Very nice guide Lajos! I skimmed over it and haven't had a chance to really do the steps just yet. Maybe tss would post the article?

~mark

Lajos wrote:


Ok, I figured out the problem. In using OpenEJB in the per-webapp scenario, you MUST define the openejb.base init-param. That's cause org.openejb.loader.LoaderServlet will set openejb.base to the web application WEB-INF directory IF the openejb.loader is "tomcat-webapps" and openejb.base is not defined. Is this the intended behavior?


My FlashGuide, http://www.galatea.com/flashguides/tomcat-openejb1-unix now also covers the "per-webapp" scenario. Enjoy.

Regards,

Lajos



Lajos wrote:




David Blevins wrote:


Great. OpenEJB now supports the whole one-OpenEJB-per-webapp thing, which I think people will really like. If you wanted to write a FlashGuide for that, I'd be very happy to link to it from openejb.org.



I have found some curious errors in testing this. What I did was to copy the openejb-loader*.jar to my web application WEB-INF/lib directory. I edited WEB-INF/web.xml per the instructions:


<servlet>
<servlet-name>loader</servlet-name>
<servlet-class>org.openejb.loader.LoaderServlet</servlet-class>
<init-param>
<param-name>openejb.loader</param-name>
<param-value>tomcat-webapp</param-value>
</init-param>
<init-param>
<param-name>openejb.home</param-name>
<param-value>/usr/local/share/openejb1</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

In Tomcat 4 and 5, this generated a ClassNotFoundException for org.openejb.OpenEJB, from:

java.lang.NoClassDefFoundError: org/openejb/OpenEJB
at org.openejb.loader.EmbeddedLoader.load(EmbeddedLoader.java:59)
at org.openejb.loader.EmbeddingLoader.load(EmbeddingLoader.java:82)
at org.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:68)




It seems like the classpath thingy isn't working right?

Another problem is that, if you leave out the "openejb.loader" init-param, embedded OpenEJB loads just fine. However, you can't access any beans from that web application! For example, if I have this in my WEB-INF/web.xml:

<servlet>
<servlet-name>loader</servlet-name>
<servlet-class>org.openejb.loader.LoaderServlet</servlet-class>
<init-param>
<param-name>openejb.home</param-name>
<param-value>/usr/local/share/openejb1</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

I get the lovely ClassCastException at PortableRemoteObject.narrow. Is that the expected behavior?

For the record, I'm getting the bean reference thusly:

Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.openejb.client.LocalInitialContextFactory");
javax.naming.InitialContext ctx = new javax.naming.InitialContext(p);
Object obj = ctx.lookup("/SimpleTest");



The webadmin app doesn't seem to work, but I'll have to keep investigating.

The only other problem I found were some project.xml errors, noted in my FlashGuide (wrong j2ee version & jta dependency missing). Don't know if you want me to make the changes or whether someone else can.




Hammer away.



It appears I don't have any CVS permissions. Is there another way?

Regards,

Lajos







Reply via email to