ejb-3.0

NameNotFoundException when calling a EJB in Weblogic 10.3

时光怂恿深爱的人放手 提交于 2019-12-03 03:24:29
I have a EJB defined as this: package com.foo; @Stateless (mappedName="HelloWorld") public class HelloWorldBean implements HelloWorld, HelloWorldLocal .... When it's deployed to Weblogic (WL), it gets the name myBean. I'm not sure if this is important. I try to call the bean with this code: Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL, "t3://localhost:7001"); ic = new InitialContext(ht); tp = (HelloWorld) ic.lookup("HelloWorld#com.foo.HelloWorldBean"); Anyone know why I get the following error?

Glassfish v3 / JNDI entry cannot be found problems!

左心房为你撑大大i 提交于 2019-12-03 03:06:53
I've been having problems trying to call an EJB's method from a Java Application Client. Here is the code. EJB Remote Interface package com.test; import javax.ejb.Remote; @Remote public interface HelloBeanRemote { public String sayHello(); } EJB package com.test; import javax.ejb.Stateless; @Stateless (name="HelloBeanExample" , mappedName="ejb/HelloBean") public class HelloBean implements HelloBeanRemote { @Override public String sayHello(){ return "hola"; } } Main class (another project) import com.test.HelloBeanRemote; import javax.naming.Context; import javax.naming.InitialContext; public

What is an Enterprise Java Bean really?

做~自己de王妃 提交于 2019-12-03 02:28:47
On the Tomcat FAQ it says: "Tomcat is not an EJB server. Tomcat is not a full J2EE server." But if I: use Spring to supply an application context annotate my entities with JPA annotations (and use Hibernate as a JPA provider) configure C3P0 as a connection pooling data source annotate my service methods with @Transactional (and use Atomikos as JTA provider) Use JAXB for marshalling and unmarshalling and possibly add my own JNDI capability then don't I effectively have a Java EE application server? And then aren't my beans EJBs? Or is there some other defining characteristic? What is it that a

Named Query Or Native Query or Query Which one is better in performance point of view?

∥☆過路亽.° 提交于 2019-12-03 02:10:14
Which one is better among following(EJB 3 JPA) //Query a). getEntityManager().createQuery ("select o from User o"); //Named Query where findAllUser is defined at Entity level b). getEntityManager().createNamedQuery ("User.findAllUser");** //Native Query c). getEntityManager().createNativeQuery ("SELECT * FROM TBLMUSER "); Please explain me which approach is better in which case?. Wundwin Born createQuery() It should be used for dynamic query creation. //Example dynamic query StringBuilder builder = new StringBuilder("select e from Employee e"); if (empName != null) { builder.append(" where e

Why should we use EJB? [closed]

荒凉一梦 提交于 2019-12-03 01:56:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . What is EJB, and why we should use it? Please explain in simple language. Thank you. 回答1: The EJB or Enterprise Java Beans are plain java classes (since version 3.0) with annotations that enable to you write the business logic of your applications and later deploy it (or

How to limit the number of MDB instances listening to a Jboss JMS queue

不打扰是莪最后的温柔 提交于 2019-12-02 20:48:23
I'm having a problem with the following setup: A Java application send email msg to a JMS queue, then an MDB listening to the queue get the email msg with the onMessage method, it open a connection on the Gmail SMTP, send the email to the SMTP and close the connection. Doing this on all message in the JMS queue. It is working great when I have up to 5 messages in the queue at the same time. All messages are picked-up in the same time by 5 different instances of the MDB, so I have 5 concurrent connection to the Gmail SMTP server. But when there is more messages in the JMS queue, I get a

How to stop endless EJB 3 timer?

孤人 提交于 2019-12-02 20:43:15
I am new to EJB 3 . I use the following code to start endless EJB 3 timer then deploying it on JBOSS 4.2.3 @Stateless public class SimpleBean implements SimpleBeanRemote,TimerService { @Resource TimerService timerService; private Timer timer ; @Timeout public void timeout(Timer timer) { System.out.println("Hello EJB"); } } then calling it timer = timerService.createTimer(10, 5000, null); It works well. I created a client class that calls a method that creates the timer and a method that is called when the timer times out. I forget to call cancel then it does not stop .redeploy with cancel call

EJB3 transaction rollback

老子叫甜甜 提交于 2019-12-02 18:54:06
I'm using CMT in EJB3 state-less session beans. Also I've created my own Exception having the annotation "@ApplicationException (rollback=true)". Do I have to use "context.setRollbackOnly()" when I want to rollback the transaction? Can I just rollback the transaction by throwing an exception inside public method in the bean? If so (the answer to Q#2 is yes) do I have to throw the exception out of the method by declaring the exception in the method or will it be sufficient to just throw an exception inside the method and handle it inside the same method itself? (I don't want to propagate the

How do you unit test Java EE code?

白昼怎懂夜的黑 提交于 2019-12-02 17:33:39
I want to ask for your prefered way to test Java EE code? I found only three project, that are trying to help to code unit tests in Java EE environment: http://jakarta.apache.org/cactus/ : Last Published: 2009-01-18 http://www.junitee.org/ : Last Release: 2004-12-11 http://ejb3unit.sourceforge.net/ : Last Release: 2008-05-17 So I wonder, is there any framework helping to write (j) unit test for Java EE code? do you use embedded Java EE servers like jboss or glassfish v3? do you mockup and inject by yourself? Thanks a lot... Pascal Thivent If by Unit Testing you mean... unit testing (testing a

Examples or Uses Cases to explain EJB Transaction Attributes

可紊 提交于 2019-12-02 17:12:52
There are some good explanations of EJB Transaction Attributes (and annotations) out there, for example, OpenEJB's . But sometimes when I try to cover this with someone who hasn't worked with many transactional resources, I see their eyes start to glaze over. So my question - how would you explain EJB Transaction Attributes to your grandmother? Required RequiresNew Mandatory NotSupported Supports Never I'm thinking a contrived example, analogy, or a concise real-world use case would be helpful. Miguel Ping You can think of them in terms of Collaboration . Let's say you are a chef, and you have