Re: EJB Annotation does not work in AbstractServlet
Thanks for your response and for opening this Jira. It will be great to have this feature. Actually, my abstract Servlet have an abstract method wich return an EJB, and all my other servlets (extending the abstract servlet) define an EJB just for returning it to the super class ... Any idea of what version of OpenEJB should have this feature ? Maxime David Blevins wrote: > > > On Dec 19, 2008, at 1:03 AM, Maxime Thieu wrote: > >> >> Hello, >> >> I am using OpenEJB 3.1 in Tomcat. >> >> I use the Annotation @EJB in my Servlet in order to obtain my EJB >> and it >> works well. >> >> But If I use the Annotation @EJB in an abstract Servlet (which is the >> superclass of all my Servlets), it does'nt work : it seams that the >> EJB >> Annotation is not "interpreted" by openEJB. >> >> Is this normal ? Is there any way for referencing EJB in abstract >> Servlet ? > > We could get this to work, but we'd have to replace the annotation > processor in Tomcat. That isn't really a big deal and would be an > easy feature to add. We simply error on the conservative side when it > comes to replacing parts of Tomcat in the Tomcat/OpenEJB integration > (we want Tomcat to still feel like Tomcat), usually holding off till > someone requests a feature that requires it. This would be one of > those features. > > The Tomcat annotation processor is pretty decent in that it looks for > the basic annotations then blindly looks up from JNDI and injects what > it finds -- this allows us to expand it to support things that Tomcat > doesn't normally support. But there two things it will not do: look > for annotations in super classes (as you notice); do xml-only injection. > > Added a jira for it: > > https://issues.apache.org/jira/browse/OPENEJB-979 > > -David > > > -- View this message in context: http://www.nabble.com/EJB-Annotation-does-not-work-in-AbstractServlet-tp21087942p21125847.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Exception in Transaction does not show the original Cause
Hello, I am using OpenEJB3.1 in Tomcat with JPA and Hibernate 3.3 as provider. It works well, but when an persistence exception occurs (originaly thrown by Hibernate, for exemple, Constraint violation), the visible Exception is : javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization With no indication of the Hibernate Exception (whereas with Spring framework, the original Hibernate cause is visible) Is there any way to configure the Transaction Manager to have the original cause (Hibernate Exception) in logs ? Thanks in advance, Maxime Full Exception Log : avax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:345) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:291) at $Proxy105.createObject(Unknown Source) at ... at ... at ... at ... at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.openejb.tomcat.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509) at java.lang.Thread.run(Thread.java:595) Caused by: javax.transaction.RollbackException: Unable to commit: transaction marked for rollback at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:271) at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:245) at org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:291) at org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71) at org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:74) at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:231) at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286) ... 21 more -- View this message in context: http://www.nabble.com/Exception-in-Transaction-does-not-show-the-original-Cause-tp21124326p21124326.html Sent from the OpenEJB User mailing list archive at Nabble.com.
EJB Annotation does not work in AbstractServlet
Hello, I am using OpenEJB 3.1 in Tomcat. I use the Annotation @EJB in my Servlet in order to obtain my EJB and it works well. But If I use the Annotation @EJB in an abstract Servlet (which is the superclass of all my Servlets), it does'nt work : it seams that the EJB Annotation is not "interpreted" by openEJB. Is this normal ? Is there any way for referencing EJB in abstract Servlet ? Thanks in advance, Maxime Example : public abstract class AbstractTestServlet extends HttpServlet { @EJB protected MyEJB myEJB; protected void testEJB() { myEJB.test(); } } public class TestServlet extends AbstractTestServlet { @EJB protected MyEJB myEJB2; ... protected void testMyEJB() { myEJB2.test(); // this works testEJB(); // this doesn't work : NPE myEJB.test(); // this doesn't work : NPE (myEJB is null) } } -- View this message in context: http://www.nabble.com/EJB-Annotation-does-not-work-in-AbstractServlet-tp21087942p21087942.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: web.xml with SYSTEM ENTITY (in DTD) provoques NPE in OPENEJB loading
Yes, this configuration works well in standalone Tomcat. The file.xml is situated in WEB-INF folder (where web.xml is situated) and contains some servlet definitions. The fact is that OpenEJB parser does not read system entities whereas Tomcat did it. A temporary solution for me, is to store the content of file.xml in web.xml, but it would be great if OpenEJB could read web.xml like Tomcat does. Thanks for your response Maxime Dain Sundstrom wrote: > > Is this something that works in standalone Tomcat? If it is, where is > the "file.xml" file located? This is not likely to be fixed in the > next release, so in the mean time, you'll have to unroll the entity > reference by hand (or using some tool). > > -dain > > On Nov 28, 2008, at 7:53 AM, Maxime Thieu wrote: > >> >> Hello, >> >> I am using OpenEJB 3.1 in Tomcat (with openejb.war). >> >> I have webapps with web.xml containing SYSTEM ENTITY in DTD (for >> inclusion >> of xml) like this : >> >> >> > Application >> 2.3//EN" >> "http://java.sun.com/j2ee/dtds/web- >> app_2.3.dtd" [ >> >> >> ]> >> >> >> &inclusionFile; >> >> ... >> >> >> >> During Tomcat starting (when OpenEJB reads webapp definition), I >> have the >> following blocking error: >> >> ERROR - Unable to load web.xml in war /test: Exception: Encountered >> unknown >> error parsing the web.xml file: jndi:/localhost/test/WEB-INF/ >> web.xml: null >> >> I found (with the StackTrace) that the problem is situated in >> JaxbJavaee >> class, in inner class NamespaceFilter, when resolving entity: >> System entity have publicId with null value and it provoques a null >> pointer >> exception when adding it to the Set publicIds. >> >>public InputSource resolveEntity(String publicId, String >> systemId) >> throws SAXException, IOException { >>Set publicIds = currentPublicId.get(); >>if (publicIds != null) { >>publicIds.add(publicId); >>} >>return EMPTY_INPUT_SOURCE; >>} >> >> >> Is this a bug ? Is there any other way to resolve this ? >> >> Thanks in advance, >> >> Maxime >> >> here is the complete StackTrace of the Error in the log : >> ERROR - Unable to load web.xml in war /test: Exception: Encountered >> unknown >> error parsing the web.xml file: jndi:/localhost/test/WEB-INF/ >> web.xml: null >> org.apache.openejb.OpenEJBException: Encountered unknown error >> parsing the >> web.xml file: jndi:/localhost/test/WEB-INF/web.xml: null >> at >> org >> .apache >> .openejb.config.ReadDescriptors.readWebApp(ReadDescriptors.java:496) >> at >> org >> .apache >> .openejb >> .tomcat >> .catalina >> .TomcatWebAppBuilder.createWebModule(TomcatWebAppBuilder.java:609) >> at >> org >> .apache >> .openejb >> .tomcat >> .catalina >> .TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:529) >> at >> org >> .apache >> .openejb >> .tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java: >> 234) >> at >> org >> .apache >> .openejb >> .tomcat >> .catalina.TomcatLoader.processRunningApplications(TomcatLoader.java: >> 228) >> at >> org >> .apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.java: >> 139) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun >> .reflect >> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) >> at >> sun >> .reflect >> .DelegatingMethodAccessorImpl >> .invoke(DelegatingMethodAccessorImpl.java:43) >> at java.lang.reflect.Method.invoke(Method.java:615) >> at org.apache.openejb.loader.Embedder.init(Embedder.java:75) >> at org.apache.openejb.tomcat.loader.TomcatHook.hook(TomcatHook.java: >> 98) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun >> .reflect >> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) >> at >> sun >> .reflect >> .DelegatingMethodAccessorImpl >> .invoke(DelegatingMethodAccessorImpl.java:43) >> at java.lang.reflect.Method.invoke(Method.java:615) >> at >> org >> .apache >>
web.xml with SYSTEM ENTITY (in DTD) provoques NPE in OPENEJB loading
Hello, I am using OpenEJB 3.1 in Tomcat (with openejb.war). I have webapps with web.xml containing SYSTEM ENTITY in DTD (for inclusion of xml) like this : http://java.sun.com/j2ee/dtds/web-app_2.3.dtd"; [ ]> &inclusionFile; ... During Tomcat starting (when OpenEJB reads webapp definition), I have the following blocking error: ERROR - Unable to load web.xml in war /test: Exception: Encountered unknown error parsing the web.xml file: jndi:/localhost/test/WEB-INF/web.xml: null I found (with the StackTrace) that the problem is situated in JaxbJavaee class, in inner class NamespaceFilter, when resolving entity: System entity have publicId with null value and it provoques a null pointer exception when adding it to the Set publicIds. public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { Set publicIds = currentPublicId.get(); if (publicIds != null) { publicIds.add(publicId); } return EMPTY_INPUT_SOURCE; } Is this a bug ? Is there any other way to resolve this ? Thanks in advance, Maxime here is the complete StackTrace of the Error in the log : ERROR - Unable to load web.xml in war /test: Exception: Encountered unknown error parsing the web.xml file: jndi:/localhost/test/WEB-INF/web.xml: null org.apache.openejb.OpenEJBException: Encountered unknown error parsing the web.xml file: jndi:/localhost/test/WEB-INF/web.xml: null at org.apache.openejb.config.ReadDescriptors.readWebApp(ReadDescriptors.java:496) at org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.createWebModule(TomcatWebAppBuilder.java:609) at org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:529) at org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:234) at org.apache.openejb.tomcat.catalina.TomcatLoader.processRunningApplications(TomcatLoader.java:228) at org.apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.java:139) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.apache.openejb.loader.Embedder.init(Embedder.java:75) at org.apache.openejb.tomcat.loader.TomcatHook.hook(TomcatHook.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.apache.openejb.tomcat.loader.TomcatEmbedder.embed(TomcatEmbedder.java:74) at org.apache.openejb.tomcat.loader.LoaderServlet.init(LoaderServlet.java:44) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4055) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:576) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
Re: persistence.xml in a Jar in Tomcat Common classloader (ERROR : PersistenceUnit already deployed)
Hi David, Thanks for your anwser. I allready try including persistence.xml in my webapp. But this doesn't works because I have Service in service.jar with Annotation @PersistenceContext under EntityManager. OpenEJB doesn't find it (because it's defined in the webapp) when it loads service.jar : ERROR - FAIL ... MyService: Missing required persistence.xml for @PersistenceContext ref "entityManager" to unit "jpa-service" Even if this has worked, it is not really what I'm after. Indeed, I will be very interested if "global" persistence units where managed by OpenEJB. Thanks in advance, Maxime David Blevins wrote: > > Hi Maxime, > > It should be possible to put the service.jar in the Tomcat lib/ > directory without a persistence.xml in it and then include that > persistence xml in your webapp. You should be able to include a file> element in the unit declaration that points to the C:/tomcat6/ > lib/service.jar so all the entities will be discovered without having > to explicitly list them via the element. You'd have to > include the same persistence.xml in each webapp that wanted to reuse > the classes in service.jar. > > Not entirely sure though if that's really what you're after. We don't > currently have any support for "global" persistence units. Meaning > say a persistence unit declared outside of an ear at server level and > available to all ears/apps deployed. It might be something we could > add if that's really what you're after. > > -David > -- View this message in context: http://www.nabble.com/persistence.xml-in-a-Jar-in-Tomcat-Common-classloader-%28ERROR-%3A-PersistenceUnit-already-deployed%29-tp20008468p20010734.html Sent from the OpenEJB User mailing list archive at Nabble.com.
persistence.xml in a Jar in Tomcat Common classloader (ERROR : PersistenceUnit already deployed)
Hello everybody, I am developping ejb-jar module (let's call it service.jar) which contains EJB, Entity, Service and persistence.xml (in META-INF). I am developping webapp module (let's call it test.war) which contains Servlets who are calling some Service in service.jar (using entityManager to persist some data). I am trying to make this work under Tomcat 6.xx using OpenEJB 3.1 (build: 20081009-03:31). A.jar is present in the common classloader of Tomcat (in lib directory) in order to be visible by all webapps. In this case, during Tomcat starting, OpenEJB show the following Error : "ERROR - Unable to deploy collapsed ear in war /test: Exception: Creating application failed: C:\tomcat6\webapps\test: PersistenceUnit already deployed: /C:/tomcat6/lib/service.jar" If service.jar is present in the WEB-INF/lib of test.war, everything works well, but this is not I want (classes of service.jar should be visible by all webapps). Do I miss something? Is this possible with OpenEJB? I make several try and search but I do not find how to solve this (and I am a beginner in OpenEJB). Thanks in advance, any help would be appreciated. Maxime here is the complete StackTrace of the Error in the log : ERROR - Unable to deploy collapsed ear in war /test: Exception: Creating application failed: C:\tomcat6\webapps\test: PersistenceUnit already deployed: /C:/tomcat6/lib/service.jar org.apache.openejb.OpenEJBException: Creating application failed: C:\tomcat6\webapps\test: PersistenceUnit already deployed: /C:/tomcat6/lib/service.jar at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:650) at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:447) at org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:241) at org.apache.openejb.tomcat.catalina.TomcatLoader.processRunningApplications(TomcatLoader.java:228) at org.apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.java:139) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.apache.openejb.loader.Embedder.init(Embedder.java:75) at org.apache.openejb.tomcat.loader.TomcatHook.hook(TomcatHook.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.apache.openejb.tomcat.loader.TomcatEmbedder.embed(TomcatEmbedder.java:74) at org.apache.openejb.tomcat.loader.LoaderServlet.init(LoaderServlet.java:44) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4055) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:576) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap