On Tue, Feb 22, 2005 at 05:18:53PM -0700, 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?
The idea is that when having one OpenEJB per-webapp you end up with this: WEB-INF/lib WEB-INF/classes WEB-INF/beans Where the beans directory holds the EJBs for your web app. So you can pack your ejbs in your war file like other libraries. Really nice for people doing virtual hosting or housing multiple apps for multiple people. OpenEJB and your EJBs are loaded in your webapp's classloader and all the config files are relative to your webapp. Everyone gets their own setup and one bothers anyone else. If you threw in something like Derby as an embedded database, you should be able to have your own mini-J2EE setup anywhere that offered Tomcat hosting. So to compare the two ways to use OpenEJB in Tomcat: SYSTEM = OpenEJB is loaded into Tomcat's common classloader. All webapps share the same EJB instances and have access to all the EJBs deployed in the system. There is one openejb.conf for the whole server. Webapps must not pack the EJB classes in their archive. EJBs cannot see the classes in your WEB-INF/lib and WEB-INF/classes directory, shared libraries must be put in Tomcat's common or system classloaders to be used by EJBS. WEBAPP = OpenEJB is loaded into the webapp classloader. Each webapp has it's own openejb.conf, EJBs, and EJB container. No other webapp can affect another's EJBs or EJB container. Webapps must pack the EJB jars in their archive. EJB's can access the libraries in your WEB-INF/classes and WEB-INF/lib directories. A very nice aspect of the one OpenEJB per-webapp is that the EJB's become part of your webapp, so when your webapp is deployed/undeployed/redeployed, so are your EJBs. No hocus-pocus required stemming from managing ejbs and servlets seperately. Our existing docs refer the original way to load OpenEJB into Tomcat, which is to load it into the Common classloader making it and the EJB's globably available to all webapps. So we really need help in updating the docs to clearly label and explain the two approaches and how to configure each. I would really hate for someone to be intending to setup the webapp style, but get lost in the system-wide instructions. Anyone is welcome to take the above text and incorporate it into their own docs or submit it back to us in our xml format for inclusion in the website. On that note, anyone is welcome to make dramatic changes to the organization of our website and submit that back to us. We put up what time allows, but with OpenEJB 0.9.X, 1.0, and the forthcoming 2.0, a re-org couldn't hurt. -David > > 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 > > > > > > > > -- > > > > Lajos Moczar > ---------------------------------------- > Open Source Support, Consulting and Training > ---------------------------------------- > "The Open Source Monopoly" > www.galatea.com/opensource.html > > Tomcat Unleashed > (www.amazon.com/exec/obidos/tg/detail/-/0672326361) > > Cocoon Developer's Handbook > (www.amazon.com/exec/obidos/tg/detail/-/0672322579) > > _ _____ > / \ / > /___\ / > / \ /____ > > http://www.galatea.com -- powered by AzSSL
