Re: Persistence unit annotation having no effect
Just to clarify: >> If there are 2 persistence.xmls, IMO any time this works you've found a bug, >> and the bug might depend on a particular classloader structure that occurs >> in your tests but not runtime environment. > > Which JPA spec version is supported by Geronimo? In the EJB3.0 spec > this is a requirement. In fact, if 2 separate PUs reference the same > entity class, they have to refer to the same persistent instances. This is only a requirement to be supported. There is nothing that says they have to be automatically detected, so if you're doing this you have to specify the class you're doing it with in the element inside persistence.xml. This is what I'm doing. I'm busy looking around the Geronimo code to see why it doesn't work. Could you perhaps clarify something to me. Where is the persistence.xml parsed, and how is it passed onto plugins/openjpa/geronimo-persistence-jpa10-builder? At first glance it looks like my elements are ignored (ie. force to an empty list at all times, and an empty list given to Hibernate). Q
Re: Persistence unit annotation having no effect
Hey David, Thanks for the response. See below > How many persistence.xml files are there? AFAIK persistence units can't > refer to each other, so you might be able to get things to work if the > classes are distributed between jars A and B but there is only one > persistence.xml, in B. In this case I'd wonder why you needed two jars, why > not just put everything in B? It's a modular system. Some modules would be on a system, where others aren't. Or you would have module A and instead of a B a customized one called "Bcustom", and so on. So it has to be many JARs. Further, for scanning to happen you have to include a persistence.xml in the JAR which you want scanned. > Not sure what management you are talking about here, and are you using > hibernate jpa? OpenJPA creates/manages the EntityManagers, EntityManagerFactories, PersistenceUnits, etc. >> Is there a way I can pass this responsibility over to OpenEJB instead? > > I don't think so. Yes. This does seem a bit complex. > If there are 2 persistence.xmls, IMO any time this works you've found a bug, > and the bug might depend on a particular classloader structure that occurs > in your tests but not runtime environment. Which JPA spec version is supported by Geronimo? In the EJB3.0 spec this is a requirement. In fact, if 2 separate PUs reference the same entity class, they have to refer to the same persistent instances. Q
Re: Persistence unit annotation having no effect
I don't understand what you are trying to do yet. How many persistence.xml files are there? AFAIK persistence units can't refer to each other, so you might be able to get things to work if the classes are distributed between jars A and B but there is only one persistence.xml, in B. In this case I'd wonder why you needed two jars, why not just put everything in B? On Oct 23, 2009, at 8:40 AM, Quintin Beukes wrote: I think I might have why it works in OpenEJB and not in Geronimo. It seems Geronimo has OpenJPA do the management, where OpenEJB does it themselves. Not sure what management you are talking about here, and are you using hibernate jpa? Is there a way I can pass this responsibility over to OpenEJB instead? I don't think so. If there are 2 persistence.xmls, IMO any time this works you've found a bug, and the bug might depend on a particular classloader structure that occurs in your tests but not runtime environment. thanks david jencks Quintin Beukes On Fri, Oct 23, 2009 at 3:25 PM, Quintin Beukes wrote: Hey, When doing unit tests, this work fine. But as soon as I deploy the app to Geronimo, it fails. I have 2 jars A and B. B depends on A, and both have entities classes. Some of the entities in B reference (foreign keys) entities in A. So to get this working I add the classes in in A I'm referencing to B's persistence unit. When I unit test, this works perfectly. But as soon as I deploy it, I get the following: 2009-10-23 15:18:26,400 INFO [config] Configuring enterprise application: net.kunye/VDS-lamps-ejb/3.0/jar 2009-10-23 15:18:26,807 INFO [OpenEJB] Auto-deploying ejb LampBean: EjbDeployment(deployment-id=VDS-lamps-ejb/LampBean) 2009-10-23 15:18:26,808 INFO [config] Enterprise application "net.kunye/VDS-lamps-ejb/3.0/jar" loaded. 2009-10-23 15:18:28,719 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [ name: VDS-lamps-PU ...] 2009-10-23 15:18:28,961 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampAssignment 2009-10-23 15:18:28,962 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampAssignment on table LampAssignment 2009-10-23 15:18:29,004 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.Lamp 2009-10-23 15:18:29,004 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.Lamp on table Lamp 2009-10-23 15:18:29,017 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampFault 2009-10-23 15:18:29,017 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampFault on table LampFault 2009-10-23 15:18:29,018 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampTest 2009-10-23 15:18:29,019 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampTest on table LampTest 2009-10-23 15:18:29,033 ERROR [GBeanInstanceState] Error while starting; GBean is now in the FAILED state: abstractName="net.kunye/VDS-lamps-ejb/3.0/jar?EJBModule=net.kunye/ VDS-lamps-ejb/3.0/ jar ,J2EEApplication = null ,PersistenceUnitModule=ejb.jar,j2eeType=PersistenceUnit,name=VDS- lamps-PU" org.hibernate.AnnotationException: @OneToOne or @ManyToOne on net.kunye.vds.lamps.LampAssignment.employee references an unknown entity: net.kunye.personnel.Employee at org .hibernate .cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:81) at org .hibernate .cfg .AnnotationConfiguration .processEndOfQueue(AnnotationConfiguration.java:456) at org .hibernate .cfg .AnnotationConfiguration .processFkSecondPassInOrder(AnnotationConfiguration.java:438) at org .hibernate .cfg .AnnotationConfiguration .secondPassCompile(AnnotationConfiguration.java:309) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java: 1162) at org .hibernate .ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) at org .hibernate .ejb .EventListenerConfigurator.configure(EventListenerConfigurator.java: 173) at org .hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java: 854) at org .hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java: 425) at org .hibernate .ejb .HibernatePersistence .createContainerEntityManagerFactory(HibernatePersistence.java:131) at org .apache .geronimo .persistence.PersistenceUnitGBean.(PersistenceUnitGBean.java: 127) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun .reflect .NativeConstructorAccessorImpl .newInstance(NativeConstructorAccessorImpl.java:39) at sun .reflect .DelegatingConstructorAccessorImpl .newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.xbean.recipe.ReflectionUtil $ConstructorFactory.create(ReflectionUtil.java:952) at org .apache.xbean.recipe.ObjectRecipe.internalCreate
Re: Persistence unit annotation having no effect
I think I might have why it works in OpenEJB and not in Geronimo. It seems Geronimo has OpenJPA do the management, where OpenEJB does it themselves. Is there a way I can pass this responsibility over to OpenEJB instead? Quintin Beukes On Fri, Oct 23, 2009 at 3:25 PM, Quintin Beukes wrote: > Hey, > > When doing unit tests, this work fine. But as soon as I deploy the app > to Geronimo, it fails. > > I have 2 jars A and B. B depends on A, and both have entities classes. > Some of the entities in B reference (foreign keys) entities in A. So > to get this working I add the classes in in A I'm referencing to B's > persistence unit. > > When I unit test, this works perfectly. But as soon as I deploy it, I > get the following: > 2009-10-23 15:18:26,400 INFO [config] Configuring enterprise > application: net.kunye/VDS-lamps-ejb/3.0/jar > 2009-10-23 15:18:26,807 INFO [OpenEJB] Auto-deploying ejb LampBean: > EjbDeployment(deployment-id=VDS-lamps-ejb/LampBean) > 2009-10-23 15:18:26,808 INFO [config] Enterprise application > "net.kunye/VDS-lamps-ejb/3.0/jar" loaded. > 2009-10-23 15:18:28,719 INFO [Ejb3Configuration] Processing > PersistenceUnitInfo [ > name: VDS-lamps-PU > ...] > 2009-10-23 15:18:28,961 INFO [AnnotationBinder] Binding entity from > annotated class: net.kunye.vds.lamps.LampAssignment > 2009-10-23 15:18:28,962 INFO [EntityBinder] Bind entity > net.kunye.vds.lamps.LampAssignment on table LampAssignment > 2009-10-23 15:18:29,004 INFO [AnnotationBinder] Binding entity from > annotated class: net.kunye.vds.lamps.Lamp > 2009-10-23 15:18:29,004 INFO [EntityBinder] Bind entity > net.kunye.vds.lamps.Lamp on table Lamp > 2009-10-23 15:18:29,017 INFO [AnnotationBinder] Binding entity from > annotated class: net.kunye.vds.lamps.LampFault > 2009-10-23 15:18:29,017 INFO [EntityBinder] Bind entity > net.kunye.vds.lamps.LampFault on table LampFault > 2009-10-23 15:18:29,018 INFO [AnnotationBinder] Binding entity from > annotated class: net.kunye.vds.lamps.LampTest > 2009-10-23 15:18:29,019 INFO [EntityBinder] Bind entity > net.kunye.vds.lamps.LampTest on table LampTest > 2009-10-23 15:18:29,033 ERROR [GBeanInstanceState] Error while > starting; GBean is now in the FAILED state: > abstractName="net.kunye/VDS-lamps-ejb/3.0/jar?EJBModule=net.kunye/VDS-lamps-ejb/3.0/jar,J2EEApplication=null,PersistenceUnitModule=ejb.jar,j2eeType=PersistenceUnit,name=VDS-lamps-PU" > org.hibernate.AnnotationException: @OneToOne or @ManyToOne on > net.kunye.vds.lamps.LampAssignment.employee references an unknown > entity: net.kunye.personnel.Employee > at > org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:81) > at > org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:456) > at > org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:438) > at > org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:309) > at > org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1162) > at > org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) > at > org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173) > at > org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854) > at > org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425) > at > org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131) > at > org.apache.geronimo.persistence.PersistenceUnitGBean.(PersistenceUnitGBean.java:127) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at > org.apache.xbean.recipe.ReflectionUtil$ConstructorFactory.create(ReflectionUtil.java:952) > at > org.apache.xbean.recipe.ObjectRecipe.internalCreate(ObjectRecipe.java:276) > at > org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:96) > at > org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:61) > at > org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:910) > at > org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:269) > at > org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:103) > at > org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(GBeanInstanceState.java:125) > at > org.apache.geronimo.gbean.runtime.GBeanInstance.startRecursive(GBeanInstance.java:538) > at
Re: [Geronimo 2.1] add a Queue JNDI ref in ejb-jar.xml? sending JMS from an EJB/MDB
OK, I found a quick fix in ejb-jar.xml jms/myMDB . jms/anotherQueue javax.jms.Queue I must admit, I still don't understand how to write a correct deployment plan. I just goggle, copy, paste.and mix up those deployment plans. -- View this message in context: http://www.nabble.com/-Geronimo-2.1--add-a-Queue-JNDI-ref-in-ejb-jar.xml--sending-JMS-from-an-EJB-MDB-tp26025166s134p26026848.html Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Persistence unit annotation having no effect
Hey, When doing unit tests, this work fine. But as soon as I deploy the app to Geronimo, it fails. I have 2 jars A and B. B depends on A, and both have entities classes. Some of the entities in B reference (foreign keys) entities in A. So to get this working I add the classes in in A I'm referencing to B's persistence unit. When I unit test, this works perfectly. But as soon as I deploy it, I get the following: 2009-10-23 15:18:26,400 INFO [config] Configuring enterprise application: net.kunye/VDS-lamps-ejb/3.0/jar 2009-10-23 15:18:26,807 INFO [OpenEJB] Auto-deploying ejb LampBean: EjbDeployment(deployment-id=VDS-lamps-ejb/LampBean) 2009-10-23 15:18:26,808 INFO [config] Enterprise application "net.kunye/VDS-lamps-ejb/3.0/jar" loaded. 2009-10-23 15:18:28,719 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [ name: VDS-lamps-PU ...] 2009-10-23 15:18:28,961 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampAssignment 2009-10-23 15:18:28,962 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampAssignment on table LampAssignment 2009-10-23 15:18:29,004 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.Lamp 2009-10-23 15:18:29,004 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.Lamp on table Lamp 2009-10-23 15:18:29,017 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampFault 2009-10-23 15:18:29,017 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampFault on table LampFault 2009-10-23 15:18:29,018 INFO [AnnotationBinder] Binding entity from annotated class: net.kunye.vds.lamps.LampTest 2009-10-23 15:18:29,019 INFO [EntityBinder] Bind entity net.kunye.vds.lamps.LampTest on table LampTest 2009-10-23 15:18:29,033 ERROR [GBeanInstanceState] Error while starting; GBean is now in the FAILED state: abstractName="net.kunye/VDS-lamps-ejb/3.0/jar?EJBModule=net.kunye/VDS-lamps-ejb/3.0/jar,J2EEApplication=null,PersistenceUnitModule=ejb.jar,j2eeType=PersistenceUnit,name=VDS-lamps-PU" org.hibernate.AnnotationException: @OneToOne or @ManyToOne on net.kunye.vds.lamps.LampAssignment.employee references an unknown entity: net.kunye.personnel.Employee at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:81) at org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:456) at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:438) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:309) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1162) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131) at org.apache.geronimo.persistence.PersistenceUnitGBean.(PersistenceUnitGBean.java:127) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.xbean.recipe.ReflectionUtil$ConstructorFactory.create(ReflectionUtil.java:952) at org.apache.xbean.recipe.ObjectRecipe.internalCreate(ObjectRecipe.java:276) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:96) at org.apache.xbean.recipe.AbstractRecipe.create(AbstractRecipe.java:61) at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:910) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:269) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:103) at org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(GBeanInstanceState.java:125) at org.apache.geronimo.gbean.runtime.GBeanInstance.startRecursive(GBeanInstance.java:538) at org.apache.geronimo.kernel.basic.BasicKernel.startRecursiveGBean(BasicKernel.java:377) at org.apache.geronimo.kernel.config.ConfigurationUtil.startConfigurationGBeans(ConfigurationUtil.java:456) at org.apache.geronimo.kernel.config.KernelConfigurationManager.start(KernelConfigurationManager.java:190) at org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration(SimpleConfigurationManager.java:546)
[Geronimo 2.1] add a Queue JNDI ref in ejb-jar.xml? sending JMS from an EJB/MDB
The same post on stackoverflow but with better code layout http://stackoverflow.com/questions/1612960/geronimo-2-1-add-a-queue-jndi-ref-in-ejb-jar-xml-sending-jms-msg-in-a-ejb-mdb hi, I have an EAR application which contains an MDB and a WAR. In this EAR application I would send a message into an another Queue from other EAR application. Say jms/anotherQueue If the message sending happens in web context, it works. I have such setup in web.xml jms/anotherQueue javax.jms.Queue Produces jms/anotherQueue But if the message sending occurs in EJB (MDB here) context, I will get a JNDI name lookup failure. javax.naming.NameNotFoundException: anotherQueue my ejb-jar.xml http://java.sun.com/xml/ns/javaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";> jms/myMDB com.my.MDBImplement javax.jms.MessageListener Container destination jms/myQueue destinationType javax.jms.Queue jms/myCF javax.jms.QueueConnectionFactory Container Shareable jms/myMDB onMessage javax.jms.Message NotSupported the openejb.jar is http://geronimo.apache.org/xml/ns/j2ee/application-2.0"; xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"; xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"; xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"; xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"; xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"; xmlns:pers="http://java.sun.com/xml/ns/persistence"; xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"; xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"; xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1";> myGroup imyMDB 1.0 ejb org.apache.geronimo.configs activemq-broker car jms/myMDB myJmsResource I define myJmsResource in geronimo-application.xml http://geronimo.apache.org/xml/ns/j2ee/application-2.0"; xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"; xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"; xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"; xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"; xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2"; xmlns:pers="http://java.sun.com/xml/ns/persistence"; xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"; xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"; xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1";> myGroup myEAR 1.0 ear geronimo-activemq-ra-2.1.4.rar myGroup myJmsResource 1.0 rar org.apache.geronimo.configs activemq-broker car myJmsResource DefaultWorkManager javax.jms.ConnectionFactory jms/myCF javax.jms.QueueConnectionFactory javax.jms.TopicConnectionFactory javax.jms.Queue org.apache.activemq.command.ActiveMQQueue jms/myQueue jms/myQueue jms/anotherQueue jms/anotherQueue javax.jms.Topic org.apache.activemq.command.ActiveMQTopic It seems that myMDB cannot understand what jms/anotherQueue is!!! How can I fix it? -- View this message in context: http://www.nabble.com/-Geronimo-2.1--add-a-Queue-JNDI-ref-in-ejb-jar.xml--sending-JMS-from-an-EJB-MDB-tp26025166s134p26025166.html Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
Is there anybody using Geronimo and Camel?
Hello! Is there anybody using Geronimo and Camel? Is the integration easy? Is it working well? Thank you very much. -- View this message in context: http://www.nabble.com/Is-there-anybody-using-Geronimo-and-Camel--tp26024285s134p26024285.html Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.