Re: Rollback transactions in unit testing
On Sep 29, 2008, at 8:39 AM, Glauber Ferreira wrote: Hi all. I need to rollback transactions in order to revert all data modified (deleted, updated, created) by my tests. How can I do that in the test code listed in this link: http://openejb.apache.org/3.0/unit-testing-transactions.html Suggestions in this thread are pretty good. A couple additional possibilities to throw on the stack.. If you throw a runtime exception from the TransactionBean call method the container will rollback the transaction. Another option is to call the setRollbackOnly() method on the javax.ejb.SessionContext object. A session ejb can have it injected with a field declared like @Resource SessionContext sessionContext; -David
Re: EntityManager not picking up Map properties
On Sep 18, 2008, at 10:28 PM, rde8026 wrote: I'm using Hibernate as my JPA provider in a Stateless EJB. I need to add the hibernate.default_catalog property to the EntityManager based on the dialect being used (i.e. SQL Server = dbo). I'm injecting the EntityManagerFactory and trying to construct an EntityManager based off that but passing a HashMap to it with that single property...and its not pre-pending the sql statements correctly. If I do it via the persistence.xml file it worksany thoughts? Here is a code snippet.. MapString, String props = new HashMapString, String(); props.put(hibernate.default_catalog, dbo); em = emf.createEntityManager(props); Likely a bug in hibernate as that call goes directly to them. We get the hibernate EntityManagerFactory via a call like: PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance(); EntityManagerFactory emf = persistenceProvider.createContainerEntityManagerFactory(unitInfo, new HashMap()); And the persistence.xml data is in the PersistenceUnitInfo implementation we create and hand to the persistence provider (Hibernate in this case). Seems they only support that property (or perhaps all properties) via the call above and not via the EntityManagerFactory createEntityManager method. -David
RE: Override annotations in ejb-jar.xml for a test case
Hi, We don't have any functionality for supplying an alternate ejb-jar.xml for testing purposes. It's not a bad idea and is something we might be able to add after we get the 3.1 release out the door. [Marcin Kwapisz] My Maven2 profile is as follows. resource directs to folder src/test/resources/Toplink (METAINF) where modified ejb-jar.xml and persistence.xml exist. profile idTestEJB_Toplink/id activation property nameenv/name valuetesttoplink/value /property /activation dependencies dependency groupIdtoplink.essentials/groupId artifactIdtoplink-essentials-agent/artifactId version2.1-53/version scopetest/scope /dependency dependency groupIdtoplink.essentials/groupId artifactIdtoplink-essentials/artifactId version2.1-53/version scopetest/scope /dependency dependency groupIdzsk.samples/groupId artifactIdToplinkExternalContainer/artifactId version1.0/version scopetest/scope /dependency /dependencies build resources resource directorysrc/test/resources/Toplink/directory /resource /resources /build /profile This might be because the ejb-jar.xml is with the ejbs that are annotated. [Marcin Kwapisz] Correct me if I am wrong: when ejb-jar is empty OpenEJB process all class files (in classes and test-classes) and looks for annotated EJBs. When ejb-jar is modified, OpenEJB process that file and looks for annotated EJBs in test-classes only. Regards -- Marcin Kwapisz Division of Computer Networks Technical Univeristy of Lodz, Poland
Re: Override annotations in ejb-jar.xml for a test case
On Oct 9, 2008, at 3:16 AM, Marcin Kwapisz wrote: Correct me if I am wrong: when ejb-jar is empty OpenEJB process all class files (in classes and test-classes) and looks for annotated EJBs. When ejb-jar is modified, OpenEJB process that file and looks for annotated EJBs in test-classes only. We look for annotated ejbs in classes/ if we find a classes/META-INF/ ejb-jar.xml file and the ejb-jar.xml file does not have 'metadata- complete' attribute set to 'true'. Aside from the metadata-complete attribute, the contents of the ejb-jar.xml do not prevent searching for annotations or annotated ejbs. The classes/ directory is treated as a single ejb jar and the contents of the classes/META-INF/ejb- jar.xml apply only to the beans in classes/. The same rule applies for test-classes/. Specifically, we look for annotated ejbs in test-classes/ if we find a test-classes/META-INF/ejb- jar.xml file and the ejb-jar.xml file does not have 'metadata- complete' attribute set to 'true' and the test-classes/ directory is treated as a single ejb jar, separate from classes/, and the contents of the test-classes/META-INF/ejb-jar.xml apply only to the beans in test-classes/. Hope that helps. -David
Re: OpenEJB with JUnit from NetBeans: NameNotFoundException
On Oct 8, 2008, at 2:09 PM, Bernhard Humm wrote: This is what I did first, with the same effect: NameNotFoundException Could you post the log output from the test run? -David
Re: OpenEJB with JUnit from NetBeans: NameNotFoundException
On Oct 9, 2008, at 4:32 AM, Bernhard Humm wrote: init: deps-jar: compile: compile-test: Testsuite: org.superbiz.calculator.CalculatorTest Apache OpenEJB 3.0build: 20080408-04:13 http://openejb.apache.org/ INFO - openejb.home = C:\temp\NetBeans\OpenEJBTest INFO - openejb.base = C:\temp\NetBeans\OpenEJBTest INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) INFO - Configuring Service(id=Default JDK 1.3 ProxyFactory, type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory) Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 5,234 sec It doesn't look like the app is getting discovered with the way it's setup in NetBeans. OpenEJB will search for directories or jars containing a META-INF/ejb-jar.xml file and load those directories and jars as individual ejb jars. We have NetBeans users, so I know it's capable of putting both the classes and the META-INF/ejb-jar.xml in the same directory so that OpenEJB can discover them together as an app. We just need to figure out what might be happening with this particular setup. Run this in your test case and see if your classpath is setup right. There should be a META-INF/ejb-jar.xml file in any directories that contain ejb classes that should be deployed by OpenEJB. EnumerationURL ejbJars = this.getClass().getClassLoader().getResources(META-INF/ejb-jar.xml); while (ejbJars.hasMoreElements()) { URL url = ejbJars.nextElement(); System.out.println(app = + url); } -David
Re: JNDI lookup in Tomcat
In a servlet listener for my webapp, I'm using this: public void contextInitialized(ServletContextEvent aArg0) { System.setProperty(Context.INITIAL_CONTEXT_FACTORY, org.apache.openejb.client.LocalInitialContextFactory); System.err.println( FULL JNDI TREE FROM STARTUP); try { InitialContext ic = new InitialContext(); listContext(,ic); } catch (NamingException e) { System.err.println(Could not list tree.+e); } System.err.println( FULL JNDI TREE FROM STARTUP); } private static final void listContext(String s, Context c) throws NamingException { NamingEnumerationNameClassPair pairs = c.list(); for (; pairs.hasMoreElements();) { NameClassPair p = pairs.next(); System.err.println(s+/+p.getName() + + p.getClassName()); Object o = c.lookup(p.getName()); if (o instanceof Context) { Context child = (Context) o; listContext(s+/+p.getName(), child); } } } And here's what I get: /. java.lang.String /openejb org.apache.openejb.core.ivm.naming.IvmContext /openejb/ConfigurationInfoBusinessRemote org.apache.openejb.core.ivm.naming.Busi nessRemoteReference /openejb/DeployerBusinessRemote org.apache.openejb.core.ivm.naming.BusinessRemot eReference ...and then other contexts created by my MDB/SB. I don't see any /openejb/TransactionManager there. /Zog David Blevins wrote: On Oct 8, 2008, at 12:37 PM, Zog wrote: I installed the openejb.war in tomcat-6.0.18 and my ear as a collapsed ear. When I lookup objects in the JNDI tree, I realized that I can freely look up injected resources (I use the resource-ref in ejb-jar.xml for ex for data sources), but non injected are failing - is this normal ? Specifically, one of my ejb is doing InitialContext ic = new InitialContext(); // Properly initialized with the OpenEJB ICfactory ic.lookup(openejb/TransactionManager); and this always throws a NameNotFoundException. Hmm. If it was created with the LocalInitialContextFactory as so.. Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, org.apache.openejb.client.LocalInitialContextFactory); InitialContext initialContext = new InitialContext(properties); Then it should definitely work. If it was done as so... InitialContext initialContext = new InitialContext(); Then I'm not as confident that it will work. We have code in the integration to add the openejb subcontext into the webapp's jndi context, or so I thought. I added code along these lines, but it's been while and I can't recall the details. Maybe in this second case you have to lookup java:openejb/TransactionManager. Can you verify which technique you are using? -David -- View this message in context: http://www.nabble.com/JNDI-lookup-in-Tomcat-tp19883726p19898308.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB in an OSGi container
Guillaume is the one who's done most the work in this area in regards to his use of OpenEJB in the OSGi-based ServiceMix 4. What boot technique did you use in ServieMix? -David On Oct 9, 2008, at 2:08 PM, Zog wrote: Hi So, I managed to get my EJB app running just fine in Tomcat/ OpeneEJB. Now that it validates the J2EE support I need from OpenEJB, I'd like to move all this to an OSGi container. Any hints on where I should look for information ? I scanned through the web and although it's stated everywhere that OpenEJB is packaged as OSGi bundled, I couldn't find information on how to start openejb in osgi. I tried a simple approach where I load everything in openejb/lib from the system classpath, but got a mysterious exception: Caused by: org.apache.openejb.core.ivm.naming.NamingException: Cannot initailize OpenEJB: null at org.apache.openejb.core.ivm.naming.InitContextFactory.initializeOpenE JB(InitContextFactory.java:88) at org.apache.openejb.core.ivm.naming.InitContextFactory.getInitialConte xt(InitContextFactory.java:35) at org.apache.openejb.client.LocalInitialContextFactory.getIntraVmContex t(LocalInitialContextFactory.java:114) That's most probably related to the way OSGi does classloading, and I'm investigating. Should I look at the way you embedded OpenEJB for Tomcat ? Or should I look elsewhere ? Any clue welcomed :) /Zog PS: Btw, finding http://openejb.apache.org/apidocs is not very easy on the openejb site - I had to scan through the forums to find that one. -- View this message in context: http://www.nabble.com/OpenEJB-in-an-OSGi-container-tp19905326p19905326.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB in an OSGi container
It's been a long time since I work on that and I still have not found the time to continue this integration work. Anyway, the code I used is available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3 It uses a spring-powered bundle to set up OpenEJB: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/resources/META-INF/spring/openejb-spring.xml and the related java classes are available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/java/org/apache/servicemix/ejb3/deployer/ Unfortunately, this may be a bit outdated :-( Anyway, the idea was to be able to listen to newly installed bundles and discover EJB inside those so that they are automatically configured as plain EJB or web services. Though, this was in the context of ServiceMix, where the EJBs were to be exposed on the JBI bus and eventually through HTTP/SOAP too. On Thu, Oct 9, 2008 at 9:26 PM, David Blevins [EMAIL PROTECTED] wrote: Guillaume is the one who's done most the work in this area in regards to his use of OpenEJB in the OSGi-based ServiceMix 4. What boot technique did you use in ServieMix? -David On Oct 9, 2008, at 2:08 PM, Zog wrote: Hi So, I managed to get my EJB app running just fine in Tomcat/OpeneEJB. Now that it validates the J2EE support I need from OpenEJB, I'd like to move all this to an OSGi container. Any hints on where I should look for information ? I scanned through the web and although it's stated everywhere that OpenEJB is packaged as OSGi bundled, I couldn't find information on how to start openejb in osgi. I tried a simple approach where I load everything in openejb/lib from the system classpath, but got a mysterious exception: Caused by: org.apache.openejb.core.ivm.naming.NamingException: Cannot initailize OpenEJB: null at org.apache.openejb.core.ivm.naming.InitContextFactory.initializeOpenE JB(InitContextFactory.java:88) at org.apache.openejb.core.ivm.naming.InitContextFactory.getInitialConte xt(InitContextFactory.java:35) at org.apache.openejb.client.LocalInitialContextFactory.getIntraVmContex t(LocalInitialContextFactory.java:114) That's most probably related to the way OSGi does classloading, and I'm investigating. Should I look at the way you embedded OpenEJB for Tomcat ? Or should I look elsewhere ? Any clue welcomed :) /Zog PS: Btw, finding http://openejb.apache.org/apidocs is not very easy on the openejb site - I had to scan through the forums to find that one. -- View this message in context: http://www.nabble.com/OpenEJB-in-an-OSGi-container-tp19905326p19905326.html Sent from the OpenEJB User mailing list archive at Nabble.com. -- Cheers, Guillaume Nodet Blog: http://gnodet.blogspot.com/ Open Source SOA http://open.iona.com
Re: OpenEJB in an OSGi container
Thanks, Guillaume. That gives me a pretty good idea on what the pieces are. Zog, let me know what OSGi kernel and version you're using and I'll see if I can't whip up some boot code for you. If you've got any starter code you can share, feel free to zip it up and attach it do a JIRA (created a jira for you here https://issues.apache.org/jira/browse/OPENEJB-921) -David On Oct 9, 2008, at 2:47 PM, Guillaume Nodet wrote: It's been a long time since I work on that and I still have not found the time to continue this integration work. Anyway, the code I used is available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ ejb3 It uses a spring-powered bundle to set up OpenEJB: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/resources/META-INF/spring/openejb-spring.xml and the related java classes are available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/java/org/apache/servicemix/ejb3/deployer/ Unfortunately, this may be a bit outdated :-( Anyway, the idea was to be able to listen to newly installed bundles and discover EJB inside those so that they are automatically configured as plain EJB or web services. Though, this was in the context of ServiceMix, where the EJBs were to be exposed on the JBI bus and eventually through HTTP/SOAP too. On Thu, Oct 9, 2008 at 9:26 PM, David Blevins [EMAIL PROTECTED] wrote: Guillaume is the one who's done most the work in this area in regards to his use of OpenEJB in the OSGi-based ServiceMix 4. What boot technique did you use in ServieMix? -David On Oct 9, 2008, at 2:08 PM, Zog wrote: Hi So, I managed to get my EJB app running just fine in Tomcat/ OpeneEJB. Now that it validates the J2EE support I need from OpenEJB, I'd like to move all this to an OSGi container. Any hints on where I should look for information ? I scanned through the web and although it's stated everywhere that OpenEJB is packaged as OSGi bundled, I couldn't find information on how to start openejb in osgi. I tried a simple approach where I load everything in openejb/lib from the system classpath, but got a mysterious exception: Caused by: org.apache.openejb.core.ivm.naming.NamingException: Cannot initailize OpenEJB: null at org .apache.openejb.core.ivm.naming.InitContextFactory.initializeOpenE JB(InitContextFactory.java:88) at org .apache.openejb.core.ivm.naming.InitContextFactory.getInitialConte xt(InitContextFactory.java:35) at org .apache.openejb.client.LocalInitialContextFactory.getIntraVmContex t(LocalInitialContextFactory.java:114) That's most probably related to the way OSGi does classloading, and I'm investigating. Should I look at the way you embedded OpenEJB for Tomcat ? Or should I look elsewhere ? Any clue welcomed :) /Zog PS: Btw, finding http://openejb.apache.org/apidocs is not very easy on the openejb site - I had to scan through the forums to find that one. -- View this message in context: http://www.nabble.com/OpenEJB-in-an-OSGi-container-tp19905326p19905326.html Sent from the OpenEJB User mailing list archive at Nabble.com. -- Cheers, Guillaume Nodet Blog: http://gnodet.blogspot.com/ Open Source SOA http://open.iona.com
Re: OpenEJB in an OSGi container
I'm using apache Felix 1.2.1 with OSGi 1.4. I've no code to share yet - I started on this just recently and am still in information gathering mode :) but for sure I'll share this once I get it to work. Thanks a lot for the help /Zog David Blevins wrote: Thanks, Guillaume. That gives me a pretty good idea on what the pieces are. Zog, let me know what OSGi kernel and version you're using and I'll see if I can't whip up some boot code for you. If you've got any starter code you can share, feel free to zip it up and attach it do a JIRA (created a jira for you here https://issues.apache.org/jira/browse/OPENEJB-921) -David On Oct 9, 2008, at 2:47 PM, Guillaume Nodet wrote: It's been a long time since I work on that and I still have not found the time to continue this integration work. Anyway, the code I used is available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ ejb3 It uses a spring-powered bundle to set up OpenEJB: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/resources/META-INF/spring/openejb-spring.xml and the related java classes are available at: http://svn.apache.org/repos/asf/servicemix/smx4/features/branches/ejb3/deployer/src/main/java/org/apache/servicemix/ejb3/deployer/ Unfortunately, this may be a bit outdated :-( Anyway, the idea was to be able to listen to newly installed bundles and discover EJB inside those so that they are automatically configured as plain EJB or web services. Though, this was in the context of ServiceMix, where the EJBs were to be exposed on the JBI bus and eventually through HTTP/SOAP too. On Thu, Oct 9, 2008 at 9:26 PM, David Blevins [EMAIL PROTECTED] wrote: Guillaume is the one who's done most the work in this area in regards to his use of OpenEJB in the OSGi-based ServiceMix 4. What boot technique did you use in ServieMix? -David On Oct 9, 2008, at 2:08 PM, Zog wrote: Hi So, I managed to get my EJB app running just fine in Tomcat/ OpeneEJB. Now that it validates the J2EE support I need from OpenEJB, I'd like to move all this to an OSGi container. Any hints on where I should look for information ? I scanned through the web and although it's stated everywhere that OpenEJB is packaged as OSGi bundled, I couldn't find information on how to start openejb in osgi. I tried a simple approach where I load everything in openejb/lib from the system classpath, but got a mysterious exception: Caused by: org.apache.openejb.core.ivm.naming.NamingException: Cannot initailize OpenEJB: null at org .apache.openejb.core.ivm.naming.InitContextFactory.initializeOpenE JB(InitContextFactory.java:88) at org .apache.openejb.core.ivm.naming.InitContextFactory.getInitialConte xt(InitContextFactory.java:35) at org .apache.openejb.client.LocalInitialContextFactory.getIntraVmContex t(LocalInitialContextFactory.java:114) That's most probably related to the way OSGi does classloading, and I'm investigating. Should I look at the way you embedded OpenEJB for Tomcat ? Or should I look elsewhere ? Any clue welcomed :) /Zog PS: Btw, finding http://openejb.apache.org/apidocs is not very easy on the openejb site - I had to scan through the forums to find that one. -- View this message in context: http://www.nabble.com/OpenEJB-in-an-OSGi-container-tp19905326p19905326.html Sent from the OpenEJB User mailing list archive at Nabble.com. -- Cheers, Guillaume Nodet Blog: http://gnodet.blogspot.com/ Open Source SOA http://open.iona.com -- View this message in context: http://www.nabble.com/OpenEJB-in-an-OSGi-container-tp19905326p19907692.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB with JUnit from NetBeans: NameNotFoundException
Good day, I am getting the same problem. And my system is able to find the META-INF/ejb-jar.xml as seen in the last part of the surefire reports ( not unless that's the wrong ejb-jar.xml that I'm supposed to look for ). I downloaded openejb-examples-3.0 ( [1] ), extracted the archive, and run `mvn clean install`, and I am getting NameNotFoundException all over the place. Are there are many steps I need to take to set this up? Thanks, Franz [1] http://www.apache.org/dyn/closer.cgi/openejb/3.0/openejb-examples-3.0.tar. Sample Surefire reports from simple-stateless: ?xml version=1.0 encoding=UTF-8 ? testsuite errors=2 skipped=0 tests=2 time=1.075 failures=0 name=org.superbiz.calculator.CalculatorTest properties property value=3.0 name=openejb.version/ property value=Java(TM) 2 Runtime Environment, Standard Edition name=java.runtime.name/ property value=/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/jre/lib/i386 name=sun.boot.library.path/ property value=1.5.0_15-b04 name=java.vm.version/ property value=Sun Microsystems Inc. name=java.vm.vendor/ property value=http://java.sun.com/; name=java.vendor.url/ property value=: name=path.separator/ property value=Java HotSpot(TM) Server VM name=java.vm.name/ property value=sun.io name=file.encoding.pkg/ property value=org.apache.openejb.core.security.JaccProvider$Factory name=javax.security.jacc.PolicyConfigurationFactory.provider/ property value=PH name=user.country/ property value=SUN_STANDARD name=sun.java.launcher/ property value=unknown name=sun.os.patch.level/ property value=Java Virtual Machine Specification name=java.vm.specification.name/ property value=/home/franz/src/openejb-examples-3.0/simple-stateless name=user.dir/ property value=1.5.0_15-b04 name=java.runtime.version/ property value=/home/franz/src/openejb-examples-3.0/simple-stateless name=derby.system.home/ property value=sun.awt.X11GraphicsEnvironment name=java.awt.graphicsenv/ property value=/home/franz/src/openejb-examples-3.0/simple-stateless name=basedir/ property value=/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/jre/lib/endorsed name=java.endorsed.dirs/ property value=i386 name=os.arch/ property value=/tmp/surefirebooter58049.jar name=surefire.real.class.path/ property value=/tmp name=java.io.tmpdir/ property value= name=line.separator/ property value=Sun Microsystems Inc. name=java.vm.specification.vendor/ property value=org.apache.openejb.core.ivm.naming name=java.naming.factory.url.pkgs/ property value=Linux name=os.name/ property value=true name=derby.storage.fileSyncTransactionLog/ property value=UTF-8 name=sun.jnu.encoding/ property value=/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/jre/lib/i386/server:/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.15/jre/../lib/i386 name=java.library.path/ property