Re: JUnit question
On Nov 19, 2008, at 6:32 AM, ericp56 wrote: I wasn't paying attention to the package, only the class name. Thanks for the clarification:) No worries. I've often thought it would be neat to add some functionality that would catch ClassNotFoundExceptions and print the name of the jar that should be added to the classpath. Wouldn't be too hard as all we'd have to do is create a maven plugin (or any plain java code we can run via the maven-ant-plugin at build time) that squirted the indexes of each jar we depend on into a file that we include in the openejb-core jar. Then it'd simply be a quick read through that file to find the jar name to add to the error message. Would be a cool contribution if you felt like giving it a whirl :) -David
Re: EntityManager Propagation Problem under 3.1
On Nov 18, 2008, at 4:29 PM, JimOR wrote: Apologies in advance for cross-posting, but my post to OpenJPA ( http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html ) hasn't gotten any hits. To repeat from that post, I have: A) Parent entity with LAZY OneToMany List, cascade: PERSIST,MERGE,REFRESH B) Child entity with EAGER ManyToOne Parent, cascade: PERSIST,MERGE,REFRESH C)Abstract CRUD class with injected Extended PersistenceContext, and requisite CRUD methods D) Parent Stateful bean that extends CRUD E) Child Stateful bean that extends CRUD Classes are enhanced in place via ant prior to junit test run. Under OpenEJB3.0 (OpenJPA 1.0.1), Any/All managed entities show as managed by either bean, but under OpenEJB 3.1 (with deployed OpenJPA 1.1.0 AND 'latest binary' 1.2.0), only the bean responsible for the load/ persist/merge of an entity shows the entity as managed. The following snippet works fine under 3.0, but throws an exception under 3.1: Parent p = parentBean.insert(new Parent("Foo")); Child c = childBean.insert(new Child("Bar", p)); WARN org .apache .geronimo.transaction.manager.TransactionImpl.beforeCompletion(Ln 516) - Unexpected exception from beforeCompletion; transaction will roll back org.apache.openjpa.persistence.ArgumentException: The given instance "entity.Parent-6264" is not managed by this context. FailedObject: entity.Parent-6264 Hi Jim, I'm not sure what would cause this issue. We should try isolating things so we can figure out where to look. First thing would be either: a. swap out the OpenJPA version in your OpenEJB 3.1 install with OpenJPA 1.0.1, or b. take your working OpenEJB 3.0 install and upgrade your OpenJPA version from OpenJPA 1.0.1 to OpenJPA 1.1.0 or OpenJPA 1.2.0 I'd go with b. If that recreates the issue than you can rule out OpenEJB and update your post on the OpenJPA list saying you know it isn't an OpenEJB issue. If it doesn't recreate the issue than we know it's something on our end and we can dig deeper. -David
Re: Error connecting OpenEJB3.0 client to OpenEJB 3.1 server.
Hi Paul, The client and server versions have to match. We did a major overhaul of the client/server communication between 3.0 and 3.1. The remote client/server performance of 3.1 is many times faster than 3.0 and I'd definitely recommend switching all clients over. We *try* to keep the client/server protocol and connection management stable between versions, but to get the improvements in we had to break some eggs. -David On Nov 18, 2008, at 5:35 AM, Paul Spencer wrote: I am getting the following exception when connecting a OpenEJB 3.0 remote client to an OpenEJB 3.1 standalone server. The exception is thrown when the client is getting the IntialContext. *** * Code that does gets the initial context * Note: This was copied from OpenEJB's remote client example *** Properties p = new Properties(); p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory"); p.put("java.naming.provider.url", "ejbd://localhost:4201"); p.put("java.naming.security.principal", ""); p.put("java.naming.security.credentials", ""); InitialContext ctx = new InitialContext(p); *** * Exception on OpenEJB 3.0 remote Client end *** javax.naming.AuthenticationException: Cannot open object output stream to server: ; nested exception is: java.net.SocketException: Broken pipe at org.apache.openejb.client.JNDIContext.authenticate(JNDIContext.java: 176) at org .apache .openejb.client.JNDIContext.getInitialContext(JNDIContext.java:129) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java: 667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.(InitialContext.java:197) *** * Exception on OpenEJB 3.1 Server End *** java.io.IOException: Unexpected byte 79 at org.apache.openejb.server.ejbd.KeepAliveServer $Session.service(KeepAliveServer.java:221) at org .apache .openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233) at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java: 66) at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91) at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120) at java.util.concurrent.ThreadPoolExecutor $Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor $Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:613) When I change openejb-client version from 3.0 to 3.1, the client successfully get the initial context and connects to the server. Is this a bug in 3.1, 3.0, or both? Paul Spencer
OpenEJB issue with Oracle Driver
Hello, I'm using Eclipse and OpenEjb3.1, testing my OpenJPA application. I am connecting to an Oracle database using the JdbcUrl When I use code: p = System.getProperties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory"); p.put("SchedulerDB.JdbcDriver", "oracle.jdbc.OracleDriver"); p.put("SchedulerDB.JdbcUrl", "jdbc:oracle:thin:user1/[EMAIL PROTECTED]:1522:ListenerID"); I am getting the error message invalid logon. If I put this same info in openejb.xml, it works fine. Hmmm, the funny thing is I didn't change the resource id from the demo, and it still connected to the DB OK. JdbcDriver = oracle.jdbc.OracleDriver JdbcUrl = jdbc:oracle:thin:user1/[EMAIL PROTECTED]:1522:ListenerID ScrapEjbTest com.twcable.ivr.test.ScrapEjbTest test1(com.twcable.ivr.test.ScrapEjbTest) javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is: org.apache.openjpa.persistence.PersistenceException: Cannot create PoolableConnectionFactory (ORA-01017: invalid username/password; logon denied ) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:363) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:291) at $Proxy42.Echo(Unknown Source) at com.twcable.ivr.test.ScrapEjbTest.test1(ScrapEjbTest.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.apache.openjpa.persistence.PersistenceException: Cannot create PoolableConnectionFactory (ORA-01017: invalid username/password; logon denied ) at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:101) at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:554) at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1250) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505) at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430) at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103) at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68) at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:843) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:834) at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638) at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183) at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntit
Re: UserTransaction injection
2008/11/18 David Blevins <[EMAIL PROTECTED]>: > On Nov 11, 2008, at 6:57 PM, Carlos MacLeod wrote: >> >> 2008-11-12 00:40:55,155 - ERROR - Error merging OpenEJB JNDI entries >> in to war /Bunda: Exception: null >> java.lang.NullPointerException >> at java.util.Hashtable.put(Hashtable.java:394) >> at >> org.apache.catalina.deploy.NamingResources.addResourceEnvRef(NamingResources.java:320) >> at >> org.apache.openejb.tomcat.catalina.TomcatJndiBuilder.mergeRef(TomcatJndiBuilder.java:416) >> at >> org.apache.openejb.tomcat.catalina.TomcatJndiBuilder.mergeJndi(TomcatJndiBuilder.java:140) >> at >> org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:270) >> at >> org.apache.openejb.tomcat.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58) > > This seems to be the heart of the issue. Unfortunately looking at the code > here what might be going on is not obvious. Is it possible you could create > a small app that reproduces the problem so we can try it on our end? > > I've created a JIRA here for it: > https://issues.apache.org/jira/browse/OPENEJB-960 > > -David > > Hi David, I created a simple JSF managed bean and a JSP page, it is the simplest example: 1- Managed bean code: @Stateless @TransactionManagement(TransactionManagementType.EJB) public class MyStatelessBean implements MyStatelessBeanInterface { private String title = "Teste"; @Resource private UserTransaction utx = null; @Override public String getTitle() { return title; } @Override public void setTitle(String title) { this.title = title; } } 2- JSP page <[EMAIL PROTECTED] contentType="text/html"%> <[EMAIL PROTECTED] pageEncoding="UTF-8"%> <[EMAIL PROTECTED] prefix="f" uri="http://java.sun.com/jsf/core"%> <[EMAIL PROTECTED] prefix="h" uri="http://java.sun.com/jsf/html"%> http://www.w3.org/TR/html4/loose.dtd";> <%-- This file is an entry point for JavaServer Faces application. --%> JSP Page 3- Faces config 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/web-facesconfig_1_2.xsd";> MyStatelessBean test.MyStatelessBean session -- Best regards, Carlos MacLeod "Java is like violence: if it doesn's solve your problem, you aren't using enough of it"
OpenEJB security in Tomcat
Hi, I have a successfull installation of openejb-3.1 under Tomcat 5.5. I deleted the context.xml file, so I can access the http://servername:8080/openejb URL from a remote computer as well. But anybody can access to this URL now. Can I set logon ID/password somehow for this URL by using tomcat-users.xml file? Thanks, Andras
Problem with exceptions thrown by stateful session beans ?
Hi, I have a project with EJB3 Seam components. I write unit tests that will run on OpenEJB, but I encounter a problem I can't find it is a Seam or OpenEJB one. I wrote a Seam component with CONVERSATION scope, i.e. a stateful session bean. I wrote the following unit test for this component : public void testSaveAndDeleteOrganizationType() throws java.lang.Exception { new ComponentTest() { public void testComponents() throws java.lang.Exception { OrganizationInternalServiceLocal service = (OrganizationInternalServiceLocal) getInstance("organizationInternalService"); // Create a new organization type OrganizationType newOrganizationType = new OrganizationType(); newOrganizationType.setCode("ORG_TYPE_TEST"); newOrganizationType.setName("Test organization type"); newOrganizationType = service.saveOrganizationType(newOrganizationType); assert newOrganizationType.getId() != null; // Create a duplicated organization type try { OrganizationType duplicatedOrganizationType = new OrganizationType(); duplicatedOrganizationType.setCode("ORG_TYPE_TEST"); duplicatedOrganizationType.setName("Test organization type"); duplicatedOrganizationType = service.saveOrganizationType(duplicatedOrganizationType); assert false; } catch (Exception exception){ assert true; } // Delete an organization type service.deleteOrganizationType(newOrganizationType); assert service.loadOrganizationType("ORG_TYPE_TEST") == null; } }.run(); } I have a unique constraint on code property of organization type. So when I try to save an organization type with a code that is already in database, the saveOrganizationType is expected to throw an exception. Actually it does, no problem about that. But further calls to the component, for example deleteOrganizationType method, fail with the following stack trace : testSaveAndDeleteOrganizationType(t4.core.commons.organization.internal.test.OrganizationInternalServiceTest) Time elapsed: 0.156 sec <<< FAILURE! javax.ejb.NoSuchEJBException: reference is invalid at org.apache.openejb.core.ivm.BaseEjbProxyHandler.isValidReference(BaseEjbProxyHandler.java:319) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:232) at $Proxy135.deleteOrganizationType(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54) at org.javassist.tmp.java.lang.Object_$$_javassist_27.deleteOrganizationType(Object_$$_javassist_27.java) at t4.core.commons.organization.internal.test.OrganizationInternalServiceTest$26.testComponents(OrganizationInternalServiceTest.java:1276) at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:163) at t4.core.commons.organization.internal.test.OrganizationInternalServiceTest.testSaveAndDeleteOrganizationType(OrganizationInternalServiceTest.java:1246) If I set the component to STATELESS scope, i.e. staless session bean, my unit test works OK ! So what I note is that throwing an exception from a stateful session bean turns it to invalid. Do you think this is a problem with OpenEJB or with Seam ? Thanks in advance, Olivier
Re: JUnit question
I wasn't paying attention to the package, only the class name. Thanks for the clarification:) -- View this message in context: http://www.nabble.com/JUnit-question-tp20306283p20580964.html Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: How to use annotation in client application?
Manu, Is their a "client container"? Or stated another way; how can OpenEJB be configured to be a container for the client application, but services like bean declaration and authentication services be done by a remote container? Paul Spencer Manu George wrote: Hi Paul, If it is a standalone client application with its own main method, it runs outside the container.So you cannot get beans injected and you will need to always look them up via remote JNDI lookup Regards Manu On Tue, Nov 18, 2008 at 7:14 PM, Paul Spencer <[EMAIL PROTECTED]> wrote: I have a EJB3 client application that is not getting the the bean via annotation. Getting the bean via the initial context works. *** * Annotation to get the customerBean *** @EJB (name="CustomerBeanRemote) private CustomerBean customerBean 1) How do I use annotations, like @EJB, in an EJB3 client? 2) Is their Maven configuration other then a dependency on openejb-client that is necessary? Paul Spencer