tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Mulder <ammul...@alumni.princeton.edu>
Subject Re: servlets in tomcat - EJBs in WebLogic 5.1
Date Thu, 28 Sep 2000 13:08:08 GMT
	One thing I can point out is that you definitely want all your
WebLogic-related stuff to be in the same place.  So you can't, for
example, put base WebLogic client libraries in tomcat/lib and then your
EJB interfaces in WEB-INF/classes.  The reason, as you noted, is the
ClassLoaders.  If the WebLogic client libs are loaded from tomcat/lib,
they cannot access stuff in your web app directories since they are in the
parent ClassLoader, though the web app classes can access the tomcat/lib
classes since they are in the child ClassLoader.  I would recommend you
put everything WebLogic-related in the WEB-INF/lib and WEB-INF/classes
directories.
	Also, as Paul notes, there is an issue with thread context class
loaders.  In Java >= 1.2, you can set the context class loader, and RMI
will obey.  I have forgotten the exact problem, but I went through this
before and printed the classloaders in a number of places and there were 3
or more involved  - it got pretty ugly.  The solution to this (again, not
for 1.1) is to add an Interceptor to your Tomcat server.xml configuration
file.  This interceptor sets the context class loader for all
requests.  You should add it as the last "RequestInterceptor" in
server.xml, and the block you need to add looks like this:

    <RequestInterceptor
         className="org.apache.tomcat.request.Jdk12Interceptor"
         debug="0" />

	Last I checked, the Realms (SimpleRealm, JDBCRealm, etc.) were the
last RequestInterceptor entries, so you should add it after those.  This
is based on the Tomcat 3.2b series - if you're using an older or newer
Tomcat I'm not sure where or whether this convenience is implemented
(though I believe it is done automatically in Catalina).

Aaron

On Wed, 27 Sep 2000, Paul Speed wrote:
> Hello,
> 
> 	I'm not going to be of much help... I know why it happens
> but I don't know how to fix it yet.  We have the exact same problem
> and I would be glad to hear if you find a solution.  Since it works
> with things being in CLASSPATH it got pushed to the back burner.
> 
> 	One thing you might try is removing the EJB classes, like the
> home interface, from the jar file that you put in WEB-INF/lib.  This
> _should_ cause the classes to be loaded over the connection to 
> Weblogic and should eliminate your class casting problems... but I have
> not tried it and it is a much less than ideal solution.
> 
> 	What happens is that the classloader that's used when 
> marshalling objects from Weblogic to Tomcat is a sibling to the 
> classloader that your servlets/jsps use.  So class Foo loaded in one
> is not cast-compatable with class Foo loaded in the other.  Since 
> classloaders generally defer loading to their parent classloader,
> then when you put class Foo in your system classpath then the class
> is only loaded once.
> 
> 	The solution is to somehow get Weblogic's classloader to use
> the servlet/jsp classloader as its parent.  The other day someone
> suggested setting the Thread's classloader context.  I'm not sure if
> this will work with Weblogic... but it sounds like the right idea.
> 
> 	Good luck and let me know if you get it working!
> 	-Paul
> 
> matthew denner wrote:
> > 
> > Dear all,
> > 
> > i wanted to drop everyone a mail to point out a problem that i've had with
> > tomcat and weblogic 5.1 interacting just to see if anyone has experienced a
> > similar problem and whether there is a better solution.
> > 
> > i have some session EJBs deployed in weblogic 5.1; a servlet running under
> > tomcat creates one these EJBs and then uses it (i know the architecture isn't
> > great but i'm attempting to migrate slowly).  the problem is that i get a
> > ClassCastException thrown when i try to narrow the EJB Home interface
> > retrieved from the initial context.
> > 
> > the problem can be solved by NOT putting the EJB jar file in the WEB-INF/lib
> > directory for the servlet, but rather to add it to the CLASSPATH used by
> > tomcat on startup.  i'm assuming this has something to do with difference
> > between the class loading mechanisms for tomcat and the servlets.  i do not
> > want this nasty solution to be the only one; anyone recommend a better one?
> > 
> > to the developers of tomcat, is this a bug, feature, or something that has
> > been overlooked?  can it be fixed?
> > 
> > Cheers,
> > Matt
> > 
> > -----------------------------------------------------------------------------
> > Sessami is a trademark of Escape Velocity Technology Mobile Services Limited.
> > All information contained in this e-mail is confidential and for the use of
> > the addressee only.  If you receive this message in error please notify.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 


Mime
View raw message