You are not able to get DataSource from remote clients. 2009/12/14 Toni Bennasar <[email protected]>
> Hello. First of all, excuse my poor english, and thanks for your good > work. > > I have a standalone client application working fine with OpenEJB 3.1.2. > OpenEjb is running standalone (not embedded), and the client is running > on other Java VM. It works getting EJBs from their remote interfaces, it > works running JPA things, but i have troubles retrieving a Datasource > from its JNDI name. > > The openejb.xml datasource are: > > <Resource id="fachibernate" type="DataSource"> > > JdbcDriver com.mysql.jdbc.Driver > JdbcUrl jdbc:mysql://localhost/fachibernate > UserName foo > Password bar > JtaManaged true > </Resource> > > <Resource id="fachibernatenojta" type="DataSource"> > > JdbcDriver com.mysql.jdbc.Driver > JdbcUrl jdbc:mysql://localhost/fachibernate > UserName foo > Password bar > JtaManaged false > </Resource> > > The JNDI properties I use: > > > java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory > java.naming.provider.url=ejbd://localhost:4201 > > And here the evil line: > > DataSource ds = (DataSource)contexto.lookup(poolJndiName); > ...<here comes some SQL work with ds> > > I have been test this with GlassFish and it worked, but I have some > problems / questions with OpenEjb: > > 1) I read the OpenEjb documentation about datasource JNDI names, and I > have tried to put poolJndiName="fachibernate", > poolJndiName="java:openejb/Resource/fachibernate" and > poolJndiName="java:comp/env/fachibernate" and they give me a > > javax.naming.NameNotFoundException: XXX does not exist in the system. > Check that the app was successfully deployed. > at > org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:261) > ... > > that names only works on the same VM than Openejb? I'm new about J2EE, > so this probably is my fault. > > 2) I have tried poolJndiName="openejb:Resource/fachibernate" and it does > some different. It throws the exception: > > javax.naming.NamingException: Expected an ejb proxy, found unknown > object: type=org.apache.openejb.resource.jdbc.BasicManagedDataSource, > tostring=org.apache.openejb.resource.jdbc.basicmanageddatasou...@1f8a6890 > at > > org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:354) > at > > org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:129) > at > > org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:200) > at > org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:153) > at > org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:71) > at org.apache.openejb.server.ejbd.KeepAliveServer > $Session.service(KeepAliveServer.java:213) > 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:886) > at java.util.concurrent.ThreadPoolExecutor > $Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:619) > > "Expected an ejb proxy"... Is this out of the J2EE specification? Can I > only retrieve EJBs from a remote OpenEjb? I'm doing something wrong? > > (where it says "fachibernate", I have tried too "fachibernatenojta" and > it give me the same result) > > Thanks. > > > -- Gurkan Erdogdu http://gurkanerdogdu.blogspot.com
