ejb-3.1

How to EJB 3.1 Deployment in Tomcat 5.5.x [duplicate]

瘦欲@ 提交于 2019-11-28 10:53:39
问题 This question already has answers here : How to deploy EJB based application on Tomcat (4 answers) Closed 3 years ago . I have hosting plan which supports i) Tomcat - 5.5.xSupport ii) JDK - 1.6.x Support iii) JSP/servlet - 2.0 Support Am I able to deploy EJB 3.1 on this setup? I've heard that Tomcat does not support EJBs, but hopefully there is a workaround. Any advice is appreciated. 回答1: Apache TomEE was previously the openEJB project if i am not mistaken. You can use the openEJB libraries

Set/configure the EJB Timer Service’s DataSource

余生长醉 提交于 2019-11-28 06:01:35
I'm trying to use the Timer Service in EJB 3.1 in my app. @Stateless @LocalBean public class StatelessTimerSessionBean { @Schedule(minute = "*", second = "0", dayOfMonth = "*", month = "*", year = "*", hour = "9-17", dayOfWeek = "Mon-Fri") public void myTimer() { System.out.println("Timer event: " + new Date()); } } ".. set the EJB Timer Service’s Timer DataSource setting to a valid JDBC resource.." from EJB Timer Service I cannot figure out how to configure the Timer Datasource correctly? The error I get when deploying is: SEVERE: Exception while invoking class org.glassfish.ejb.startup

What is the difference between @Inject and @EJB

让人想犯罪 __ 提交于 2019-11-28 05:44:17
I'm currently learning the new Java EE 6 component models and am confused with the latest dependency injection mechanism. So here are my questions: 1) What is the difference between @Inject and @EJB 2) If I have a simple POJO that contains another POJOs (which one of them is the DAO code), what would be the better choice: @Inject or @EJB? Can I mix @Inject and @EJB? An example would be: ClassA implements InterfaceA and has an instance of ClassA_Adaptor ClassA_Adaptor implements InterfaceAB and has an instance of ClassB ClassB implements InterfaceB and has an instance of ClassB_Adaptor and an

JavaEE6 DAO: Should it be @Stateless or @ApplicationScoped?

我只是一个虾纸丫 提交于 2019-11-28 05:27:31
I'm currently creating an EJB3 Data Access Class to handle all database operations in my Java EE 6-application. Now, since Java EE 6 provides the new ApplicationScoped annotation, I wonder what state my EJB should have, or if it should be stateless. Would it be better to let the DAO be a @Stateless Session Bean, or an @ApplicationScoped Bean? What about @Singleton ? What are the differences between these options related to a DAO? EDIT: I'm using Glassfish 3.0.1 with the full Java EE 6 platform Whould it be better to let the DAO be a @Stateless Session Bean, or an @ApplicationScoped Bean? What

Injecting EJB 3 into Spring Bean

混江龙づ霸主 提交于 2019-11-28 00:10:56
I am trying to inject EJB into Spring (3.1.2) service (both in different WARs) Both are very simple (methods removed to simplify example): EJB: @Remote public interface MyBean { } @Singleton public class MyBeanImpl implements MyBean{ } Service: @Service public class MyServiceImpl implements MyService{ } At first sight thing is very simple, but I tried: @EJB(lookup = "java:global/ejbApp/MyBeanImpl!com.my.MyBean") private MyBean myBean; and it didin't work. Then I also tried: @EJB(mappedName = "java:global/ejbApp/MyBeanImpl!com.my.MyBean") private MyBean myBean; And @Resource(mappedName = "java

Avoid expunging timer on glassfish

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 18:49:09
I have a method annotated with @Schedule that is called by the container once in a while. @Schedule(second = "*/5", minute = "*", hour = "*", persistent = false) public void myTimerMethod() throws Exception { ... } Problem is on certain conditions i want to this method to throw an exception to cause the ongoing transaction to rollback. But if I do this more than two times the timer will be expunged and not called any more! INFO: EJB5119:Expunging timer ['68@@1359143163781@@server@@domain1' 'TimedObject = MyBean' 'Application = My-War' 'BEING_DELIVERED' 'PERIODIC' 'Container ID =

The mystery of Java EE 6 annotations inheritance

半腔热情 提交于 2019-11-27 16:22:51
问题 I'm using inheritance with EJB in a few scenarios, sometimes with annotations in the super class like this generic entityDAO: public class JpaDAO<T>{ protected Class<T> entityClass; @PersistenceContext(unitName="CarrierPortalPU") protected EntityManager em; protected CriteriaBuilder cb; @PostConstruct private void init() { cb = em.getCriteriaBuilder(); } public JpaDAO(Class<T> type) { entityClass = type; } @TransactionAttribute(TransactionAttributeType.REQUIRED) public void create(T entity) {

Is it possible to @Inject a @RequestScoped bean into a @Stateless EJB?

梦想与她 提交于 2019-11-27 13:12:56
Is it possible to inject a request-scoped CDI bean into a Stateless session bean? I had asked a related question and thought the specific CDI @RequestScoped into @Stateless question merited its own post. Passing state between EJB methods / @RequestScoped and @Stateless I also asked a similar question about JMS @MessageDriven beans - basically want to know the same about @Stateless. @RequestScoped CDI injection into @MessageDriven bean You can absolutely do what you mention and use @RequestScoped beans in an @Stateless session bean and an @MessageDriven bean. This is a core part of the CDI spec

Can @Resource be used to inject primitives in EJB3.0?

浪子不回头ぞ 提交于 2019-11-27 10:24:09
问题 Using Glassfish, I can setup a string jndi entry: JNDI name: "com/xyzcompany/echo/EchoServiceBean/viewName" Factory Class: org.glassfish.resources.custom.factory.PrimitivesAndStringFactory Properties: value="Testing123" I can then inject this container configured string into my EJB: @Resource(lookup = "com/xyzcompany/echo/EchoServiceBean/viewName") String viewName; The lookup= appears to internally do an InitialContext.lookup(...). However, this uses ejb3.1, but unfortunately my prod

EJB @Schedule wait until method completed

孤者浪人 提交于 2019-11-27 06:27:40
I want to write a back-ground job (EJB 3.1), which executes every minute. For this I use the following annotation: @Schedule(minute = "*/1", hour = "*") which is working fine. However, sometimes the job may take more than one minute. In this case, the timer is still fired, causing threading-issues. Is it somehow possible, to terminate the scheduler if the current execution is not completed? Arjan Tijms If only 1 timer may ever be active at the same time, there are a couple of solutions. First of all the @Timer should probably be present on an @Singleton . In a Singleton methods are by default