ejb-3.0

New to EJB world… Null pointer exception in EJB client

非 Y 不嫁゛ 提交于 2019-11-28 08:49:37
I am learning EJB and I am trying to execute the Helloworld example given in EJB In Action book. My app server is JBoss, I created the Jar file for the bean class and interface in the right directory( I can see the EJB in JMX console). Now I created a simple client using EJB annotations, but I am getting a NullPointerException. Here is my client code. Client code: package com.client; import javax.ejb.EJB; import com.EJB.*; public class HelloWorldClient { @EJB private static HelloWorldInterface HelloBean; public static void main(String[] args) { HelloBean.SayHelloWorldInEJB(); } } Bean class

How can i deploy Session Bean on another computer with Client JSP/Servlet

喜你入骨 提交于 2019-11-28 08:47:43
Hello Everybody i'm new in EJB3, i know how to deploy Session Bean (Stateless or stateful) on Glassfish server in one computer. My question is: how can i deploy session bean on Computer A and Deploy Servlet or JSP on Computer B? It mean Computer A have Session Bean Source and Computer B have Servlet or JSP source. if use 1 computer i can use @EJB dependency inject lookup Session Bean but on another computer how can i do it for client code? Example for 1 computer @EJB private StatelessRemote remote ; double Dosomething= remote.Dosomething(); out.println(Dosomething); Create a "client jar" with

Embedding images into html email with java mail

吃可爱长大的小学妹 提交于 2019-11-28 08:24:28
I am sending html and images with javamail but for some reason I don't see the images as part of the html, I see them only as an attachment. I don't know why is that. This is how it looks like when one of my users receive an email: I would like to mention also that is how the html looks like: private String generateActivationLinkTemplate() { String htmlText = ""; htmlText ="<table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td><img src=\"cid:logoimg\"/></td> </tr> <tr> <td height=\"220\"> <p>Thanks for Joining Site.com</p> <p>Lorem ipsum dolor sit amet, consectetur

A JTA EntityManager cannot use getTransaction()

有些话、适合烂在心里 提交于 2019-11-28 08:14:30
How do I have the following code in my non-ejb application. The code works. @Override public void saveItems(Collection<T> items) { synchronized (em) { EntityTransaction tx = em.getTransaction(); try { tx.begin(); for (T item : items) { saveItem_((Class<T>) null, item); } tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } } In a new application I'm using EJB3 + JSF and would like to re-use the library containing the code above. My peristence unit for the new application looks like this: <persistence-unit name="myApp" transaction-type="JTA"> <provider>org.hibernate.ejb

Declaring @Resource and @EJB at the class level in Java EE6

蓝咒 提交于 2019-11-28 07:53:10
Is there any situation still ( given that Java EE6 has java:global/, app/, module/ naming standards) that necessitates declaring EJBs or Resources like the example below? @EJB (name = "ejb/PlaceBid", beanInterface = PlaceBid.class) public class ActionBazaarBidControllerServlet extends HttpServlet { } Looking up PlaceBid in the helper class used by ActionBazaarBidControllerServlet PlaceBid placeBid = (PlaceBid)context.lookup("java:comp/env/ejb/PlaceBid"); The java:comp/env/ namespace is sometimes a little understood feature. This namespace corresponds to what is called the Enterprise Naming

How is the return-value of SessionContext.getBusinessObject() different from 'this' keyword used in the bean?

一笑奈何 提交于 2019-11-28 03:53:41
问题 The SessionContext.getBusinessObject() is described in the docs as follows, Obtain an object that can be used to invoke the current bean through the given business interface. Parameters: businessInterface - One of the local business interfaces or remote business interfaces for this session bean. Returns: The business object corresponding to the given business interface. Can't I use the 'this' keyword in Java instead, to accomplish the same ? How are these different ? 回答1: The motivation here

Should I use EJB3 or Spring for my business layer?

依然范特西╮ 提交于 2019-11-28 02:50:50
My team is developing a new service oriented product with a web front-end. In discussions about what technologies we will use we have settled on running a JBoss application server, and Flex frontend (with possible desktop deployment using Adobe AIR), and web services to interface the client and server. We've reached an impasse when it comes to which server technology to use for our business logic. The big argument is between EJB3 and Spring, with our biggest concerns being scalability and performance, and also maintainability of the code base. Here are my questions: What are the arguments for

Spring vs EJB. Can Spring replace EJB? [closed]

霸气de小男生 提交于 2019-11-28 02:39:09
Since Spring is able to use transactions just like EJB . For me, Spring is able to replace the requirement of using EJB. Can anyone tell me what are the extra advantages of using EJB? Spring was developed as an alternative to EJB right from its inception, so the answer is of course you can use Spring in place of EJBs. If there's an "advantage" to using EJBs, I'd say that it would depend on the skills of your team. If you have no Spring expertise, and lots of EJB experience, then maybe sticking with EJB 3.0 is a good move. App servers written to support the EJB standard can, in theory, be

Many-to-Many link tables in grails (GORM) / hibernate

天大地大妈咪最大 提交于 2019-11-28 01:28:39
问题 I'm playing aroud with Grails and am finding the ORM stuff tedious because I don't fully understand what I'm doing when it comes to domain classes. I'm hoping someone can put me back on track Consider the following Test Job One:Many Hardware Used on Job Many:One Physical Hardware ...this is analogous to the classic Order, OrderLine, Product scenario seen in university DB examples I've created the following domain classes class Job { String jobName String jobDescription } class HardwareOnJob {

EJBException when calling entityManager.getTransaction()

淺唱寂寞╮ 提交于 2019-11-28 00:22:01
问题 This is probably something trivial, but I'd love some help. I get: javax.ejb.EJBException: java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager 11:54:37,105 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77) 11:54:37,105 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) 11:54:37,105 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)