ejb-3.0

Error invoking timeout for timer - could not obtain lock within 5MINUTES at EJB 3 timerservice

孤街浪徒 提交于 2019-12-03 07:42:27
问题 I have an application running on jboss 6.1 that defines a lot of dinamyc timers at the startup (e.g doSomething every minute) based on informations already persisted on the database. The timers are created programmatically based on these informations: TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(info); timerConfig.setPersistent(false); Timer timer = timerService.createCalendarTimer(scheduleExpression, timerConfig); Today i found that the "every minute" timer created was

How to stop endless EJB 3 timer?

…衆ロ難τιáo~ 提交于 2019-12-03 07:03:23
问题 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

Is it safe to inject an EJB into a servlet as an instance variable?

徘徊边缘 提交于 2019-12-03 06:47:51
We all know that in the web tier there is the possibility that only a single instance of a given Servlet exists which services multiple requests. This can lead to threading issues in instance variables. My question is, is it safe to inject an EJB using the @EJB annotation into a servlet as an instance variable? My initial instinct would be no, under the assumption that the same instance of the EJB would service multiple requests at the same time. It would seem that this would also be the instinct of a number of other programmers: Don't inject to servlets However have I jumped to the wrong

EJB3 - using 2 persistence units within a transaction (Exception: Local transaction already has 1 non-XA Resource)

杀马特。学长 韩版系。学妹 提交于 2019-12-03 06:30:21
I am trying to use 2 persistence units within the same transaction in a Java EE application deployed on Glassfish. The 2 persistence units are defined in persistence.xml, as follows: <persistence-unit name="BeachWater"> <jta-data-source>jdbc/BeachWater</jta-data-source> ... <persistence-unit name="LIMS"> <jta-data-source>jdbc/BeachWaterLIMS</jta-data-source> ... These persistence units correspond to JDBC resources and connection pools which I had defined in Glassfish as follows (include one here as both are identical apart from names & database connection info): JDBC Resource: JNDI Name: jdbc

How does EJB and JPA relate? [duplicate]

三世轮回 提交于 2019-12-03 05:51:40
问题 This question already has answers here : Relationship between EJB 3.0 and JPA? (4 answers) Closed 2 years ago . I am reading the EJB 3 in Action book and I have the following question : Is the POJO's you write and annotate with @Entity and so on also a EJB entity type? I don't understand what JPA has to do with EJB. Isn't JPA a own specification now? The entities are also contained in a own persistence container. They talk about EJB 3 Java Persistence API etc. but I don't understand what

EJB3 transaction rollback

泪湿孤枕 提交于 2019-12-03 05:36:02
问题 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

javax.naming.NameNotFoundException

女生的网名这么多〃 提交于 2019-12-03 05:31:33
I am running an example of ejb using JBoss5 Container. I am using an example from here(Part one) . In the example I deployed bean in JBoss and an application in Tomcat(to acces the bean from JBoss). I am getting the error in the screen of tomcat server javax.naming.NameNotFoundException: greetJndi not bound ( greetJndi is the jndi-name in jboss.xml file ) Is there any specific directory structure to deploy in JBoss? Thanks Pascal Thivent I am getting the error (...) javax.naming.NameNotFoundException: greetJndi not bound This means that nothing is bound to the jndi name greetJndi , very likely

EJB: Avoid Transaction rollback

只愿长相守 提交于 2019-12-03 04:59:56
When a (transactional) method of an EJB calls another (transactional) method of another EJB, and an exception is thrown in the second, but catched in the first one, it seems that the transaction is automatically rolled back when the second one returns, even if the first one catches it, is this true? how can I avoid it? The scenario is the following one: @Stateless class ClassA { @EJB ClassB objectB; methodA() { try { objectB.methodB(); } catch(Exception e) { //Here the transaction started in this method is //automatically rolled back. Is this avoidable? } } } @Stateless class ClassB { methodB(

How do you unit test Java EE code?

给你一囗甜甜゛ 提交于 2019-12-03 04:14:58
问题 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

Examples or Uses Cases to explain EJB Transaction Attributes

元气小坏坏 提交于 2019-12-03 03:45:55
问题 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