Re: 2 webapps using shared jar (ClassLoader problem)

2007-06-29 Thread Kevin Wilhelm

Nobody any idea on this? :(


- Original Message - 
From: Kevin Wilhelm [EMAIL PROTECTED]

To: users@tomcat.apache.org
Sent: Thursday, June 28, 2007 2:34 PM
Subject: 2 webapps using shared jar (ClassLoader problem)


I deployed a shared jar file on Tomcat that is to be used by two Spring 
webapps. The problem is the Exception I receive when trying to access the 
shared library by the second webapp. The first one already set some 
properties within the shared class instances.


The Exception:

java.lang.IllegalArgumentException: interface 
org.hibernate.jdbc.ConnectionWrapper is not visible from class loader

  java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
  java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)

org.hibernate.jdbc.BorrowedConnectionProxy.generateProxy(BorrowedConnectionProxy.java:67)

org.hibernate.jdbc.ConnectionManager.borrowConnection(ConnectionManager.java:163)
  org.hibernate.jdbc.JDBCContext.borrowConnection(JDBCContext.java:111)
  org.hibernate.impl.SessionImpl.connection(SessionImpl.java:359)

org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:456)

org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:349)

org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:259)

org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)

org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)

org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:203)
  $Proxy2.create(Unknown Source)
  test.TestController.handleRequest(TestController.java:39)

org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:774)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:460)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:415)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

The interface from Hibernate is in the hibernate3.jar file of the first 
webapp.


I tried to do something that seemed to be a workaround. Something to do 
with the ClassLoaders not being able to see each others classes?! I 
extended Spring's ContextListeners and replaced the original ones for 
startup (for both webapps):


public class MySpringContextListener extends 
org.springContextLoaderListener {


@Override
public void contextInitialized(ServletContextEvent evt) {
ClassLoader contextLoader = 
Thread.currentThread().getContextClassLoader();

Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
super.contextInitialized(evt);
Thread.currentThread().setContextClassLoader(contextLoader);
}

@Override
public void contextDestroyed(ServletContextEvent evt) {

ClassLoader contextLoader = 
Thread.currentThread().getContextClassLoader();

Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
super.contextDestroyed(evt);
evt.getServletContext().removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
Thread.currentThread().setContextClassLoader(contextLoader);
}
}

But the exception remains

Can you help me, please?

--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] 



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: 2 webapps using shared jar (ClassLoader problem)

2007-06-29 Thread Caldarale, Charles R
 From: Kevin Wilhelm [mailto:[EMAIL PROTECTED] 
 Subject: Re: 2 webapps using shared jar (ClassLoader problem)
 
 Nobody any idea on this? :(

You already figured out the problem:  classes from different webapps
cannot access each other - no ifs, ands, or buts.  Anything that is to
be accessed from more than one webapp must be put in a common location.
See:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
or
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

(You didn't bother to tell us the version of Tomcat that you're using.)

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]