Results 1 to 3 of 3

Thread: Two Spring webapps using shared jar

  1. #1

    Default Two Spring webapps using shared jar

    Hello,

    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:

    Code:
    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)
    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):

    Code:
    public class MySpringContextListener extends org.spring....ContextLoaderListener {
    
    	@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 still the exception remains

    Can you help me, please?

  2. #2

    Default

    No ClassLoader experts around here

  3. #3

    Default

    Still have this problem.

    May be the picture attached makes it clearer to understand the trouble I am in.

    While the first webapp injects valid service classes into the shared ServiceFactory, the second webapp obtains those services (at least tries to). I get the described exception.

    The services are all transactionized via:

    Code:
    	<!-- transaction manager -->
    	<bean id="transactionManager"
    		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory">
    			<ref local="sessionFactory"/>
    		</property>
    	</bean>
    
        <bean id="domainServiceTransactionAttributeSource" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
            <property name="properties">
                <props>
                    <prop key="create*">PROPAGATION_REQUIRES_NEW</prop>
    
                    <prop key="delete*">PROPAGATION_REQUIRES_NEW</prop>
    
                    <prop key="edit*">PROPAGATION_REQUIRES_NEW</prop>
    
                    <prop key="find*">PROPAGATION_REQUIRES_NEW,readOnly</prop>
                </props>
            </property>
        </bean>
    
        <bean id="languageService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="proxyInterfaces">
                <list>
                    <value>org.mycomp.shared.ICRUDService</value>
                </list>
            </property>
    
            <property name="target" ref="languageServiceTarget" />
    
            <property name="transactionManager" ref="transactionManager" />
    
            <property name="transactionAttributeSource" ref="domainServiceTransactionAttributeSource" />
        </bean>
    
        <bean id="languageServiceTarget" class="org.mycomp.notshared.service.LanguageServiceImpl">
        </bean>
    I'd appreciate any help ...
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •