RE: RE: [OpenEJB-user] Context problem when connecting OpenEJB and Tomcat
Brought to you by:
dblevins,
monson-haefel
From: Clemens K. <cle...@de...> - 2003-02-27 09:22:30
|
Hi David, here are the results of my tests regarding multiple contexts after changing org.openejb.alt.assembler.classic.Assembler.java as described in https://sourceforge.net/tracker/?func=detail&atid=439275&aid=683862&group_id=44351 I did the following test: I set up 2 env_entries in my application environment in tomcat .../WEB-INF/web.xml --------------------- <web-app> ... <env-entry> <env-entry-name>foo/envvar_t</env-entry-name> <env-entry-value>ENVVAR_TF</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> <env-entry> <env-entry-name>bar/envvar_t</env-entry-name> <env-entry-value>ENVVAR_TB</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> </web-app> - - - - - - - - - - and one env-entry in the bean environment .../META-INF/ejb-jar.xml --------------------- <ejb-jar> <enterprise-beans> <session> <ejb-name>Hello</ejb-name> <home>... ... <env-entry> <env-entry-name>foo/envvar_o</env-entry-name> <env-entry-value>ENVVAR_O</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry> ... - - - - - - - - - - Here is the output of my JSP and Bean (following I say servlet, but in fact it is a JSP for convenience ;) You can test it by exchanging the 4 attached files after you have set up the HelloWorld Example together with Tomcat as described by Jacek Laskowski in http://openejb.sourceforge.net/tomcat-object-factory.html You see the statement followed by the output result in sqared brackets ----------------------------------------------- Date = Thu Feb 27 09:12:31 CET 2003 Servlet output: ------------ initCtx = new InitialContext() env = (Context) initCtx.lookup("java:comp/env") env.getClass() [class org.apache.naming.NamingContext] initCtx.lookup("java:comp/env/foo/envvar_t") : [ENVVAR_TF] initCtx.lookup("java:comp/env/bar/envvar_t") : [ENVVAR_TB] Object object = env.lookup("ejb/hello") HelloHome helloHome = (HelloHome) javax.rmi.PortableRemoteObject.narrow(object, HelloHome.class) HelloObject bean = helloHome.create() Bean output: ------------ ctx = new InitialContext() env = (Context) ctx.lookup("java:comp/env") env.getClass() [class org.openejb.core.ivm.naming.IvmContext] env_foo = (Context) ctx.lookup("java:comp/env/foo") env_foo.getClass() [class org.openejb.core.ivm.naming.IvmContext] env_bar = (Context) ctx.lookup("java:comp/env/bar") env_bar.getClass() [class org.apache.naming.NamingContext] ctx.lookup("java:comp/env/foo/envvar_o") : [ENVVAR_O] ctx.lookup("java:comp/env/foo/envvar_t") : [ENVVAR_TF] ctx.lookup("java:comp/env/bar/envvar_t") : [ENVVAR_TB] env.lookup("foo/envvar_o") : [ENVVAR_O] env.lookup("foo/envvar_t") : [ not found] env.lookup("bar/envvar_t") : [ not found] env_foo.lookup("envvar_o") : [ENVVAR_O] env_foo.lookup("envvar_t") : [ not found] env_bar.lookup("envvar_t") : [ENVVAR_TB] ------------ It looks all very well. - All Tomcat entries are found from the servlet. - The bean remote interface is found from the servlet. - As long as the ejb container finds a name in its own name space it uses it, otherwise it transfers activity to the next context in the list (is "federate" the correct word for this?) - Although it is the same URL java:comp/env/foo/... it realizes that envvar_o is in a different name space than envvar_t. I'm happy that I could help you. Greetings Clemens (See attached file: openejb.jsp)(See attached file: ejb-jar.xml)(See attached file: HelloBean.java)(See attached file: web.xml) "David Blevins" <dav...@vi...> on 26.02.2003 04:04:55 An: "'Clemens Kadura'" <clemens.kadura@DE.OPEL.COM> Kopie: <openejb-user@LISTS.SOURCEFORGE.NET> Thema: RE: [OpenEJB-user] Context problem when connecting OpenEJB and Tomcat Hi Clemens, I saw your comment on the support request. We can definitely put your patch in the next release (0.9.2), if you can test on thing.... This fixes EJB's ability to get at their JNDI namespaces, but does it cause a problem for Servlet's to get at theirs? It shouldn't as OpenEJB has functionality to check the next provider when it doesn't fing the name in it's own. Just want to make sure that other things are not affected. Thanks for the patch!! -David |