David Blevins pisze:
On Aug 17, 2007, at 3:51 AM, Tomasz Mazan wrote:
..if there's no global jndi context and I can't get SBean within my
standalone java application client?
In addition - there's no chance to run old EJB2 application with remote
client on Geronimo 2.0. May I'm wrong - so, please help me to understand
this "feature".
EJB 1.1, EJB 2.x and EJB 3.0 standalone clients do work.
To connect to the server using the default settings:
Properties props = new Properties();
props.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", "foo://127.0.0.1:" +
port);
InitialContext context = new InitialContext(props);
The JNDI Names for each bean are printed in INFO in the
OpenEJB.startup log cagetory, which you can enable by adding this:
log4j.logger.OpenEJB.startup=INFO
..to your var/log/server-log4j.properties file
The output should look similar to the following:
INFO - Assembling app:
/Users/dblevins/work/openejb3/itests/openejb-itests-beans/target/classes
INFO - Jndi(name=client/tests/entity/cmp/BasicCmpHome)
INFO - Jndi(name=client/tests/entity/cmp/ComplexCmpHome)
INFO - Jndi(name=client/tests/entity/cmp/UnknownCmpHome)
INFO - Jndi(name=client/tests/entity/cmp2/BasicCmpHome)
INFO - Jndi(name=client/tests/entity/cmp2/ComplexCmpHome)
INFO - Jndi(name=client/tests/entity/cmp2/UnknownCmpHome)
INFO - Jndi(name=client/tests/entity/cmp/allowed_operations/EntityHome)
INFO - Jndi(name=client/tests/entity/cmp2/allowed_operations/EntityHome)
INFO - Jndi(name=client/tests/entity/cmp/EncBean)
INFO - Jndi(name=client/tests/entity/cmp2/EncBean)
INFO - Jndi(name=client/tests/entity/cmp/ContextLookupCmpBean)
INFO - Jndi(name=client/tests/entity/cmp/RMI-over-IIOP/EJBHome)
INFO - Jndi(name=client/tests/entity/cmp2/RMI-over-IIOP/EJBHome)
INFO - Jndi(name=client/tests/entity/cmr/oneToOne/PersonLocal)
INFO - Jndi(name=client/tests/entity/cmr/oneToOne/LicenseLocal)
INFO - Jndi(name=client/tests/entity/cmr/oneToMany/ArtistLocal)
INFO - Jndi(name=client/tests/entity/cmr/oneToMany/SongLocal)
INFO - Jndi(name=client/tests/entity/cmr/manyToMany/GameLocal)
There is an open issue (GERONIMO-2884) regarding the default jndi
names you may want to check out if you names like
"geronimo-deploymentUtil5840.tmpdir/FooBeanBusinessRemote.
Changing the format of the JNDI names is fine. The only drawback is
offical javaee 5 application-client.xml style clients will no longer
be able to look up ejbs (well, not using the java:comp/env snytax
anyway, they could still look them up as standalone applications do).
See the info on this page on how to reset the openejb.jndiname.format
system variable:
http://openejb.apache.org/jndi-names.html
The default value is "{deploymentId}/{interfaceClass}"
Hmmm... Looking at the code right now I see that its actually a bit
tricky to set the "openejb.jndiname.format" property -- normally
setting it as a system property would do the trick, but I see we're
not checking to see if it was set before stuffing in the default.
If you want to change the format, let me know and I will show you a
couple options.
-David
David, thank you for your response, and.... please help :-)
I've configured connection to context with theese settings
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL,
"ejbd://localhost:4201");
this.ctx = new InitialContext(properties);
and try to get remote SB with method
this.ctx.lookup("EJBtest-1.0.jar/CustomerFacade");
and get instance of.... org.apache.openejb.client.JNDIContext.. where is
my session bean?!
There is CustomerFacade in JNDIViewer tree - Geronimo Console, but....
1) when I deploy my application the console prints warn like:
10:45:38,906 WARN [Runtime] The property named
"openjpa.ClassTransformerOptions" was not recognized and will be
ignored, although the name
closely matches a valid property called "openjpa.ClassResolver".
2) Although I set key log4j.logger.OpenEJB.startup to value INFO,
there's no jndi messages on console
3) May it be independent troublem, but I use persistence unit, with
properly configured (on server) connectio pool, and when I explore
(click) via jndi viewer, geronimo console prints error like
javax.naming.NotContextException:
geronimo/env/pl.netia.fonbsa.core.dao.facade.impl.CommonFacadeImpl/entityManager
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:161)
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:611)
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:152)
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:597)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at
org.apache.openejb.core.ivm.naming.JndiUrlReference.getObject(JndiUrlReference.java:34)
This problem is common for my application and geronimo examples from
official site.
Please, help me to understand this strange behaviour.
Tomasz Mazan
PS. Let's changing jndi name format to near future.