Re: 2 webapps using shared jar (ClassLoader problem)
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]
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]
Re: Design
No! This sounds like a simple webapp to me. Just use some Servlet Container (Tomcat) and have all of the presentation (JSP), business and persistence things handled in ONE engine. - Original Message - From: Mohammed Zabin [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, June 19, 2007 9:26 AM Subject: Design Hi All I am developing an online exam site as a graduation project. I have some questions regardsing the design: 1. In such a program which is a web site that introduce some multiple choice questions, and shows the result of user answers, DO I HAVE TO USE EJB?? - 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: Design
I'd take the approach with Servlets/JSP that handle user inputs. You could in deed use tags for the inputs and process them with suitable controllers in the logic tier. May be there are simpler ways to proceed with questionaires. - Original Message - From: Mohammed Zabin [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, June 19, 2007 9:42 AM Subject: Re: Design I am using a Tag that render the whole questions, can i create another tag that deals with user request? On 6/19/07, Kevin Wilhelm [EMAIL PROTECTED] wrote: No! This sounds like a simple webapp to me. Just use some Servlet Container (Tomcat) and have all of the presentation (JSP), business and persistence things handled in ONE engine. - Original Message - From: Mohammed Zabin [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, June 19, 2007 9:26 AM Subject: Design Hi All I am developing an online exam site as a graduation project. I have some questions regardsing the design: 1. In such a program which is a web site that introduce some multiple choice questions, and shows the result of user answers, DO I HAVE TO USE EJB?? - 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]
Share one singleton across webapps
I managed to get a jar file shared across two webapps in my Tomcat 6. Inside there is a class that represents a Singleton. The problem: the singleton class is instantiated by the first webapp and then again instantiated in the second webapp. So there are 2 representations of the class and it is not really shared. There has to be a way to let the first webapp instantiate the singleton and set some property so that the second webapp can use the singleton and read the property. How do I achieve this? -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser - 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: Share one singleton across webapps
It works! Thanks! The problem has been that each webapp had its own shared-lib jar-file, because I am developing in Eclipse. So Eclipse needs to know which classes I am accessing :/ At the end there were 3 times the same jar-file: 1st webapp, 2nd webapp, tomcat/lib. Removing the jars from the webapps and leaving the one in tomcat/lib solved the problem. However this is very disgusting. Every time I am deploying the 2 webapps to Tomcat, the jars are copied as well. I have to delete them manually, so that only the jar in Tomcat/lib is used. Is there some workaround for this? Should I use Ant for deploying then? But I won't be able to debug the webapps from within my IDE anymore since I am avoiding Eclipse's deployment mechanisms. Original-Nachricht Datum: Mon, 18 Jun 2007 15:40:36 +0200 Von: Johnny Kewl [EMAIL PROTECTED] An: Tomcat Users List users@tomcat.apache.org Betreff: Re: Share one singleton across webapps The typical form is like this public class SingletonObject { private SingletonObject(){} public static SingletonObject getSingletonObject() { if (ref == null) // it's ok, we can call this constructor ref = new SingletonObject(); return ref; } private static SingletonObject ref; } If thats in Tomcat/lib it should share Notice the use of static ie there is only one, no matter how many times its started. ...and the check for null which is how it determines it needs to make one instance if there is non... Thats the trick a normal class which is what I imagine you trying, will load once. but instance many times. Hope that helps... try not use them unless you really have to. - Original Message - From: Kevin Wilhelm [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Monday, June 18, 2007 3:12 PM Subject: Share one singleton across webapps I managed to get a jar file shared across two webapps in my Tomcat 6. Inside there is a class that represents a Singleton. The problem: the singleton class is instantiated by the first webapp and then again instantiated in the second webapp. So there are 2 representations of the class and it is not really shared. There has to be a way to let the first webapp instantiate the singleton and set some property so that the second webapp can use the singleton and read the property. How do I achieve this? -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser - 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] -- 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]
Re: Share one singleton across webapps
Hi, thanks for your advice. I knew the plugin page before. This should be the first-choice when searching for Eclipse add ons. Currently I am happy about having solved the problem. It's possible to include other JAVA-projects into the build path of an Eclipse-Web-Project. So far so good. Taking this approach instead of including the shared jar file concludes in setting some interesting property for the web project to be deployed: How should dependent Java projects be handled during deployment? - Ignore dependent Java projects (I will manually manage them) instead of - Jar dependent Java project output and place in 'lib' directory which was standard. So from now on the shared classes are contained within my development environment (Eclipse) and left out of the deployed version in Tomcat, which has its own unique version of the shared lib. Fantastic! By the way, what means UAT and QA jars? Original-Nachricht Datum: Mon, 18 Jun 2007 10:11:58 -0400 Von: Martin Gainty [EMAIL PROTECTED] An: Tomcat Users List users@tomcat.apache.org Betreff: Re: Share one singleton across webapps Good Morning Kevin Glad to hear that worked for you What I found is that Eclipse has it's own plugins for virtually every major system/subsystem as illustrated here http://www.eclipseplugincentral.com/Web_Links+main.html When exporting your build file to build.xml you will need to determine which jars will work in dev (as Eclipse plugin) vs UAT and QA jars Please keep us apprised of your progress M-- This email message and any files transmitted with it contain confidential information intended only for the person(s) to whom this email message is addressed. If you have received this email message in error, please notify the sender immediately by telephone or email and destroy the original message without making a copy. Thank you. - Original Message - From: Kevin Wilhelm [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, June 18, 2007 9:58 AM Subject: Re: Share one singleton across webapps It works! Thanks! The problem has been that each webapp had its own shared-lib jar-file, because I am developing in Eclipse. So Eclipse needs to know which classes I am accessing :/ At the end there were 3 times the same jar-file: 1st webapp, 2nd webapp, tomcat/lib. Removing the jars from the webapps and leaving the one in tomcat/lib solved the problem. However this is very disgusting. Every time I am deploying the 2 webapps to Tomcat, the jars are copied as well. I have to delete them manually, so that only the jar in Tomcat/lib is used. Is there some workaround for this? Should I use Ant for deploying then? But I won't be able to debug the webapps from within my IDE anymore since I am avoiding Eclipse's deployment mechanisms. Original-Nachricht Datum: Mon, 18 Jun 2007 15:40:36 +0200 Von: Johnny Kewl [EMAIL PROTECTED] An: Tomcat Users List users@tomcat.apache.org Betreff: Re: Share one singleton across webapps The typical form is like this public class SingletonObject { private SingletonObject(){} public static SingletonObject getSingletonObject() { if (ref == null) // it's ok, we can call this constructor ref = new SingletonObject(); return ref; } private static SingletonObject ref; } If thats in Tomcat/lib it should share Notice the use of static ie there is only one, no matter how many times its started. ...and the check for null which is how it determines it needs to make one instance if there is non... Thats the trick a normal class which is what I imagine you trying, will load once. but instance many times. Hope that helps... try not use them unless you really have to. - Original Message - From: Kevin Wilhelm [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Monday, June 18, 2007 3:12 PM Subject: Share one singleton across webapps I managed to get a jar file shared across two webapps in my Tomcat 6. Inside there is a class that represents a Singleton. The problem: the singleton class is instantiated by the first webapp and then again instantiated in the second webapp. So there are 2 representations of the class and it is not really shared. There has to be a way to let the first webapp instantiate the singleton and set some property so that the second webapp can use the singleton and read the property. How do I achieve this? -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: Using shared Spring Webapp in Tomcat 6
I understand it makes no sense to share a whole webapp in Tomcat. What about sharing a singleton across all Tomcat webapps? I want my main webapp to call a method on that shared singleton in order to provide a factory (...getInstance().setFactory()). This factory should be retrieved by webapps using that singleton (getFactory()). I know I have to put that singleton (in a jar file) into the $CATALINA_HOME/lib directory. How do I access the singleton from within my webapps after that? I guess I have to touch the web.xml somewhere. However, the first call must set the factory (the main webapp will do that)... all following calls shall be able to access the factory. - Original Message - From: Caldarale, Charles R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Friday, June 15, 2007 12:08 AM Subject: RE: Using shared Spring Webapp in Tomcat 6 From: Kevin Wilhelm [mailto:[EMAIL PROTECTED] Subject: Using shared Spring Webapp in Tomcat 6 For Tomcat 6 there is a folder called $CATALINAHOME/lib that is said to be used for that kind of stuff. No, the $CATALINA_HOME/lib directory is for classes common to all webapps, not any individual webapps. Each webapp is normally deployed in its own directory under the Host appBase (typically $CATALINA_HOME/webapps). 1.) Does it work to create a war file from my services webapp and put it into the lib directory? Is this the way to go? No. 2.) Furthermore: Where do I start with my JSP/JSF view webapp? I assume I have to access the SessionFacade somehow. I will have to access the logic web app from within my view-webapp. If your logic webapp is just that - no presentation capabilities - then it's not really a webapp, is it? Sounds like you haven't really thought through the application architecture here. This may well be more of a Spring topic than a Tomcat one. - 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] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using shared Spring Webapp in Tomcat 6
Hello, I am about to finalize some early state Spring web application (just the persistence and logic part). I am using Hibernate to retrieve data from a database. I created the whole logic using the Spring framework; at the top there is a Session Facade providing access to all the services. At this point I want to create JSP/JSF views in another webapp. I want to create a new web application that *USES* the services of the one described above. For Tomcat 6 there is a folder called $CATALINAHOME/lib that is said to be used for that kind of stuff. But isn't this folder meant to be used for jars instead of complete running web apps? 1.) Does it work to create a war file from my services webapp and put it into the lib directory? Is this the way to go? 2.) Furthermore: Where do I start with my JSP/JSF view webapp? I assume I have to access the SessionFacade somehow. I will have to access the logic web app from within my view-webapp. I'd appreciate some hints on that! Thanks in advance! -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]