RE: ClassCastException while sharing objects accross applications
The type in Java is a combination of a fully qualified class name and its defining classloader. So the two objects with the same class name are considered different types in your two web applications because each web application is loaded by the dedicated webapp classloader. To solve your problem you can use object serialization or if your objects are the java beans you can use the java.beans encoding. The XMLEncoder class is a complementary alternative to the ObjectOutputStream and can used to generate a textual representation of a JavaBean in the same way that the ObjectOutputStream can be used to create binary representation of Serializable objects. --Seva From: Surya Mishra [mailto:[EMAIL PROTECTED] Sent: Mon 10/3/2005 4:12 PM To: Tomcat Users List Subject: ClassCastException while sharing objects accross applications Hi, I am trying to share an object between 2 applications deployed on the same tomcat server. I have put the object in the ServletContext in my first application. I access the object using ServletContext.getContext(firstApp).getAttribute(object);. The object comes in fine but it won't let me cast it to the actual Object Type. I get a ClassCastException. I tried printing the name of the class. That also came fine (same class name). Thanks in advance. -Surya
Re: ClassCastException while sharing objects accross applications
What about using JNDI to share objects between webapps? I think that: init(){ ... String context = java:comp/env/; InitialContext ic = new InitialContext(); ClassX c = (ClassX) ic.lookup(sContexto); ... } should return the same object to different servlets/webapps, if you define the jndi-resource globally, i.e., in conf/server.xml - Original Message - From: Seva Popov [EMAIL PROTECTED] To: Tomcat Users List Surya Mishra [EMAIL PROTECTED]@gmail.com; Tomcat Users List tomcat-user@jakarta.apache.org Sent: Tuesday, October 04, 2005 8:41 AM Subject: RE: ClassCastException while sharing objects accross applications The type in Java is a combination of a fully qualified class name and its defining classloader. So the two objects with the same class name are considered different types in your two web applications because each web application is loaded by the dedicated webapp classloader. To solve your problem you can use object serialization or if your objects are the java beans you can use the java.beans encoding. The XMLEncoder class is a complementary alternative to the ObjectOutputStream and can used to generate a textual representation of a JavaBean in the same way that the ObjectOutputStream can be used to create binary representation of Serializable objects. --Seva From: Surya Mishra [mailto:[EMAIL PROTECTED] Sent: Mon 10/3/2005 4:12 PM To: Tomcat Users List Subject: ClassCastException while sharing objects accross applications Hi, I am trying to share an object between 2 applications deployed on the same tomcat server. I have put the object in the ServletContext in my first application. I access the object using ServletContext.getContext(firstApp).getAttribute(object);. The object comes in fine but it won't let me cast it to the actual Object Type. I get a ClassCastException. I tried printing the name of the class. That also came fine (same class name). Thanks in advance. -Surya - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException while sharing objects accross applications
From: Andrés Glez. [mailto:[EMAIL PROTECTED] Subject: Re: ClassCastException while sharing objects accross applications What about using JNDI to share objects between webapps? Won't change anything, due to the previously noted classloader-specific casting issue. What should work (haven't tried it) is to put the defining class for the object of interest in shared/classes or shared/lib (if packaged in a jar), and remove it from each webapp. This will create the class under a classloader visible to both webapps. See: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/class-loader-howto.html for more info. - 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 unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException while sharing objects accross applications
What Chuck says is right. This approach has a few gotchas though, especially if ClassX is complex and references many other objects loaded from the same (WebApp) classloader. You can end up with a lot of classes up in the common repository. -o Make ClassX an interface, if you can. That way only the interface (and any referenced types) need go in common. Refactoring here we go :) HTH, Jon Caldarale, Charles R wrote: From: Andrés Glez. [mailto:[EMAIL PROTECTED] Subject: Re: ClassCastException while sharing objects accross applications What about using JNDI to share objects between webapps? Won't change anything, due to the previously noted classloader-specific casting issue. What should work (haven't tried it) is to put the defining class for the object of interest in shared/classes or shared/lib (if packaged in a jar), and remove it from each webapp. This will create the class under a classloader visible to both webapps. See: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/class-loader-howto.html for more info. - 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 unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException while sharing objects accross applications
Yes, using the shared classloader seems like an obvious and easy option for sharing the objects between the web applications. However, like the previous author notes relying on the classloader can bring up some issues like introducing new dependencies and reducing the web application incapsulation. That is why the alternative way of sharing objects between the web applications is worth considering I guess. As I noted before one can achive this using the java object serialization or the java.beans xml encoding. This technique allows one to effectively eliminate the class loader information from the type and thus share the objects between the web applications without using the shared classloader. BTW, one can not use the Tomcat JNDI tree as a place to share the objects between the web apps, because Tomcat does not allow one to put an arbitrary object into the JNDI tree. One possible way is to utilize the system MBeanServer. --Seva -Original Message- From: Jon Wingfield [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 04, 2005 9:47 AM To: Tomcat Users List Subject: Re: ClassCastException while sharing objects accross applications What Chuck says is right. This approach has a few gotchas though, especially if ClassX is complex and references many other objects loaded from the same (WebApp) classloader. You can end up with a lot of classes up in the common repository. -o Make ClassX an interface, if you can. That way only the interface (and any referenced types) need go in common. Refactoring here we go :) HTH, Jon Caldarale, Charles R wrote: From: Andrés Glez. [mailto:[EMAIL PROTECTED] Subject: Re: ClassCastException while sharing objects accross applications What about using JNDI to share objects between webapps? Won't change anything, due to the previously noted classloader-specific casting issue. What should work (haven't tried it) is to put the defining class for the object of interest in shared/classes or shared/lib (if packaged in a jar), and remove it from each webapp. This will create the class under a classloader visible to both webapps. See: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/class-loader-howto.html for more info. - 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 unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException while sharing objects accross applications
Hi, I am trying to share an object between 2 applications deployed on the same tomcat server. I have put the object in the ServletContext in my first application. I access the object using ServletContext.getContext(firstApp).getAttribute(object);. The object comes in fine but it won't let me cast it to the actual Object Type. I get a ClassCastException. I tried printing the name of the class. That also came fine (same class name). Thanks in advance. -Surya
RE: Tomcat 5.5.9 with Struts 1.2.7 - ClassCastException - looks like a Tomcat bug
Thank you Christian - you are correct. A colleague also referred me to: http://www.systemmobile.com/wp/?p=152 I had a copy of jsp-api.jar in my app (/WEB-INF/lib/jsp-api.jar) And Tomcat (both 5.0.28 and 5.5.9) has a copy under $CATALINA_HOME/common/lib/jsp-api.jar This makes the copy in my app redundant and it can safely be removed. By removing it, it resolves the ClassCastException with org.apache.struts.taglib.html.MessagesTei But why should this double presence of jsp-api.jar be a problem for Tomcat 5.5.9 but not for 5.0.28? Thank you, Stewart -Original Message- From: Christian Dionne [mailto:[EMAIL PROTECTED] Sent: 17 August 2005 14:14 To: 'Struts Users Mailing List' Subject: RE: Tomcat 5.5.9 with Struts 1.2.7 - ClassCastException - looks like a Tomcat bug Hi Stewart, I had the same problem and I received a great answer on this mailing list a few days ago. The problem is caused by either one of these libraries that are conflicting with Struts: - jsp-api.jar - jsp-2.0-api.jar On my side, removing these libraries from my project (they were not used) solved the problem. Thanks, Christian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: August 17, 2005 6:24 AM To: [EMAIL PROTECTED]; user@struts.apache.org Subject: Tomcat 5.5.9 with Struts 1.2.7 - ClassCastException - looks like a Tomcat bug Using Struts 1.2.7 with the latest Tomcat 5.5.9 I get the following in localhost.date.log when I first try to access my web application: 17-Aug-2005 11:02:02 org.apache.catalina.core.Stand-ardHostValve custom SEVERE: Exception Processing ErrorPage[exceptionType=java.l-ang.Exception, location=/error.jsp] org.apache.jasper.JasperExcept-ion: Failed to load or instantiate TagExtraInfo class: org.apache.struts.taglib.html.-MessagesTei And in stdout_date.log I get: ERROR:org.apache.catalina.core-.ApplicationDispatcher.invoke(-Applicatio nDispatcher.java:704-) Servlet.service() for servlet jsp threw exception java.lang.ClassCastException: org.apache.struts.taglib.html.-MessagesTei Through trial and error I have found that this does not happen with Tomcat 5.0.28, with all other factors (struts, my application, etc) kept the same. Thought you all might like to know. Stewart - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException When Compiling JSP
Hi, Tomcat is unable to compile any of the JSPs in my application (Struts 1.2.7, JDK 5, Tomcat 5.5.9) because of a ClassCastException when loading up of the Struts TLDs. I'm posting the problem here because the application works fine using Resin. There are two stack traces. The one that actually presents the problem is the second one listed. The HTTP 500 error message contains: exception org.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:591) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001) org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:560) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.systemmobile.sparrow.util.LoginFilter.doFilter(LoginFilter.java:55) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) root cause java.lang.ClassNotFoundException: org.apache.jsp.login.index_jsp java.net.URLClassLoader$1.run(URLClassLoader.java:200) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:188) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:158) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:589) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063) org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1001) org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:560) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.systemmobile.sparrow.util.LoginFilter.doFilter(LoginFilter.java:55) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) The reason the JSP isn't found is because a ClassCastException was thrown during compile. Here's the exception from the logs: ERROR: 2005-07-30 23:52:50,067: StandardWrapperValve: Servlet.service() for servlet default threw exception java.lang.ClassCastException: org.apache.struts.taglib.html.MessagesTei at org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:420) at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248) at org.apache.jasper.compiler.TagLibraryInfoImpl.init(TagLibraryInfoImpl.java:162) at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418) at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1543) at org.apache.jasper.compiler.Parser.parse(Parser.java:126) at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146
Re: session replication problem: ClassCastException
Hi Peter, thank you very much for your quick response! I have more information on this topic now. Peter Rossbach wrote: First your are sure that your wars inside the installation art identical? Yes I am. Our automated install procedure ensures that. You stacktraces are strange. The cast inside writeSession use only tomcat classes! Have you change the authorisation and use your own principal implementation ? No. We did no such changes. I already thought it might have something to do with different Classloaders used by the two tomcats, but I know too little about the Classloaders that tomcat uses to judge this suspicion. For more help I think do the following steps a) update to tomcat 5.5.9 b) install the cluster fix ( The Bug Database http://issues.apache.org/bugzilla/show_bug.cgi?id=34389) c) change your Cluster Config from SimpleTcpReplicationManager to DeltaManager d) Use fastasyncqueue mode. We die the same modifications to our testcluster now. Because the configuration files are autogenerated i am sure that the config files are the same except the details that have to be different (like machine names etc.). Besides that we have exactly the same software (webapp) running on the testcluster. The interesting part is that we do not see these ClassCastExceptions in the testcluster? I originally thought that it might be that we got something wrong with the tomcat set-up and i've reinstalled tomcat 5.5.4 plus jdk1.4 patch on the production machines but this did not help. We also noticed that these class cast exceptions do not depend on the numbers of sessions we have. They are roughly constant at roughly 2 such exceptions per minute, even during the night where our session count drops to basically 0. We currently cannot upgrade to tomcat 5.5.9 because of our upgrade policy to only upgrade software when it was extensively tested in our test environment. Via Google I only found one post with a remotely similar problem: http://www.junlu.com/msg/65888.html otherwise I have no more Ideas on how to continue from here. Do you see any other way how to analyse and debug this problem? Thank you very much! -- Christian Schuhegger http://www.el-chef.de/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
session replication problem: ClassCastException
hello, we have since two weeks a problem with session replication. we use jakarta-tomcat-5.5.4.tar.gz with the compatibility package for jdk1.4 on a redhat advanced server. we are sure that session replication was still working roughly two weeks ago, but the only thing we remember that we changed during that time was the layout of the configuration files, e.g. instead of having the server.xml file directly in the conf directory we created a link to this file which resides now in another directory. we did this for several parts of our tomcat configuration. otherwise we are quite sure we did not change anything else. we did not change our web application during that time and in addition we have taken extensive measures to make sure that all objects that are put into the session are serializable. the problem we have looks like this on the tomcat which tries to serialize the session: -- snip start -- SCHWERWIEGEND: Failed to serialize the session! java.lang.ClassCastException at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.writeSession(SimpleTcpReplicationManager.java:326) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.requestCompleted(SimpleTcpReplicationManager.java:292) at org.apache.catalina.cluster.tcp.ReplicationValve.invoke(ReplicationValve.java:188) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:534) -- snip end -- and like this on the other end: -- snip start -- SCHWERWIEGEND: Failed to deserialize the session! java.lang.NullPointerException at java.io.ByteArrayInputStream.init(ByteArrayInputStream.java:89) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.readSession(SimpleTcpReplicationManager.java:352) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.messageReceived(SimpleTcpReplicationManager.java:551) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.messageDataReceived(SimpleTcpReplicationManager.java:590) at org.apache.catalina.cluster.tcp.SimpleTcpCluster.messageDataReceived(SimpleTcpCluster.java:548) at org.apache.catalina.cluster.io.ObjectReader.execute(ObjectReader.java:69) at org.apache.catalina.cluster.tcp.TcpReplicationThread.drainChannel(TcpReplicationThread.java:126) at org.apache.catalina.cluster.tcp.TcpReplicationThread.run(TcpReplicationThread.java:64) -- snip end -- the one thing which is VERY strange to me is that normally with a ClassCastException you get the type info of which class it tries to cast, but here we only get java.lang.ClassCastException? we tried to search google for people having similar problems, but we were not able to find any references to such a problem. perhaps somebody on this list is able to help us with this issue? -- Christian Schuhegger http://www.el-chef.de/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: session replication problem: ClassCastException
Hmm, First your are sure that your wars inside the installation art identical? You stacktraces are strange. The cast inside writeSession use only tomcat classes! Have you change the authorisation and use your own principal implementation ? For more help I think do the following steps a) update to tomcat 5.5.9 b) install the cluster fix ( The Bug Database http://issues.apache.org/bugzilla/show_bug.cgi?id=34389) c) change your Cluster Config from SimpleTcpReplicationManager to DeltaManager d) Use fastasyncqueue mode. Peter Christian Schuhegger schrieb: hello, we have since two weeks a problem with session replication. we use jakarta-tomcat-5.5.4.tar.gz with the compatibility package for jdk1.4 on a redhat advanced server. we are sure that session replication was still working roughly two weeks ago, but the only thing we remember that we changed during that time was the layout of the configuration files, e.g. instead of having the server.xml file directly in the conf directory we created a link to this file which resides now in another directory. we did this for several parts of our tomcat configuration. otherwise we are quite sure we did not change anything else. we did not change our web application during that time and in addition we have taken extensive measures to make sure that all objects that are put into the session are serializable. the problem we have looks like this on the tomcat which tries to serialize the session: -- snip start -- SCHWERWIEGEND: Failed to serialize the session! java.lang.ClassCastException at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.writeSession(SimpleTcpReplicationManager.java:326) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.requestCompleted(SimpleTcpReplicationManager.java:292) at org.apache.catalina.cluster.tcp.ReplicationValve.invoke(ReplicationValve.java:188) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:534) -- snip end -- and like this on the other end: -- snip start -- SCHWERWIEGEND: Failed to deserialize the session! java.lang.NullPointerException at java.io.ByteArrayInputStream.init(ByteArrayInputStream.java:89) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.readSession(SimpleTcpReplicationManager.java:352) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.messageReceived(SimpleTcpReplicationManager.java:551) at org.apache.catalina.cluster.session.SimpleTcpReplicationManager.messageDataReceived(SimpleTcpReplicationManager.java:590) at org.apache.catalina.cluster.tcp.SimpleTcpCluster.messageDataReceived(SimpleTcpCluster.java:548) at org.apache.catalina.cluster.io.ObjectReader.execute(ObjectReader.java:69) at org.apache.catalina.cluster.tcp.TcpReplicationThread.drainChannel(TcpReplicationThread.java:126) at org.apache.catalina.cluster.tcp.TcpReplicationThread.run(TcpReplicationThread.java:64) -- snip end -- the one thing which is VERY strange to me is that normally with a ClassCastException you get the type info of which class it tries to cast, but here we only get java.lang.ClassCastException? we tried to search google for people having similar problems, but we were not able to find any references to such a problem. perhaps somebody on this list is able to help us with this issue? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mail Session ClassCastException
Thanks Dirk, you were right, I had the jar files in common/lib and also in the web-inf/lib Thanks again On 6/29/05, Dirk Weigenand [EMAIL PROTECTED] wrote: Hi Carlos, --- Ursprüngliche Nachricht --- Von: Carlos Bracho [EMAIL PROTECTED] An: tomcat-user@jakarta.apache.org Betreff: Mail Session ClassCastException Datum: Tue, 28 Jun 2005 10:08:28 -0400 Hello everybody. I am trying to get a mail session using the context's lookup method and I get a ClassCastException. this is the resource declaration in my context.xml: Resource name=mail/sessionMail auth=Container type=javax.mail.Session mail.smtp.host=localhost/ the code I am using to lookup the resource is: Context initialContext = new InitialContext(); Object objeto = initialContext.lookup(java:comp/env/mail/sessionMail); String clase = objeto.getClass().getName(); if(objeto instanceof javax.mail.Session) { this.session = (javax.mail.Session) objeto; } when I debug that code I see the clase variable has javax.mail.Session as value but the if test does not pass I think your code is correct. What you are running into here is a case of loading classes via different class loaders. Check that your tomcat installation and your webapp do not both contain mail.jar. The bean factory which provides your javax.mail.Session loads the class probably from the common/lib/mail.jar and your webapp gets this class from its WEB-INF/lib/mail.jar so they are both instances of javax.mail.Session but since loaded via different class loaders not really the same classes. Can anybody help men?? Regards, Dirk -- Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie! Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl -- -- Carlos J, Bracho M. -- e-mail: [EMAIL PROTECTED] MSN: [EMAIL PROTECTED] +58 416 409 21 75 --
Mail Session ClassCastException
Hello everybody. I am trying to get a mail session using the context's lookup method and I get a ClassCastException. this is the resource declaration in my context.xml: Resource name=mail/sessionMail auth=Container type=javax.mail.Session mail.smtp.host=localhost/ the code I am using to lookup the resource is: Context initialContext = new InitialContext(); Object objeto = initialContext.lookup(java:comp/env/mail/sessionMail); String clase = objeto.getClass().getName(); if(objeto instanceof javax.mail.Session) { this.session = (javax.mail.Session) objeto; } when I debug that code I see the clase variable has javax.mail.Session as value but the if test does not pass Can anybody help men?? thanks -- -- Carlos J, Bracho M. -- e-mail: [EMAIL PROTECTED] MSN: [EMAIL PROTECTED] +58 416 409 21 75 --
Re: DBCP ClassCastException
Dhiren Bhatia wrote: I'm using BasicDataSource because javax.sql.DataSource does not have methods to set the driver class name, url, username/pwd etc. My app needs to support different databases and the driver is loaded based on which database is installed. You've got it backwards. It is the responsibility of a J2EE container to use whatever the implementatio it likes and set those parameters and then give your application just javax.sql.DataSource. THAT will make your application portable. Nix. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBCP ClassCastException
Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBCP ClassCastException
Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: DBCP ClassCastException
Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource? Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBCP ClassCastException
I'm using BasicDataSource because javax.sql.DataSource does not have methods to set the driver class name, url, username/pwd etc. My app needs to support different databases and the driver is loaded based on which database is installed. If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not portable to JBoss/Weblogic etc right? BTW, which jar is org.apache.tomcat.dbcp.dbcp.BasicDataSource in? Thanks for your response. Dhiren On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource? Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: DBCP ClassCastException
You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in common/lib/naming-factory-dbcp.jar. If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jar in common/lib you (maybe) should be able to use org.apache.commons.dbcp.BasicDataSource. I do it in a similar way - I have my own ressource factory, which extends org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5 with the above jars. Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 18:47 An: Tomcat Users List Betreff: Re: DBCP ClassCastException I'm using BasicDataSource because javax.sql.DataSource does not have methods to set the driver class name, url, username/pwd etc. My app needs to support different databases and the driver is loaded based on which database is installed. If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not portable to JBoss/Weblogic etc right? BTW, which jar is org.apache.tomcat.dbcp.dbcp.BasicDataSource in? Thanks for your response. Dhiren On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource? Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBCP ClassCastException
It works if I use org.apache.tomcat.dbcp.dbcp.BasicDataSource. I've tried adding all the commons jars to common/lib and it still doesn't work with org.apache.commons.dbcp.BasicDataSource. How do you get it to cast with your own resource factory? The way I see it, it should be the same thing if you're extending from org.apache.commons.dbcp.BasicDataSource. Just FYI...Here's what I have in commons/lib: commons-collections-3.1.jar* log4j.jar* commons-dbcp-1.2.1.jar* mysql-connector-java-3.1.7-bin.jar* commons-pool-1.2.jar* naming-factory-dbcp.jar* jasper-compiler-jdt.jar* naming-factory.jar* jasper-compiler.jar* naming-resources.jar* jasper-runtime.jar* servlet-api.jar* jsp-api.jar* On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in common/lib/naming-factory-dbcp.jar. If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jarin common/lib you (maybe) should be able to use org.apache.commons.dbcp.BasicDataSource. I do it in a similar way - I have my own ressource factory, which extends org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5with the above jars. Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 18:47 An: Tomcat Users List Betreff: Re: DBCP ClassCastException I'm using BasicDataSource because javax.sql.DataSource does not have methods to set the driver class name, url, username/pwd etc. My app needs to support different databases and the driver is loaded based on which database is installed. If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not portable to JBoss/Weblogic etc right? BTW, which jar is org.apache.tomcat.dbcp.dbcp.BasicDataSource in? Thanks for your response. Dhiren On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource? Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type= javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Yes. The syntax for the Resource tag in the server.xml has changed. The resource parameters are no longer defined in tags nested into the Resource tag, but in attributes of the tag. This is an example from the Tomcat 5.5 documentation: Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/javatest?autoReconnect=true/ http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html Best wishes, Lutz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail
AW: DBCP ClassCastException
My factory: import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.dbcp.BasicDataSourceFactory; public class MyDataSourceFactory extends BasicDataSourceFactory { public Object getObjectInstance( Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { BasicDataSource basicDataSource = (BasicDataSource) super.getObjectInstance( obj, name, nameCtx, environment); if ((obj == null) || !(obj instanceof Reference)) { return (null); } Reference ref = (Reference) obj; if (!javax.sql.DataSource.equals(ref.getClassName())) { return (null); } // do some stuff here // ... return basicDataSource; } } and of course you have to specify this factory in your context.xml (or web.xml) Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 19:27 An: Tomcat Users List Betreff: Re: DBCP ClassCastException It works if I use org.apache.tomcat.dbcp.dbcp.BasicDataSource. I've tried adding all the commons jars to common/lib and it still doesn't work with org.apache.commons.dbcp.BasicDataSource. How do you get it to cast with your own resource factory? The way I see it, it should be the same thing if you're extending from org.apache.commons.dbcp.BasicDataSource. Just FYI...Here's what I have in commons/lib: commons-collections-3.1.jar* log4j.jar* commons-dbcp-1.2.1.jar* mysql-connector-java-3.1.7-bin.jar* commons-pool-1.2.jar* naming-factory-dbcp.jar* jasper-compiler-jdt.jar* naming-factory.jar* jasper-compiler.jar* naming-resources.jar* jasper-runtime.jar* servlet-api.jar* jsp-api.jar* On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: You can find org.apache.tomcat.dbcp.dbcp.BasicDataSource in common/lib/naming-factory-dbcp.jar. If you put commons-dbcp.jar, commons-pool.jar and commons-collections.jarin common/lib you (maybe) should be able to use org.apache.commons.dbcp.BasicDataSource. I do it in a similar way - I have my own ressource factory, which extends org.apache.commons.dbcp.BasicDataSourceFactory and it works in tomcat 5.5with the above jars. Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 18:47 An: Tomcat Users List Betreff: Re: DBCP ClassCastException I'm using BasicDataSource because javax.sql.DataSource does not have methods to set the driver class name, url, username/pwd etc. My app needs to support different databases and the driver is loaded based on which database is installed. If I use org.apache.tomcat.dbcp.dbcp.BasicDataSource, then my code is not portable to JBoss/Weblogic etc right? BTW, which jar is org.apache.tomcat.dbcp.dbcp.BasicDataSource in? Thanks for your response. Dhiren On 5/9/05, Pfingstl Gernot [EMAIL PROTECTED] wrote: Tomcat 5.5 doesn't use commons-dbcp directly, the tomcat team took the source and put it in other packages. So you should use org.apache.tomcat.dbcp.dbcp.BasicDataSource instead of org.apache.commons.dbcp.BasicDataSource in your source - btw why do you cast to BasicDataSource, you can use javax.sql.DataSource? Gernot -Ursprüngliche Nachricht- Von: Dhiren Bhatia [mailto:[EMAIL PROTECTED] Gesendet: Montag, 09. Mai 2005 17:19 An: Tomcat Users List Betreff: Re: DBCP ClassCastException Hi Lutz, I changed the Resource tag definition to: Resource name=jdbc/myserver auth=Container type= javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 driverClassName=com.mysql.jdbc.Driver/ I'm setting the username/password and jdbcurl using code. I still get the same ClassCastException. Is Tomcat instantiating the correct DataSourceFactory? I have the commons-dbcp-1.2.1.jar in my ${TOMCAT_HOME}/common/lib Thanks, Dhiren On 5/8/05, Lutz Zetzsche [EMAIL PROTECTED] wrote: Hi Dhiren, Am Montag, 9. Mai 2005 07:36 schrieb Dhiren Bhatia: Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref
DBCP ClassCastException
Hi all, I'm getting a the following ClassCastException running Tomcat 5.5.9 with MySQL java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource Here's the relevant code: *Java code:* org.apache.commons.dbcp.BasicDataSource datasource; datasource = (BasicDataSource)ctx.lookup(java:comp/env/jdbc/myserver); *web.xml* resource-ref descriptionDB Connection/description res-ref-namejdbc/myserver/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref *server.xml* ** ResourceParams name=jdbc/myserver parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter *...* This same code works in Tomcat 5.0.30. Has anything changed? Am I missing something? Thanks.
Session replication : classcastexception on principal
Hi, I use a JAASRealm in my context with mys own LoginModule to authenticate in mys webapp. When I use the cluster for session replication, I have a ClassCastExecption when the cluster try to serialize the Principal object. When I look in the source code (org.apache.catalina.cluster.session.DeltaRequest.setPrincipal(), I see that they are a cast for the specific catalina principal object : GenericPrincipal. With a JAASRealm you don't use this object for principal, you precise your own class (userClassName attribute). Is it a bug or is my authentication technic is not ok ? + / \ improve Sébastien Letélié /-\ Consultant - Tel : 00 420 257 317 435 skype : sebmadecz AOL : sebmade ICQ : #336508634 MSN : [EMAIL PROTECTED] - http://blogs.application-servers.com/blogs/page/sebmade mon weblog, articles et informations sur les nouvelles technologies http://www.resurgences.com solution pour les Services d'Accès aux Urgences hospitalières http://www.improve-institute.com toutes vos formations J2EE et WebSphere http://www.application-servers.com les brèves technologiques http://www.improve.technologies.com votre index thématique sur les nouvelles technologies - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException
Hi, There is a ClassCastException when we run the JspC class with the proper arguments. I have given the detailed exception at the end of this mail, // In org.apache.jasper.JspC class code private void initServletContext() { try { context = new JspCServletContext(new PrintWriter(System.out), new URL(file: + uriRoot.replace('\\', '/') + '/')); tldLocationsCache = new TldLocationsCache(context, true); } catch(MalformedURLException me) { System.out.println(** + me); } rctxt = new JspRuntimeContext(context, this); jspConfig = new JspConfig(context); tagPluginManager = new TagPluginManager(context); } In this method it creates the object of jspRunTimeContext rctxt = new JspRuntimeContext(context, this); // end JspC class code // In org.apache.jasper.compiler.JspRuntimeContext class In constructor of this class, public JspRuntimeContext(ServletContext context, Options options){ jsps = Collections.synchronizedMap(new HashMap()); thread = null; threadDone = false; threadName = JspRuntimeContext; System.setErr(new SystemLogHandler(System.err)); this.context = context; this.options = options; // The below line causing the exception to be thrown parentClassLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader(); if(parentClassLoader == null) parentClassLoader = (URLClassLoader)getClass().getClassLoader(); if(log.isDebugEnabled()) if(parentClassLoader != null) log.debug(Localizer.getMessage(jsp.message.parent_class_loader_is, parentClassLoader.toString())); else log.debug(Localizer.getMessage(jsp.message.parent_class_loader_is, none)); initClassPath(); if(context instanceof JspCServletContext) return; if(System.getSecurityManager() != null) ... ..} // Here it is expecting the current thread class loader to be of type URLClassLoader, which is not,it is set with the AntClassLoader2.. Hence throwing the exception parentClassLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader(); /// end of org.apache.jasper.compiler.JspRuntimeContext class The reason is the current thread class loader has set in JspC after JspRuntimeContext() object creation call, setting of current thread class loader to URLClassLoader is done in the below given method in JspC class private void initClassLoader(JspCompilationContext clctxt) method // Begin JspC class Thread.currentThread().setContextClassLoader(loader); // end JspC class The class loader, URLClassLoader is set to the current thread after the exception is thrown from org.apache.jasper.compiler.JspRuntimeContext, if it set before ,then it will definitely work. --- total flow. from JspC class, methods flow Main() -- execute()--- initServletContext(); initServletContext() In this method creating the below object by calling the only one constructor of org.apache.jasper.compiler.JspRuntimeContext(context, option) -- in org.apache.jasper.compiler.JspRuntimeContext org.apache.jasper.compiler.JspRuntimeContext taking the current thread class loader and expecting to be as URLClassloader, exception thrown --- in JspC after this flow there is code to set the currentCLassLoader to URLClassLoader, in initClassLoader(JspCompilationContext clctxt) method this should be set before the creation of JspRuntimeContext object to avoid this exception. --- It would be great if we have precompilation feature. I don't know if there is any other alternatives available for this, I think we could do this. Please let me know if this is considered already and have counter this problem. --- The detailed exception is ... The line numbers may not correct since i put some System.out.println().. The code thrrowing the exception is JspRuntimeContext costructor parentClassLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader(); [java] java.lang.ClassCastException [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:172) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:705) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [java] at org.apache.tools.ant.Task.perform(Task.java:364) [java] at org.apache.tools.ant.Target.execute(Target.java:341) [java] at org.apache.tools.ant.Target.performTasks(Target.java:369) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1214) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1062) [java] at org.apache.tools.ant.Main.runBuild(Main.java:673) [java
ClassCastException in org.apache.jasper.compiler.TagLibraryInfoImpl (Tomcat5.5)
Whats up with this? java.lang.ClassCastException org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:420) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248) org.apache.jasper.compiler.TagLibraryInfoImpl.init(TagLibraryInfoImpl.java:162) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539) org.apache.jasper.compiler.Parser.parse(Parser.java:126) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) Heres a copy of the jsp I'm trying to compile: The JSP is just a huge list of taglib definitions: %@ taglib prefix=image uri=http://dev.sofari.com/taglibs/image/; % %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % %@ taglib prefix=fn uri=http://java.sun.com/jsp/jstl/functions; % %@ taglib prefix=fmturi=http://java.sun.com/jsp/jstl/fmt; % As an example... I can provide you with the full JSP file. -- Use Rojo (RSS/Atom aggregator). Visit http://rojo.com. Ask me for an invite! Also see irc.freenode.net #rojo if you want to chat. Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html If you're interested in RSS, Weblogs, Social Networking, etc... then you should work for Rojo! If you recommend someone and we hire them you'll get a free iPod! Kevin A. Burton, Location - San Francisco, CA AIM/YIM - sfburtonator, Web - http://peerfear.org/ GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException in org.apache.jasper.compiler.TagLibraryInfoImpl (Tomcat5.5)
Kevin A. Burton wrote: Whats up with this? java.lang.ClassCastException org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:420) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248) If I reduce my webapp down to just this: %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % Then I get: org.apache.jasper.JasperException: Unable to read TLD META-INF/c.tld from JAR file file:/usr/local/jakarta-tomcat-5.5.4/webapps/rojo/ROOT/WEB-INF/lib/standard.jar: org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:179) org.apache.jasper.compiler.TagLibraryInfoImpl.init(TagLibraryInfoImpl.java:181) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539) org.apache.jasper.compiler.Parser.parse(Parser.java:126) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) But the standard.jar I'm using is the SAME one from Tomcat 5.5 and even the md5sum is the same (so its not corrupt). The insane parse is that everytime I reload the page I get a diff error (FUN!) java.lang.ClassNotFoundException: org.apache.jsp.pagelet.taglibs_jsp java.net.URLClassLoader$1.run(URLClassLoader.java:199) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:187) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:156) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:69) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:589) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) BTW. Throughout this ENTIRE process Tomcat has been swallowing the real error. Not very professional :-/ Makes me wonder what other fun little secrets Tomcat has in store for me in the future. Kevin -- Use Rojo (RSS/Atom aggregator). Visit http://rojo.com. Ask me for an invite! Also see irc.freenode.net #rojo if you want to chat. Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html If you're interested in RSS, Weblogs, Social Networking, etc... then you should work for Rojo! If you recommend someone and we hire them you'll get a free iPod! Kevin A. Burton, Location - San Francisco, CA AIM/YIM - sfburtonator, Web - http://peerfear.org/ GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException in org.apache.jasper.compiler.TagLibraryInfoImpl (Tomcat5.5)
Are you running with the security manager turned on? If so - do you get the same error with it turned off? (BTW 5.5 has not been voted stable yet) -Tim Kevin A. Burton wrote: Kevin A. Burton wrote: Whats up with this? java.lang.ClassCastException org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:420) org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248) If I reduce my webapp down to just this: %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; % Then I get: org.apache.jasper.JasperException: Unable to read TLD META-INF/c.tld from JAR file file:/usr/local/jakarta-tomcat-5.5.4/webapps/rojo/ROOT/WEB-INF/lib/standard.jar: org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:179) org.apache.jasper.compiler.TagLibraryInfoImpl.init(TagLibraryInfoImpl.java:181) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1539) org.apache.jasper.compiler.Parser.parse(Parser.java:126) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) But the standard.jar I'm using is the SAME one from Tomcat 5.5 and even the md5sum is the same (so its not corrupt). The insane parse is that everytime I reload the page I get a diff error (FUN!) java.lang.ClassNotFoundException: org.apache.jsp.pagelet.taglibs_jsp java.net.URLClassLoader$1.run(URLClassLoader.java:199) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:187) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:156) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:69) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:589) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) BTW. Throughout this ENTIRE process Tomcat has been swallowing the real error. Not very professional :-/ Makes me wonder what other fun little secrets Tomcat has in store for me in the future. Kevin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException in org.apache.jasper.compiler.TagLibraryInfoImpl (Tomcat5.5) (oops)
(I was wrong) It was voted stable ... http://marc.theaimsgroup.com/?l=tomcat-devm=110011482407630w=2 -Tim Tim Funk wrote: Are you running with the security manager turned on? If so - do you get the same error with it turned off? (BTW 5.5 has not been voted stable yet) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JAASRealm / ClassCastException
hello, since a couple days i try to increase my understanding of JAASRealm. but this ongoing classcastexceptions do give me a hard time... tomcat 5.0.28 my goal is to authenticate users via servlet (FORM). so i tried this; [LoginServlet]: MyCallbackHandler handler = new MyCallbackHandler(name,password); LoginContext context = new LoginContext(ModulName, handler); context.login(); which results in that wellknown cce, as soon as my modul in its login-method wants to retrieve 'MyCallbackHandler' [AuthModul]: ... public boolean login() throws LoginException { ... MyCallBackHandler handler = (MyCallBackHandler) this.handler; // right here the cce is thrown ... ... so my thinking melts down to the following: i would like to keep all classes below WEB-INF and dont want to touch $CATALINA_HOME/server/lib or - /common/lib but where to put the custom AuthenticationModule, Handler, Principals if this results in the reported loader-issue the changelog for 5.0.28 mentions that u can define in your Realm-definition, if the Auth-Module should be loaded by your context-classloader. useContextClassLoader=true //default but even if i set it to false, its still loaded by the webappclassloader AuthModule/MyCallbackhandler loaded by WebAppClassloader, LoginContext / SecureCallbackhandler loaded by 'null' can anybody point me in the right direction? thanks in advance rene -- gpg-key 8FC78254 http://www.so36.net/keys/rene.asc fingerprint: E883 D359 3F56 51AF 0294 8BEB 16B3 15BD 8FC7 8254 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException with own Principal interface and implementation
This is probably a classloader issue. The Realm will load classes from the server classloader. Your webapp will also load the same classes in its own classloader. The two types of CrmPrincipal are not assignable so a ClassCastException results. Try placing the CrmPrincipal class in common/lib and removing it from your webapp. HTH, Jon ralf lorenz wrote: hi there, i've written my own realm 'CrmJDBCRealm' which extends the 'JDBCRealm' one of catalina. this realm creates and returns a principal of type 'CrmPrincipalImpl' which extends 'GenericPrincipal' and implements 'CrmPrincipal'. 'CrmPrincipal' has getter for an 'id' and getter and setter for a 'currentRole' field and extends 'Principal' as well as 'GenericPrincipal' does. 'CrmJDBCRealm', 'CrmPrincipalImpl' and 'CrmPrincipal' are packed together into a .jar and placed under %CATALINA_HOME%/server/lib on the other side the application only has the 'CrmPrincipal' included, so it doesn't know about 'CrmPrincipalImpl'. (even if it does nothing changed!) in my application i have a 'ChangeRoleAction' that is supposed to update the 'currentRole' if the user decides to have, only application-wide, another role. again that's nothing to do with the roles of the user that are known by the server via the 'GenericPrincipal'. when i try the following i get an ClassCastException CrmPrincipal principal = (CrmPrincipal) request.getUserPrincipal(); printing out the name of the class the request gives the 'CrmPrincipalImpl' will be stated. so the realm works fine but the cast can't be done. any help? ralf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException with own Principal interface and implementation
hi there, i've written my own realm 'CrmJDBCRealm' which extends the 'JDBCRealm' one of catalina. this realm creates and returns a principal of type 'CrmPrincipalImpl' which extends 'GenericPrincipal' and implements 'CrmPrincipal'. 'CrmPrincipal' has getter for an 'id' and getter and setter for a 'currentRole' field and extends 'Principal' as well as 'GenericPrincipal' does. 'CrmJDBCRealm', 'CrmPrincipalImpl' and 'CrmPrincipal' are packed together into a .jar and placed under %CATALINA_HOME%/server/lib on the other side the application only has the 'CrmPrincipal' included, so it doesn't know about 'CrmPrincipalImpl'. (even if it does nothing changed!) in my application i have a 'ChangeRoleAction' that is supposed to update the 'currentRole' if the user decides to have, only application-wide, another role. again that's nothing to do with the roles of the user that are known by the server via the 'GenericPrincipal'. when i try the following i get an ClassCastException CrmPrincipal principal = (CrmPrincipal) request.getUserPrincipal(); printing out the name of the class the request gives the 'CrmPrincipalImpl' will be stated. so the realm works fine but the cast can't be done. any help? ralf -- //~ created with opera - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TC5 Nightly : ClassCastException using Cluster manager
Aadi Deshpande wrote: As an additional side effect, since this is happening on session expiry the session count keeps getting higher and higher... right now I have 8942 sessions on a single instance! :-) This problem occurs with which Tomcat releases ? -- x Rémy Maucherat Developer Consultant JBoss Group (Europe) SàRL x - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
TC5 Nightly : ClassCastException using Cluster manager
( let me know if comments regarding nightly builds should be in the tomcat-dev mailing list instead ). Hi, I have a nightly build of Tomcat 5 ( mainly because i need some fixes in HEAD to resolve cross context issues ) , and I've set up the Cluster Manager ( in the updated format ) as specified in the server.xml. I came across a problem, however, when the ClusterManger is expiring sessions : WARNING: Unable to perform background process on manager java.lang.ClassCastException at org.apache.catalina.cluster.session.DeltaManager.processExpires(DeltaManager.java:914) at org.apache.catalina.cluster.session.DeltaManager.backgroundProcess(DeltaManager.java:904) at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:4546) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1619) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608) at java.lang.Thread.run(Thread.java:534) A couple things of note.. I don't really have any specific contexts, all my applications are webapps ( .war files ) and I have only a single DefaultContext set up in my server.xml file. From what I gather looking at the source code, it looks like not all the sessions retrieved by the findSessions() method call are DeltaSessions. I'm not sure why this is. The only reason I could come up with was because my web applications are specifically noted as contexts in my server.xml. Thanks for any input, -a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TC5 Nightly : ClassCastException using Cluster manager
As an additional side effect, since this is happening on session expiry the session count keeps getting higher and higher... right now I have 8942 sessions on a single instance! :-) -a Aadi Deshpande wrote: ( let me know if comments regarding nightly builds should be in the tomcat-dev mailing list instead ). Hi, I have a nightly build of Tomcat 5 ( mainly because i need some fixes in HEAD to resolve cross context issues ) , and I've set up the Cluster Manager ( in the updated format ) as specified in the server.xml. I came across a problem, however, when the ClusterManger is expiring sessions : WARNING: Unable to perform background process on manager java.lang.ClassCastException at org.apache.catalina.cluster.session.DeltaManager.processExpires(DeltaManager.java:914) at org.apache.catalina.cluster.session.DeltaManager.backgroundProcess(DeltaManager.java:904) at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:4546) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1619) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608) at java.lang.Thread.run(Thread.java:534) A couple things of note.. I don't really have any specific contexts, all my applications are webapps ( .war files ) and I have only a single DefaultContext set up in my server.xml file. From what I gather looking at the source code, it looks like not all the sessions retrieved by the findSessions() method call are DeltaSessions. I'm not sure why this is. The only reason I could come up with was because my web applications are specifically noted as contexts in my server.xml. Thanks for any input, -a - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException
Dear Java Friends, The following snippet code is for storing the ArrayList values into Object array and it has to display using another loop. My requirement is I want to store only in Object[] array but not in any other data type. Its compiling but giving run time error in the following line. Can anybody give their suggestion or recode the below. lo_oName = (Object[ ]) lo_arrListName.get(i); //giving error here in runtime. /* FullCode */ import java.util.*; public class Generic { public static void main ( String args[ ] ) { Object lo_oName[] = null; ArrayList lo_arrListName = new ArrayList(); lo_arrListName.add(HAPPY BIRTHDAY TO YOU...); lo_arrListName.add(YOU ARE NOT YOU YOU ARE HE...); lo_arrListName.add(THE GOD...); lo_arrListName.add(PRAY HIM DEEPLY PEACEFULLY...); lo_arrListName.add(HE GIVES ALL TO YOU...); /*lo_arrListName.add(new Integer(100)); lo_arrListName.add(new Integer(200)); lo_arrListName.add(new Integer(300)); */ int i = 0; System.out.println ( lo_arrListName.size()); while (ilo_arrListName.size() ) { System.out.println ( In the while loop. ); lo_oName = (Object[ ]) lo_arrListName.get(i); System.out.println (After storing the arraylist value in Object variable..); System.out.println (Value in object... + lo_oName[i].toString() ); i++; } } } - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!
RE: ClassCastException
Howdy, lo_oName = (Object[ ]) lo_arrListName.get(i); //giving error here in runtime. That's because each element of your array list is a String (or an Integer, but that part is commented out), not an array. You can use Object (plain, not array), or cast to the actual type. Try adding a System.out.println(lo_arrListName.get(i).getClass().getName()) before the above line. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException
Pinguti Sridevi wrote: Dear Java Friends, The following snippet code is for storing the ArrayList values into Object array and it has to display using another loop. My requirement is I want to store only in Object[] array but not in any other data type. Its compiling but giving run time error in the following line. Can anybody give their suggestion or recode the below. lo_oName = (Object[ ]) lo_arrListName.get(i); //giving error here in runtime. /* FullCode */ import java.util.*; public class Generic { public static void main ( String args[ ] ) { Object lo_oName[] = null; ArrayList lo_arrListName = new ArrayList(); lo_arrListName.add(HAPPY BIRTHDAY TO YOU...); lo_arrListName.add(YOU ARE NOT YOU YOU ARE HE...); lo_arrListName.add(THE GOD...); lo_arrListName.add(PRAY HIM DEEPLY PEACEFULLY...); lo_arrListName.add(HE GIVES ALL TO YOU...); /*lo_arrListName.add(new Integer(100)); lo_arrListName.add(new Integer(200)); lo_arrListName.add(new Integer(300)); */ int i = 0; System.out.println ( lo_arrListName.size()); while (ilo_arrListName.size() ) { System.out.println ( In the while loop. ); lo_oName = (Object[ ]) lo_arrListName.get(i); System.out.println (After storing the arraylist value in Object variable..); System.out.println (Value in object... + lo_oName[i].toString() ); i++; } } } - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! Try, lo_oName = (Object[ ]) lo_arrListName.toArray(); reg. s - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JNDI, DataSource, and ClassCastException
It looks like a ClassLoader issue. Casting the same class loaded by two different CLs causes a ClassCastException. Have you got the jar containing org.enhydra.jdbc.pool.StandardXAPoolDataSource in more than one place? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html HTH, Jon Marc Dugger wrote: I have a situation where I am attempting to downcast a DataSource resource into the exact class that getClass().getName() reports the object is, but it's causing a ClassCastException. -- server.xml: GlobalNamingResources Resource name=LoanAuditorDB auth=Container type=org.enhydra.jdbc.pool.StandardXAPoolDataSource/ ResourceParams name=LoanAuditorDB ...more /ResourceParams /GlobalNamingResources ...more Context path=/workbench docBase=C:\Code\loanauditor\src\webapp\workbench workDir=C:\Code\loanauditor\src\webapp\workbench\WEB-INF\work reloadable=true debug=0 ResourceLink name=jdbc/loanauditor global=LoanAuditorDB type=org.enhydra.jdbc.pool.StandardXAPoolDataSource/ ResourceLink name=jta/loanauditor global=UserTransaction type=javax.transaction.UserTransaction/ /Context -- web.xml resource-ref descriptionDB Connection/description res-ref-namejdbc/loanauditor/res-ref-name res-typeorg.enhydra.jdbc.pool.StandardXAPoolDataSource/res-type res-authContainer/res-auth /resource-ref -- constructor from abstract class, AbstractDAO.java: protected AbstractDAO() { try { Context ctx = new InitialContext(); Object o = ctx.lookup(java:comp/env/jdbc/loanauditor); log.debug(loanauditor from JNDI: + o.getClass().getName()); ds = (org.enhydra.jdbc.pool.StandardXAPoolDataSource) o; ds.setJdbcTestStmt(SELECT 1); } catch (NamingException ne) { log.fatal(ne.getMessage(), ne); throw new RuntimeException(ne); } } -- logging: 2003-12-04 05:25:39,157 [main] DEBUG com.socotech.loanauditor.dao.AbstractDAO - loanauditor from JNDI: org.enhydra.jdbc.pool.StandardXAPoolDataSource -- stacktrace: java.lang.ClassCastException at com.socotech.loanauditor.dao.AbstractDAO.init(AbstractDAO.java:31) at com.socotech.loanauditor.dao.TorqueDomainTypeDAO.init(TorqueDomainTypeDAO. java:34) at com.socotech.loanauditor.dao.TorqueDomainTypeDAO.getInstance(TorqueDomainTyp eDAO.java:29) at com.socotech.loanauditor.dao.DAOFactory.getDomainTypeDAO(DAOFactory.java:79) at com.socotech.loanauditor.web.listener.DomainTypeLoader.contextInitialized(Do mainTypeLoader.java:32) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java: 3271) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3613) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:754) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) Thanks in advance for any insight. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException
Hi I am using axis web services with the java cog kit, each web service is a application under tomcat. But when two applications wish to use the cog kit, ie the web service is invoked, the first web service works fine and the the second throws this stackTrace: java.lang.ClassCastException at org.globus.gsi.bc.BouncyCastleUtil.getIdentity(BouncyCastleUtil.java:387) at org.globus.gsi.bc.BouncyCastleUtil.getIdentity(BouncyCastleUtil.java:402) at org.globus.gsi.GlobusCredential.getIdentity(GlobusCredential.java:342) at org.globus.gsi.gssapi.GlobusGSSCredentialImpl.lt;initgt;(GlobusGSSCredenti alImpl.java:56) Now if i restart tomcat, and call the second web service first, it works fine, but then the original first web service when called throws the exception. It seems that two applications cannot load the cog kit under tomcat? Has anyone any ideas on what is happening??? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JNDI, DataSource, and ClassCastException
I have a situation where I am attempting to downcast a DataSource resource into the exact class that getClass().getName() reports the object is, but it's causing a ClassCastException. -- server.xml: GlobalNamingResources Resource name=LoanAuditorDB auth=Container type=org.enhydra.jdbc.pool.StandardXAPoolDataSource/ ResourceParams name=LoanAuditorDB ...more /ResourceParams /GlobalNamingResources ...more Context path=/workbench docBase=C:\Code\loanauditor\src\webapp\workbench workDir=C:\Code\loanauditor\src\webapp\workbench\WEB-INF\work reloadable=true debug=0 ResourceLink name=jdbc/loanauditor global=LoanAuditorDB type=org.enhydra.jdbc.pool.StandardXAPoolDataSource/ ResourceLink name=jta/loanauditor global=UserTransaction type=javax.transaction.UserTransaction/ /Context -- web.xml resource-ref descriptionDB Connection/description res-ref-namejdbc/loanauditor/res-ref-name res-typeorg.enhydra.jdbc.pool.StandardXAPoolDataSource/res-type res-authContainer/res-auth /resource-ref -- constructor from abstract class, AbstractDAO.java: protected AbstractDAO() { try { Context ctx = new InitialContext(); Object o = ctx.lookup(java:comp/env/jdbc/loanauditor); log.debug(loanauditor from JNDI: + o.getClass().getName()); ds = (org.enhydra.jdbc.pool.StandardXAPoolDataSource) o; ds.setJdbcTestStmt(SELECT 1); } catch (NamingException ne) { log.fatal(ne.getMessage(), ne); throw new RuntimeException(ne); } } -- logging: 2003-12-04 05:25:39,157 [main] DEBUG com.socotech.loanauditor.dao.AbstractDAO - loanauditor from JNDI: org.enhydra.jdbc.pool.StandardXAPoolDataSource -- stacktrace: java.lang.ClassCastException at com.socotech.loanauditor.dao.AbstractDAO.init(AbstractDAO.java:31) at com.socotech.loanauditor.dao.TorqueDomainTypeDAO.init(TorqueDomainTypeDAO. java:34) at com.socotech.loanauditor.dao.TorqueDomainTypeDAO.getInstance(TorqueDomainTyp eDAO.java:29) at com.socotech.loanauditor.dao.DAOFactory.getDomainTypeDAO(DAOFactory.java:79) at com.socotech.loanauditor.web.listener.DomainTypeLoader.contextInitialized(Do mainTypeLoader.java:32) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java: 3271) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3613) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:754) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:363) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2190) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) Thanks in advance for any insight. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException trying to access UserDatabase from example s web app
I got around my problem using reflection: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); java.lang.Object object = envCtx.lookup(userDatabase); // This throws ClassCastException System.out.println(Database id + ((UserDatabase)object).getId()); // This works java.lang.reflect.Method m = object.getClass().getMethod(getId, null); System.out.println(Database id + m.invoke(object, null)); But is this the best way? The comment in server.xml saying The database object could be accessed like this: suggests at least that the developer who wrote the comment expected the cast to work. -Original Message- From: Danielle Mortimer Sent: Tuesday, November 25, 2003 11:04 AM To: '[EMAIL PROTECTED]' Subject: ClassCastException trying to access UserDatabase from examples web app I am getting a ClassCastException when I try to access the global UserDatabase from a web app. I believe it is something to do with different class loaders but I'm not sure how to solve it. I noticed an old post on this same topic http://www.mail-archive.com/[EMAIL PROTECTED]/msg88967.html but there was no response. Details: 1. Out of the box Tomcat 4.1.29 install. Using Sun JDK 1.4.1_03. Windows 2000. 2. Modified server.xml to remove the comments around the ResourceLink in the examples context: !-- If you wanted the examples app to be able to edit the user database, you would uncomment the following entry. Of course, you would want to enable security on the application as well, so this is not done by default! The database object could be accessed like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); UserDatabase database = (UserDatabase) envCtx.lookup(userDatabase); -- ResourceLink name=userDatabase global=UserDatabase type=org.apache.catalina.UserDatabase/ 3. Created jakarta-tomcat-4.1.29\webapps\examples\test.jsp using the sample code from server.xml: %@ page import=javax.naming.* % %@ page import=org.apache.catalina.UserDatabase % html body % Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); java.lang.Object object = envCtx.lookup(userDatabase); out.write( Database id + ((UserDatabase)object).getId()); % /body /html 4. Copied UserDatabase.class from jakarta-tomcat-4.1.29\server\lib\catalina.jar into jakarta-tomcat-4.1.29\webapps\examples\WEB-INF\classes\org\apache\catalina\U serDatabase.class so the jsp will compile. 5. Restart Tomcat. 6. Go to http://localhost:8080/examples/test.jsp, browser displays exception: org.apache.jasper.JasperException at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2 54) ... root cause java.lang.ClassCastException at org.apache.jsp.test_jsp._jspService(test_jsp.java:51) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) ... Thanks in advance for any suggestions. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException trying to access UserDatabase from examples we b app
I am getting a ClassCastException when I try to access the global UserDatabase from a web app. I believe it is something to do with different class loaders but I'm not sure how to solve it. I noticed an old post on this same topic http://www.mail-archive.com/[EMAIL PROTECTED]/msg88967.html but there was no response. Details: 1. Out of the box Tomcat 4.1.29 install. Using Sun JDK 1.4.1_03. Windows 2000. 2. Modified server.xml to remove the comments around the ResourceLink in the examples context: !-- If you wanted the examples app to be able to edit the user database, you would uncomment the following entry. Of course, you would want to enable security on the application as well, so this is not done by default! The database object could be accessed like this: Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); UserDatabase database = (UserDatabase) envCtx.lookup(userDatabase); -- ResourceLink name=userDatabase global=UserDatabase type=org.apache.catalina.UserDatabase/ 3. Created jakarta-tomcat-4.1.29\webapps\examples\test.jsp using the sample code from server.xml: %@ page import=javax.naming.* % %@ page import=org.apache.catalina.UserDatabase % html body % Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); java.lang.Object object = envCtx.lookup(userDatabase); out.write( Database id + ((UserDatabase)object).getId()); % /body /html 4. Copied UserDatabase.class from jakarta-tomcat-4.1.29\server\lib\catalina.jar into jakarta-tomcat-4.1.29\webapps\examples\WEB-INF\classes\org\apache\catalina\U serDatabase.class so the jsp will compile. 5. Restart Tomcat. 6. Go to http://localhost:8080/examples/test.jsp, browser displays exception: org.apache.jasper.JasperException at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2 54) ... root cause java.lang.ClassCastException at org.apache.jsp.test_jsp._jspService(test_jsp.java:51) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) ... Thanks in advance for any suggestions. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException whilst extending Log4J Logger
Hi My scenario is that I am running a webapp consisting of JSP pages and Java classes. I have run this under WebSphere 5.x and Tomcat 4.1.x. I have overridden the Logger class in the same manner as in the Log4J example subclass/MyLogger.java. This allows per-thread logging levels to be altered at runtime. Log4J has been installed at the application server level, so that any web apps can use Log4J, as well as there being a default configuration for any default Logger created by any app. I have then configured my code to use my factory. The problem occurs if I restart the web application through the appropriate admin console on either app server. Upon starting up my classes have static fields for their logger, using my loggers overridden getInstance method which returns a Logger object which I then cast to my class (ThreadLogger). This works the first time it is called when the app server starts up and my webapp is started for the first time. But when the webapp is restarted, on calling getInstance the logger classes in particular where it retrieves the stored Logger from its static hash table in the repository, return my previous ThreadLogger object. But when I try to cast this to my ThreadLogger, it gives me a ClassCastException. I believe this is due to the fact that when a web app is restarted a new WebAppClassLoader (of what ever type dependant upon the app server) is created. So the Logger object returned after my webapp is restart was created by the first instance of the WebAppClassLoader, but it is being checked by a second instance of the WebAppClassLoader, which no longer thinks they are the same ThreadLogger class. To work around this problem under WebSphere I installed the Log4J installation under my WebApp, and changed the modules class loader order to PARENT_LAST so that it would use the Log4J instance in my webapp not the app server. This way everything (including the logger repository) is unloaded on restarting a webapp. I tried the same approach under Tomcat, but this does not appear to work, and it is continuing to use the Log4J installed and configured at the app server level, so I am unable to restart my webapp without restarting the appserver. What I am after is either a solution to how I can have Log4J installed at the app server level, but allow me to continue using, extended Loggers on a per-webapp basis. Or a recommendation on how Log4J should be installed which differs from how I have things setup. If it turns out to be a problem with Tomcat in someway, then I will post to their mailing list. Thanks for your help Tony - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat appears to cause erroneous ClassCastException (see message for circumstances)
I am using Tomcat 5 (I think) as a servlet and web service container via JWSDP 1.2. My OS is Windows XP Professional SP 2. I have written a centralized authentication service which uses a pluggable authentication module architecture. Each authentication module derives from an abstract base class com.inmezzo.authn.logon.Logon which is contained in a JAR file called inMezzo_AuthnLogon.jar, copied to common/lib. I supply a number of authentication modules (Win32, LDAP and others) with the service. These are in a package called com.inmezzo.authn.server and are contained in a WAR in webapps and they all work fine. However, the general pattern is that custom authentication modules will use a completely different package hierarchy and will be stored in their own JAR files in common/lib. This, however, causes problems. When my web app loads, the following code is executed (note that much of it is used simply to provide debug output for this post): String aClassName = m_props.getProperty(authenticator, com.inmezzo.authn.server.NullLogon); try { Class aClass = Class.forName(aClassName); System.out.println(Class is + aClass); System.out.println(Class package is + aClass.getPackage()); System.out.println(Classloader is + aClass.getClassLoader()); System.out.println(Superclass is + aClass.getSuperclass()); System.out.println(Superclass package is + aClass.getSuperclass().getPackage()); Object o = aClass.newInstance(); System.out.println(New object is + o); System.out.println(New object is a Logon object: + (o instanceof com.inmezzo.authn.logon.Logon)); System.out.flush(); m_authenticator = (com.inmezzo.authn.logon.Logon) o; // Boom! } catch(Exception e) { e.printStackTrace(); } When this code attempts to load a custom authenticator running under Tomcat, I get the following output: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is StandardClassLoader ... Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: false java.lang.ClassCastException at... When, however, I execute the same code from the command line, I get the output that I would expect: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is [EMAIL PROTECTED] Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: true Can anybody tell me what the problem is here? I don't think that I'm trying to do anything too perverse. Is there perhaps a configuration setting for Tomcat that will fix this? Alternatively, can anybody confirm whether it is worth my while to rewrite the abstract base class as an interface? I'm loath to do this only to find that it doesn't fix the problem. Thanks in advance for any light that you can shed on this matter, Chris Williams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat appears to cause erroneous ClassCastException (see message for circumstances)
Howdy, Are you putting the AuthnLogon jar in common/lib in order to use JAASRealm? Can you put this jar (and all others for your webapp) in the WEB-INF/lib directory instead? Another thing that might cause this is having two different versions of the abstract class, one in the common/lib and one in WEB-INF/lib. Could this be the case in your installation? Yoav Shapira Millennium ChemInformatics -Original Message- From: Christopher Williams [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 23, 2003 12:09 PM To: [EMAIL PROTECTED] Subject: Tomcat appears to cause erroneous ClassCastException (see message for circumstances) I am using Tomcat 5 (I think) as a servlet and web service container via JWSDP 1.2. My OS is Windows XP Professional SP 2. I have written a centralized authentication service which uses a pluggable authentication module architecture. Each authentication module derives from an abstract base class com.inmezzo.authn.logon.Logon which is contained in a JAR file called inMezzo_AuthnLogon.jar, copied to common/lib. I supply a number of authentication modules (Win32, LDAP and others) with the service. These are in a package called com.inmezzo.authn.server and are contained in a WAR in webapps and they all work fine. However, the general pattern is that custom authentication modules will use a completely different package hierarchy and will be stored in their own JAR files in common/lib. This, however, causes problems. When my web app loads, the following code is executed (note that much of it is used simply to provide debug output for this post): String aClassName = m_props.getProperty(authenticator, com.inmezzo.authn.server.NullLogon); try { Class aClass = Class.forName(aClassName); System.out.println(Class is + aClass); System.out.println(Class package is + aClass.getPackage()); System.out.println(Classloader is + aClass.getClassLoader()); System.out.println(Superclass is + aClass.getSuperclass()); System.out.println(Superclass package is + aClass.getSuperclass().getPackage()); Object o = aClass.newInstance(); System.out.println(New object is + o); System.out.println(New object is a Logon object: + (o instanceof com.inmezzo.authn.logon.Logon)); System.out.flush(); m_authenticator = (com.inmezzo.authn.logon.Logon) o; // Boom! } catch(Exception e) { e.printStackTrace(); } When this code attempts to load a custom authenticator running under Tomcat, I get the following output: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is StandardClassLoader ... Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: false java.lang.ClassCastException at... When, however, I execute the same code from the command line, I get the output that I would expect: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is [EMAIL PROTECTED] Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: true Can anybody tell me what the problem is here? I don't think that I'm trying to do anything too perverse. Is there perhaps a configuration setting for Tomcat that will fix this? Alternatively, can anybody confirm whether it is worth my while to rewrite the abstract base class as an interface? I'm loath to do this only to find that it doesn't fix the problem. Thanks in advance for any light that you can shed on this matter, Chris Williams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Follow on from ClassCastException question
I've implemented the logon architecture using an interface which all authenticator modules implement, so that the attempted cast now reads: m_authenticator = (ILogon) o; That still causes a ClassCastException. Bummer! Chris Williams. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat appears to cause erroneous ClassCastException (see message for circumstances)
You're partially correct thinking this is Tomcat, I believe. The cast exception can be caused when a class created by a different classloader is cast in the current one. In short, try specifying the webapp's classloader when you call Class.forName(). I believe the forName function defaults to the application classloader. Object o = aClass.newInstance(); System.out.println(New object is + o); System.out.println(New object is a Logon object: + (o instanceof com.inmezzo.authn.logon.Logon)); System.out.flush(); m_authenticator = (com.inmezzo.authn.logon.Logon) o; // Boom! On Tue, 2003-09-23 at 09:08, Christopher Williams wrote: I am using Tomcat 5 (I think) as a servlet and web service container via JWSDP 1.2. My OS is Windows XP Professional SP 2. I have written a centralized authentication service which uses a pluggable authentication module architecture. Each authentication module derives from an abstract base class com.inmezzo.authn.logon.Logon which is contained in a JAR file called inMezzo_AuthnLogon.jar, copied to common/lib. I supply a number of authentication modules (Win32, LDAP and others) with the service. These are in a package called com.inmezzo.authn.server and are contained in a WAR in webapps and they all work fine. However, the general pattern is that custom authentication modules will use a completely different package hierarchy and will be stored in their own JAR files in common/lib. This, however, causes problems. When my web app loads, the following code is executed (note that much of it is used simply to provide debug output for this post): String aClassName = m_props.getProperty(authenticator, com.inmezzo.authn.server.NullLogon); try { Class aClass = Class.forName(aClassName); System.out.println(Class is + aClass); System.out.println(Class package is + aClass.getPackage()); System.out.println(Classloader is + aClass.getClassLoader()); System.out.println(Superclass is + aClass.getSuperclass()); System.out.println(Superclass package is + aClass.getSuperclass().getPackage()); Object o = aClass.newInstance(); System.out.println(New object is + o); System.out.println(New object is a Logon object: + (o instanceof com.inmezzo.authn.logon.Logon)); System.out.flush(); m_authenticator = (com.inmezzo.authn.logon.Logon) o; // Boom! } catch(Exception e) { e.printStackTrace(); } When this code attempts to load a custom authenticator running under Tomcat, I get the following output: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is StandardClassLoader ... Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: false java.lang.ClassCastException at... When, however, I execute the same code from the command line, I get the output that I would expect: Class is class rdc.users.RIOLogon Class package is package rdc.users Classloader is [EMAIL PROTECTED] Superclass is class com.inmezzo.authn.logon.Logon Superclass package is package com.inmezzo.authn.logon New object is [EMAIL PROTECTED] New object is a Logon object: true Can anybody tell me what the problem is here? I don't think that I'm trying to do anything too perverse. Is there perhaps a configuration setting for Tomcat that will fix this? Alternatively, can anybody confirm whether it is worth my while to rewrite the abstract base class as an interface? I'm loath to do this only to find that it doesn't fix the problem. Thanks in advance for any light that you can shed on this matter, Chris Williams. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using ParameterMap throws ClassCastException
I am using the ParameterMap in request in an authentication mechanism. Therefore I need to do the following: add a mapping of parameters to the request.getParameter(). I do the following: import org.apache.catalina.util.ParameterMap; ... System.out.println(ParameterMap is a: + request.getParameterMap().getClass().getName()); try{ ParameterMap map = (ParameterMap)request.getParameterMap(); map.setLocked(false); map.putAll(values.getParameterMap()); map.setLocked(true); }catch(Exception e){ e.printStackTrace(); } This gives the following output: ParameterMap is a org.apache.catalina.util.ParameterMap And a ClassCastException in this line: ParameterMap map = (ParameterMap)request.getParameterMap(); So it seems that they reference to two different class-definitions, but I am using the same catalina.jar everywhere. (included it in the WEB-INF/lib dir) If I put catalina.jar in the WEB-INF/lib dir, then the above error is reported, else a ClassNotFoundException is thrown. I'm using tomcat-4.1 and found the class in the catalina.jar file. Where else is it? Thanks Morten Andersen Master of applied mathematics and computer science Research assistant (in e-learning) The Maersk Institute of Production technology at Southern Danish University www.mip.sdu.dk Campusvej 55 DK-5230 Odense M Denmark +45 6550-3654 +45 6171-1103 Jabber id: [EMAIL PROTECTED]
RE: Using ParameterMap throws ClassCastException
Howdy, Terrible idea. Don't use tomcat internal classes. Stick to the interface defined by the spec, whereby HttpServletRequest#getParameterMap returns an instance java.util.Map. Yoav Shapira Millennium ChemInformatics -Original Message- From: Morten Andersen [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 10:14 AM To: [EMAIL PROTECTED] Subject: Using ParameterMap throws ClassCastException I am using the ParameterMap in request in an authentication mechanism. Therefore I need to do the following: add a mapping of parameters to the request.getParameter(). I do the following: import org.apache.catalina.util.ParameterMap; ... System.out.println(ParameterMap is a: + request.getParameterMap().getClass().getName()); try{ ParameterMap map = (ParameterMap)request.getParameterMap(); map.setLocked(false); map.putAll(values.getParameterMap()); map.setLocked(true); }catch(Exception e){ e.printStackTrace(); } This gives the following output: ParameterMap is a org.apache.catalina.util.ParameterMap And a ClassCastException in this line: ParameterMap map = (ParameterMap)request.getParameterMap(); So it seems that they reference to two different class-definitions, but I am using the same catalina.jar everywhere. (included it in the WEB-INF/lib dir) If I put catalina.jar in the WEB-INF/lib dir, then the above error is reported, else a ClassNotFoundException is thrown. I'm using tomcat-4.1 and found the class in the catalina.jar file. Where else is it? Thanks Morten Andersen Master of applied mathematics and computer science Research assistant (in e-learning) The Maersk Institute of Production technology at Southern Danish University www.mip.sdu.dk Campusvej 55 DK-5230 Odense M Denmark +45 6550-3654 +45 6171-1103 Jabber id: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using jndi to get a DBCP BasicDataSource give ClassCastException
I did an I got BasicDataSource. --Angus -Original Message- From: Adam Hardy [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 4:19 AM To: Tomcat Users List Subject: Re: Using jndi to get a DBCP BasicDataSource give ClassCastException Hi Angus, looked at your first mail and couldn't see anything wrong with it. I can only suggest that you do some debugging, like output the .getClass().getName() from the datasource, to see what it really thinks it is. Adam On 09/04/2003 10:27 PM Angus Mezick wrote: Anyone have a clue as to whether or not this is a Real bug, or am I just screwing something up? -Original Message- From: Angus Mezick Sent: Wednesday, September 03, 2003 4:32 PM To: [EMAIL PROTECTED] Subject: Using jndi to get a DBCP BasicDataSource give ClassCastException I am having problems with the GlobalNamingResources. If I put my two DB resource entries into the GlobalNamingResources section and just use Resource-Links to access them I cannot cast from DataSource to BasicDataSource.. I need to do this to use this line in my monitoring app: (I can still use the Datasources to get talk to the DB, just not recast it from the interface to the concrete class) pageContext.getOut().println( jdbc/CommerceDB: Active: + ((BasicDataSource)ds).getNumActive() + Idle: + ((BasicDataSource)ds).getNumIdle() + br); If I define the resources directly in the Context everything works fine. ARGH! Here is my server.xml snippets: GlobalNamingResources Resource name=jdbc/SessionDBGlobal auth=Container type=javax.sql.DataSource/ Resource name=jdbc/CommerceDBGlobal auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SessionDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name valuejdbc:inetdae7a:IPADDR/value /parameter parameter namevalidationQuery/name valueselect top 1 name from syscolumns/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value6/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestWhileIdle/name valuetrue/value /parameter /ResourceParams ResourceParams name=jdbc/CommerceDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value
RE:CLASSLOADER(?) Using jndi to get a DBCP BasicDataSource give ClassCastException
Could this be a ClassLoader issue? Seems like it might be. Something about the difference between the server and context loaders? -Original Message- From: Angus Mezick Sent: Friday, September 05, 2003 8:31 AM To: Tomcat Users List Subject: RE: Using jndi to get a DBCP BasicDataSource give ClassCastException I did an I got BasicDataSource. --Angus -Original Message- From: Adam Hardy [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 4:19 AM To: Tomcat Users List Subject: Re: Using jndi to get a DBCP BasicDataSource give ClassCastException Hi Angus, looked at your first mail and couldn't see anything wrong with it. I can only suggest that you do some debugging, like output the .getClass().getName() from the datasource, to see what it really thinks it is. Adam On 09/04/2003 10:27 PM Angus Mezick wrote: Anyone have a clue as to whether or not this is a Real bug, or am I just screwing something up? -Original Message- From: Angus Mezick Sent: Wednesday, September 03, 2003 4:32 PM To: [EMAIL PROTECTED] Subject: Using jndi to get a DBCP BasicDataSource give ClassCastException I am having problems with the GlobalNamingResources. If I put my two DB resource entries into the GlobalNamingResources section and just use Resource-Links to access them I cannot cast from DataSource to BasicDataSource.. I need to do this to use this line in my monitoring app: (I can still use the Datasources to get talk to the DB, just not recast it from the interface to the concrete class) pageContext.getOut().println( jdbc/CommerceDB: Active: + ((BasicDataSource)ds).getNumActive() + Idle: + ((BasicDataSource)ds).getNumIdle() + br); If I define the resources directly in the Context everything works fine. ARGH! Here is my server.xml snippets: GlobalNamingResources Resource name=jdbc/SessionDBGlobal auth=Container type=javax.sql.DataSource/ Resource name=jdbc/CommerceDBGlobal auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SessionDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name valuejdbc:inetdae7a:IPADDR/value /parameter parameter namevalidationQuery/name valueselect top 1 name from syscolumns/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value6/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestWhileIdle/name valuetrue/value /parameter /ResourceParams ResourceParams name=jdbc/CommerceDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value
Re: Using jndi to get a DBCP BasicDataSource give ClassCastException
And that was with the GlobalResourceLinK That doesn't make sense! If you get BasicDataSource as the class's name, then you won't get a ClassCastException if you try to cast it to that, but you did, so er. wow, you've got me stumped. On 09/05/2003 02:31 PM Angus Mezick wrote: I did an I got BasicDataSource. --Angus -Original Message- From: Adam Hardy [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 4:19 AM To: Tomcat Users List Subject: Re: Using jndi to get a DBCP BasicDataSource give ClassCastException Hi Angus, looked at your first mail and couldn't see anything wrong with it. I can only suggest that you do some debugging, like output the .getClass().getName() from the datasource, to see what it really thinks it is. Adam On 09/04/2003 10:27 PM Angus Mezick wrote: Anyone have a clue as to whether or not this is a Real bug, or am I just screwing something up? -Original Message- From: Angus Mezick Sent: Wednesday, September 03, 2003 4:32 PM To: [EMAIL PROTECTED] Subject: Using jndi to get a DBCP BasicDataSource give ClassCastException I am having problems with the GlobalNamingResources. If I put my two DB resource entries into the GlobalNamingResources section and just use Resource-Links to access them I cannot cast from DataSource to BasicDataSource.. I need to do this to use this line in my monitoring app: (I can still use the Datasources to get talk to the DB, just not recast it from the interface to the concrete class) pageContext.getOut().println( jdbc/CommerceDB: Active: + ((BasicDataSource)ds).getNumActive() + Idle: + ((BasicDataSource)ds).getNumIdle() + br); If I define the resources directly in the Context everything works fine. ARGH! Here is my server.xml snippets: GlobalNamingResources Resource name=jdbc/SessionDBGlobal auth=Container type=javax.sql.DataSource/ Resource name=jdbc/CommerceDBGlobal auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SessionDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name valuejdbc:inetdae7a:IPADDR/value /parameter parameter namevalidationQuery/name valueselect top 1 name from syscolumns/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value6/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestWhileIdle/name valuetrue/value /parameter /ResourceParams ResourceParams name=jdbc/CommerceDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter
RE: Using jndi to get a DBCP BasicDataSource give ClassCastException
Anyone have a clue as to whether or not this is a Real bug, or am I just screwing something up? -Original Message- From: Angus Mezick Sent: Wednesday, September 03, 2003 4:32 PM To: [EMAIL PROTECTED] Subject: Using jndi to get a DBCP BasicDataSource give ClassCastException I am having problems with the GlobalNamingResources. If I put my two DB resource entries into the GlobalNamingResources section and just use Resource-Links to access them I cannot cast from DataSource to BasicDataSource.. I need to do this to use this line in my monitoring app: (I can still use the Datasources to get talk to the DB, just not recast it from the interface to the concrete class) pageContext.getOut().println( jdbc/CommerceDB: Active: + ((BasicDataSource)ds).getNumActive() + Idle: + ((BasicDataSource)ds).getNumIdle() + br); If I define the resources directly in the Context everything works fine. ARGH! Here is my server.xml snippets: GlobalNamingResources Resource name=jdbc/SessionDBGlobal auth=Container type=javax.sql.DataSource/ Resource name=jdbc/CommerceDBGlobal auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SessionDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name valuejdbc:inetdae7a:IPADDR/value /parameter parameter namevalidationQuery/name valueselect top 1 name from syscolumns/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value6/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestWhileIdle/name valuetrue/value /parameter /ResourceParams ResourceParams name=jdbc/CommerceDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter
Using jndi to get a DBCP BasicDataSource give ClassCastException
I am having problems with the GlobalNamingResources. If I put my two DB resource entries into the GlobalNamingResources section and just use Resource-Links to access them I cannot cast from DataSource to BasicDataSource.. I need to do this to use this line in my monitoring app: (I can still use the Datasources to get talk to the DB, just not recast it from the interface to the concrete class) pageContext.getOut().println( jdbc/CommerceDB: Active: + ((BasicDataSource)ds).getNumActive() + Idle: + ((BasicDataSource)ds).getNumIdle() + br); If I define the resources directly in the Context everything works fine. ARGH! Here is my server.xml snippets: GlobalNamingResources Resource name=jdbc/SessionDBGlobal auth=Container type=javax.sql.DataSource/ Resource name=jdbc/CommerceDBGlobal auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/SessionDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name valuejdbc:inetdae7a:IPADDR/value /parameter parameter namevalidationQuery/name valueselect top 1 name from syscolumns/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value300/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value6/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestWhileIdle/name valuetrue/value /parameter /ResourceParams ResourceParams name=jdbc/CommerceDBGlobal parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namemaxActive/name value100/value /parameter parameter namemaxIdle/name value5/value /parameter parameter namemaxWait/name value1/value /parameter parameter nameusername/name value/value /parameter parameter namepassword/name value/value /parameter parameter namedriverClassName/name valuecom.inet.tds.TdsDriver/value /parameter parameter nameurl/name
JDBC + MySQL Datasource + Tomcat = ClassCastException
Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoReconnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
Ok - implemented the getGeneratedKeys() method and everything works great. Thank you very much Mike! On another topic, is there any quick way to determine the total rows returned in a ResultSet without stepping through it. I want to build array's or objects and I need to know in advance what the array dimension will be. I could use lists, but I'd rather use array's. Here's what I came up with: ResultSet rs = ps.executeQuery(); rs.last(); int total = rs.getRow(); rs.beforeFirst(); When I get the resultset, I go to the last row, get its number, and then reset the resultset cursor back to before the first row. Is there already a method to give me this data? I looked but couldn't find any... Joe -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 1:05 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
I've also wished for this, but I think the 'last, grab, first' two-step is the only way to do this.. and of course, only with JDBC 3.0 Scrollable ResultSets (or maybe that was available back in JDBC2). The only other way I can think of is to construct a query exactly the same as the one you are running, except replace the SELECT clause with SELECT COUNT(*). Run this once, either before or after your 'real' query. Of course this isn't so great for cases where someone else inserts a dozen rows between your two queries. -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 4:10 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException Ok - implemented the getGeneratedKeys() method and everything works great. Thank you very much Mike! On another topic, is there any quick way to determine the total rows returned in a ResultSet without stepping through it. I want to build array's or objects and I need to know in advance what the array dimension will be. I could use lists, but I'd rather use array's. Here's what I came up with: ResultSet rs = ps.executeQuery(); rs.last(); int total = rs.getRow(); rs.beforeFirst(); When I get the resultset, I go to the last row, get its number, and then reset the resultset cursor back to before the first row. Is there already a method to give me this data? I looked but couldn't find any... Joe -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 1:05 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException
i solved problem with NoClassDefFoundError but i have other problem This program will use SimpleClassLoader. Load class : TestClass Not a system class. Load class : test.LocalModule Not a system class. Load class : java.lang.Object returning system class (in CLASSPATH). Returning newly loaded class. Returning newly loaded class. Load class : java.util.Vector returning system class (in CLASSPATH). Caught exception : java.lang.ClassCastException ## myjsp.jsp # SimpleClassLoader sc = new SimpleClassLoader(M:\\Java\\JSP Projects\\Ticker\\servlet4\\); Object o; String tst = TestClass; System.out.println(This program will use SimpleClassLoader.); try { Class cClass = sc.loadClass(tst); o= cClass.newInstance(); ///here ... throw cast exception ... in debuger i see that in o is instance of TestClass (TestClass is implented class of interface LocalModule) ((LocalModule)o).start(DF); } catch (Exception e) { System.out.println(Caught exception : +e); } # package test; public interface LocalModule { /* Start the module */ void start(String option); } # I'm using this classloader /** * Created by IntelliJ IDEA. * User: Alknaion * Date: 16.6.2003 * Time: 12:23:54 * To change this template use Options | File Templates. */ package test; import java.util.*; import java.io.*; public class SimpleClassLoader extends ClassLoader { private Hashtable classes = new Hashtable(); private String basePath; public SimpleClassLoader(String basePath) { this.basePath = basePath; } private byte[] getTypeFromBasePath(String typeName) { FileInputStream fis; String fileName = basePath + File.separatorChar + typeName.replace('.', File.separatorChar) + .class; try { fis = new FileInputStream(fileName); } catch (FileNotFoundException e) { return null; } BufferedInputStream bis = new BufferedInputStream(fis); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { int c = bis.read(); while (c != -1) { out.write(c); c = bis.read(); } } catch (IOException e) { return null; } return out.toByteArray(); } public Class loadClass(String className) throws ClassNotFoundException { return (loadClass(className, true)); } public synchronized Class loadClass(String className, boolean resolveIt) throws ClassNotFoundException { Class result; byte classData[]; System.out.println( Load class : +className); result = (Class)classes.get(className); if (result != null) { System.out.println( returning cached result.); return result; } try { result = super.findSystemClass(className); System.out.println( returning system class (in CLASSPATH).); return result; } catch (ClassNotFoundException e) { System.out.println( Not a system class.); } /* Try to load it from our repository */ classData = getTypeFromBasePath(className); if (classData == null) { throw new ClassNotFoundException(); } /* Define it (parse the class file) */ result = defineClass(className, classData, 0, classData.length); if (result == null) { throw new ClassFormatError(); } if (resolveIt) { resolveClass(result); } classes.put(className, result); System.out.println( Returning newly loaded class.); return result; } }
RE: ClassCastException
you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive. Charlie -Original Message- From: Anna [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2003 9:15 AM To: Tomcat Users List Subject: ClassCastException i solved problem with NoClassDefFoundError but i have other problem This program will use SimpleClassLoader. Load class : TestClass Not a system class. Load class : test.LocalModule Not a system class. Load class : java.lang.Object returning system class (in CLASSPATH). Returning newly loaded class. Returning newly loaded class. Load class : java.util.Vector returning system class (in CLASSPATH). Caught exception : java.lang.ClassCastException ## myjsp.jsp # SimpleClassLoader sc = new SimpleClassLoader(M:\\Java\\JSP Projects\\Ticker\\servlet4\\); Object o; String tst = TestClass; System.out.println(This program will use SimpleClassLoader.); try { Class cClass = sc.loadClass(tst); o= cClass.newInstance(); ///here ... throw cast exception ... in debuger i see that in o is instance of TestClass (TestClass is implented class of interface LocalModule) ((LocalModule)o).start(DF); } catch (Exception e) { System.out.println(Caught exception : +e); } # package test; public interface LocalModule { /* Start the module */ void start(String option); } # I'm using this classloader /** * Created by IntelliJ IDEA. * User: Alknaion * Date: 16.6.2003 * Time: 12:23:54 * To change this template use Options | File Templates. */ package test; import java.util.*; import java.io.*; public class SimpleClassLoader extends ClassLoader { private Hashtable classes = new Hashtable(); private String basePath; public SimpleClassLoader(String basePath) { this.basePath = basePath; } private byte[] getTypeFromBasePath(String typeName) { FileInputStream fis; String fileName = basePath + File.separatorChar + typeName.replace('.', File.separatorChar) + .class; try { fis = new FileInputStream(fileName); } catch (FileNotFoundException e) { return null; } BufferedInputStream bis = new BufferedInputStream(fis); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { int c = bis.read(); while (c != -1) { out.write(c); c = bis.read(); } } catch (IOException e) { return null; } return out.toByteArray(); } public Class loadClass(String className) throws ClassNotFoundException { return (loadClass(className, true)); } public synchronized Class loadClass(String className, boolean resolveIt) throws ClassNotFoundException { Class result; byte classData[]; System.out.println( Load class : +className); result = (Class)classes.get(className); if (result != null) { System.out.println( returning cached result.); return result; } try { result = super.findSystemClass(className); System.out.println( returning system class (in CLASSPATH).); return result; } catch (ClassNotFoundException e) { System.out.println( Not a system class.); } /* Try to load it from our repository */ classData = getTypeFromBasePath(className); if (classData == null) { throw new ClassNotFoundException(); } /* Define it (parse the class file) */ result = defineClass(className, classData, 0, classData.length); if (result == null) { throw new ClassFormatError(); } if (resolveIt) { resolveClass(result); } classes.put(className, result); System.out.println( Returning newly loaded class.); return result; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException
i need to do some kind of dynamic plugin managment ... i retrieve files from directory .. and extract names ... after that i use these names to load classes dynamicaly ... i catched article what did you post ... but i have some problems with this ... could you plz explain me how i can set my classloader's parent to the current classloader Anna you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive. Charlie
Re: ClassCastException
I've done a lot of dynamic class loading ... and have never needed to use a custom class loader ('cept one time when I stored them in a DB ... don't go there!). I would re-evaluate why you need a class loader rather than Class.forName( someClassName ).newInstance(). My gut feeling is, if you don't know all about class loaders, you don't need to use one (explicitly). My 2p tim Anna wrote: i need to do some kind of dynamic plugin managment ... i retrieve files from directory .. and extract names ... after that i use these names to load classes dynamicaly ... i catched article what did you post ... but i have some problems with this ... could you plz explain me how i can set my classloader's parent to the current classloader Anna you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException
you will probably want to review WebappClassLoader.java in the source. This is the web app's classloader and contains details of setting and delegating to the parent. Note that it does not use normal delegation - that is it looks up the class before delegating to the parent. Charlie -Original Message- From: Anna [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2003 11:25 AM To: Tomcat Users List Cc: [EMAIL PROTECTED] Subject: RE: ClassCastException i need to do some kind of dynamic plugin managment ... i retrieve files from directory .. and extract names ... after that i use these names to load classes dynamicaly ... i catched article what did you post ... but i have some problems with this ... could you plz explain me how i can set my classloader's parent to the current classloader Anna you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-h owto.html Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException
thx for your answer ... i want to load classes from directory which isn't in classpath of tomcat I've done a lot of dynamic class loading ... and have never needed to use a custom class loader ('cept one time when I stored them in a DB ... don't go there!). I would re-evaluate why you need a class loader rather than Class.forName( someClassName ).newInstance(). My gut feeling is, if you don't know all about class loaders, you don't need to use one (explicitly). My 2p tim
Re: ClassCastException
On Tue, 17 Jun 2003 01:08, Anna wrote: thx for your answer ... i want to load classes from directory which isn't in classpath of tomcat Is there any particular reason why you can't put your classes in WEB-INF/classes? As I understand it all you are doing is a portal style app with RSS feeds and using different classes to load the different feeds, is that right? The way you're doing it just seems overly complicated to me, although admit I've never done that in Java before but there has to be an easier way... Regards, -- Jason Bainbridge http://jblinux.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException
No ... the project from sourceforge i used only as sample ... i'm working on more complicated project Some kind of application framework which will use plugin managment to access some services i receive by tcp connector source (can by UNC path or url or Database) from which need to load class which server service if know how i can change class path of tomcat dynamicaly then it will be usefull but i think so stupid solution On Tue, 17 Jun 2003 01:08, Anna wrote: thx for your answer ... i want to load classes from directory which isn't in classpath of tomcat Is there any particular reason why you can't put your classes in WEB-INF/classes? As I understand it all you are doing is a portal style app with RSS feeds and using different classes to load the different feeds, is that right? The way you're doing it just seems overly complicated to me, although admit I've never done that in Java before but there has to be an easier way... Regards, -- Jason Bainbridge http://jblinux.org
Re: ClassCastException
From memory, Your ClassLoader has a constructor MyClassLoader() : 'inside' the constructor you call 'super( this.getClass().getClassLoader() )' - NB you can't actually do this as it involves doing stuff before the call to the super constructor, but the semantics are the same. Now you override the loadClass( name ) method and use the name to derive the bytestream you need (the Class definition). This will only be called if the current Class loading delegation model can't find the class. [That's the point at which I would load a blob ...] After that, 'ClassNotFoundException's are your problem ;-) tim Tim Shaw wrote: I've done a lot of dynamic class loading ... and have never needed to use a custom class loader ('cept one time when I stored them in a DB ... don't go there!). I would re-evaluate why you need a class loader rather than Class.forName( someClassName ).newInstance(). My gut feeling is, if you don't know all about class loaders, you don't need to use one (explicitly). My 2p tim Anna wrote: i need to do some kind of dynamic plugin managment ... i retrieve files from directory .. and extract names ... after that i use these names to load classes dynamicaly ... i catched article what did you post ... but i have some problems with this ... could you plz explain me how i can set my classloader's parent to the current classloader Anna you need to set your classloader's parent to the current classloader. Have you reviewed Tomcat's classloader document so that you understand how tomcat works before trying to load your own classes? http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html Is there a reason to do this as opposed to moving your classes into tomcat's WEB-INF directory? I wouldn't do this if you are just trying to avoid copying your files to tomcat's directory from your network drive. Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
classcastexception in bootstrap.jar though the jars are loaded
Hi, I'm unable to start Tomcat due to ClassNotFoundException. The classpath to bootstrap.jar and tools.jar is correct and defined. And the home directory too. All the jars are loaded, but still I get a classcastexception. Under what cirumstances could this occur? It there anything[system variables,classpath,etc] else that needs to be set? As seen below the classloader loads catalina.jar but throw an classnotfoundexception when its unable to locate org.apache.catalina.mbeans.ServerLifecycleListener which i contained in that jar. Regards, David ### Debug log ### Using CATALINA_BASE: E:\tomcat Using CATALINA_HOME: E:\tomcat Using CATALINA_TMPDIR: E:\tomcat\temp Using JAVA_HOME: E:\jdk1.4 _RUNJAVA: E:\jdk1.4\bin\java _EXECJAVA: start Tomcat E:\jdk1.4\bin\java JAVA_OPTS: CATALINA_OPTS: DEBUG_OPTS: JAVA_ENDORSED_DIRS: E:\tomcat\bin;E:\tomcat\common\endorsed CLASSPATH: E:\jdk1.4\lib\tools.jar;E:\tomcat\bin\bootstrap.jar CATALINA_BASE: E:\tomcat _RUNJAVA JAVA_OPTS CATALINA_OPTS DEBUG_OPTS -Djava.endorsed.dirs=JAVA_ENDORSED_DIRS -classpath CLASSPATH -Dcatalina.base=CATALINA_BASE -Dcatalina.home=CATALINA_HOME -Djava.io.tmpdir=CATALINA_TMPDIR MAINCLASS CMD_LINE_ARGS ACTION ClassLoaderFactory: Creating new class loader ClassLoaderFactory: Including directory E:\tomcat\common\classes ClassLoaderFactory: Including jar file E:\tomcat\common\endorsed\xercesImpl.jar ClassLoaderFactory: Including jar file E:\tomcat\common\endorsed\xmlParserAPIs.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\activation.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\ant.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\commons-collections.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\commons-dbcp.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\commons-logging-api.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\commons-pool.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\j2ee.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\jasper-compiler.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\jasper-runtime.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\jdbc2_0-stdext.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\jndi.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\jta.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\mail.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\naming-common.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\naming-factory.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\naming-resources.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\servlet.jar ClassLoaderFactory: Including jar file E:\tomcat\common\lib\tools.jar ClassLoaderFactory: Creating new class loader ClassLoaderFactory: Including directory E:\tomcat\server\classes ClassLoaderFactory: Including jar file E:\tomcat\server\lib\catalina-ant.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\catalina.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\commons-beanutils.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\commons-digester.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\commons-logging.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\commons-modeler.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\jaas.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\jakarta-regexp-1.2.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\mx4j-jmx.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\servlets-common.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\servlets-default.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\servlets-invoker.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\servlets-manager.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\servlets-webdav.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-coyote.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-http11.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-jk.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-jk2.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-util.jar ClassLoaderFactory: Including jar file E:\tomcat\server\lib\tomcat-warp.jar ClassLoaderFactory: Creating new class loader ClassLoaderFactory: Including directory E:\tomcat\shared\classes Bootstrap: Loading startup class Bootstrap: Setting startup class properties Bootstrap: Calling startup class process() method XmlMapper: Debug level: 999 XmlMapper: Validating = false XmlMapper: Set locator : [EMAIL PROTECTED] XmlMapper: new className org.apache.catalina.core.StandardServer Server StandardServer[8005] XmlMapper: setProperty(class org.apache.catalina.core.StandardServer className
ClassCastException
Dear All, I had an application, it was running fine. I decided to put it on a different computer. Both computers run Tomcat 4.0.1Now I recieve the following error message: root cause java.lang.ClassCastException: org.apache.crimson.jaxp.DocumentBuilderFactoryImpl at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:139) at org.apache.jasper.parser.ParserUtils.parseXMLDocument(ParserUtils.java:183) at org.apache.jasper.compiler.TldLocationsCache.processWebDotXml(TldLocationsCache.java:165) at org.apache.jasper.compiler.TldLocationsCache.(TldLocationsCache.java:138) at org.apache.jasper.EmbededServletOptions.(EmbededServletOptions.java:324) at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:266) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106) at java.lang.Thread.run(Thread.java:479) Can someone tell me what is missing? Best Regards, Yakov Belov
Tomcat4.1.18 and ClassCastException.
Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP. This is using a Object database called CacheDatabase. testclass = (ClassA)ClassA._open(dbconnection); The return type from open is of type ClassA. org.apache.jasper.JasperException: Unable to process TestTomcat Page at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2 48) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:530) at java.lang.Thread.run(Thread.java:484) Please help me on this as I have no idea why it shouldn't work. It works fine on Jrun4 which also implements the JSP/Servlet version. Thanks, Prasad. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat4.1.18 and ClassCastException.
Howdy, A few suggestions: - Could it be that ClassA is not in the classpath that the JSP is in? Then Jasper won't be able to find ClassA. - Have you looked at the servlet generated when your JSP is compiled? Can you precompile your JSP (use jspc) without errors? - Usually, underlined method names (_open in your example) indicate an internal-type method that external apps shouldn't be calling. Are you sure you're using ClassA properly? Yoav Shapira Millennium ChemInformatics -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:10 PM To: 'Tomcat Users List' Subject: Tomcat4.1.18 and ClassCastException. Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP. This is using a Object database called CacheDatabase. testclass = (ClassA)ClassA._open(dbconnection); The return type from open is of type ClassA. org.apache.jasper.JasperException: Unable to process TestTomcat Page at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.j ava: 2 48) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295 ) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic atio n FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil terC h ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal ve.j a va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal ve.j a va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:24 15) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav a:18 0 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV alve . java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav a:17 2 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve .jav a :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:4 32) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process Conn e ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:5 34) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo l.ja v a:530) at java.lang.Thread.run(Thread.java:484) Please help me on this as I have no idea why it shouldn't work. It works fine on Jrun4 which also implements the JSP/Servlet version. Thanks, Prasad. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat4.1.18 and ClassCastException.
Prasad, Is there more information under the exception information you have supplied labelled Root Cause: ? If so, this is the information we need to help. Can you post this additional information to the list if it's there please? Best regards, Andy -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: 11 February 2003 17:10 To: 'Tomcat Users List' Subject: Tomcat4.1.18 and ClassCastException. Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP. This is using a Object database called CacheDatabase. testclass = (ClassA)ClassA._open(dbconnection); The return type from open is of type ClassA. org.apache.jasper.JasperException: Unable to process TestTomcat Page at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrap per.java:2 48) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(A pplication FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati onFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp erValve.ja va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline. java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardConte xtValve.ja va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline. java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValv e.java:180 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispat cherValve. java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValv e.java:172 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline. java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngine Valve.java :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCon text.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline. java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.pr ocessConne ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thre adPool.jav a:530) at java.lang.Thread.run(Thread.java:484) Please help me on this as I have no idea why it shouldn't work. It works fine on Jrun4 which also implements the JSP/Servlet version. Thanks, Prasad. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat4.1.18 and ClassCastException.
This is the information under RootCause. javax.servlet.ServletException: Unable to process TestTomcat Page at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp l.java:530) at org.apache.jsp.testtomcat_jsp._jspService(testtomcat_jsp.java:71) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2 04) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:530) at java.lang.Thread.run(Thread.java:484) Thanks, Prasad. -Original Message- From: Andy Eastham [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:39 PM To: Tomcat Users List Subject: RE: Tomcat4.1.18 and ClassCastException. Prasad, Is there more information under the exception information you have supplied labelled Root Cause: ? If so, this is the information we need to help. Can you post this additional information to the list if it's there please? Best regards, Andy -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: 11 February 2003 17:10 To: 'Tomcat Users List' Subject: Tomcat4.1.18 and ClassCastException. Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP. This is using a Object database called CacheDatabase. testclass = (ClassA)ClassA._open(dbconnection); The return type from open is of type ClassA. org.apache.jasper.JasperException: Unable to process TestTomcat Page at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrap per.java:2 48) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241
RE: Tomcat4.1.18 and ClassCastException.
Howdy, What's in the tomcat logs? Yoav Shapira Millennium ChemInformatics -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:43 PM To: 'Tomcat Users List' Subject: RE: Tomcat4.1.18 and ClassCastException. This is the information under RootCause. javax.servlet.ServletException: Unable to process TestTomcat Page at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageConte xtIm p l.java:530) at org.apache.jsp.testtomcat_jsp._jspService(testtomcat_jsp.java:71) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.j ava: 2 04) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295 ) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic atio n FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil terC h ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal ve.j a va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal ve.j a va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:24 15) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav a:18 0 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV alve . java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav a:17 2 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve .jav a :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:4 32) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process Conn e ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:5 34) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo l.ja v a:530) at java.lang.Thread.run(Thread.java:484) Thanks, Prasad. -Original Message- From: Andy Eastham [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:39 PM To: Tomcat Users List Subject: RE: Tomcat4.1.18 and ClassCastException. Prasad, Is there more information under the exception information you have supplied labelled Root Cause: ? If so, this is the information we need to help. Can you post this additional information to the list if it's there please? Best regards, Andy -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: 11 February 2003 17:10 To: 'Tomcat Users List' Subject: Tomcat4.1.18 and ClassCastException. Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP. This is using a Object database called CacheDatabase. testclass = (ClassA)ClassA._open(dbconnection); The return type from open is of type ClassA. org.apache.jasper.JasperException: Unable to process TestTomcat Page
RE: Tomcat4.1.18 and ClassCastException.
Same as the one below. Thanks, Prasad. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:45 PM To: Tomcat Users List Subject: RE: Tomcat4.1.18 and ClassCastException. Howdy, What's in the tomcat logs? Yoav Shapira Millennium ChemInformatics -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:43 PM To: 'Tomcat Users List' Subject: RE: Tomcat4.1.18 and ClassCastException. This is the information under RootCause. javax.servlet.ServletException: Unable to process TestTomcat Page at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageConte xtIm p l.java:530) at org.apache.jsp.testtomcat_jsp._jspService(testtomcat_jsp.java:71) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.j ava: 2 04) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295 ) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic atio n FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil terC h ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal ve.j a va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal ve.j a va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:24 15) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav a:18 0 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV alve . java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav a:17 2 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve .jav a :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext. invo k eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java: 480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:4 32) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process Conn e ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:5 34) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo l.ja v a:530) at java.lang.Thread.run(Thread.java:484) Thanks, Prasad. -Original Message- From: Andy Eastham [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 12:39 PM To: Tomcat Users List Subject: RE: Tomcat4.1.18 and ClassCastException. Prasad, Is there more information under the exception information you have supplied labelled Root Cause: ? If so, this is the information we need to help. Can you post this additional information to the list if it's there please? Best regards, Andy -Original Message- From: Prasad Parigi [mailto:[EMAIL PROTECTED]] Sent: 11 February 2003 17:10 To: 'Tomcat Users List' Subject: Tomcat4.1.18 and ClassCastException. Hi, I am new to this mailing list and I get the following error while using Tomcat. I tried out all options to resolve this. Any help is appreciated. If this is not a proper way of communication, please let me know. I get an error ClassCastException when I try to use this line of code in my JSP
ClassCastException when pulling an object from ServletContext.
We have a development tomcat 3.3.1 final on a server that has Red Hat Linux release 7.1 (Seawolf) Kernel 2.4.2-2 on an i686. There are no problems here whatsoever when retrieving an object from the ServletContext and casting it to it's original type. On my machine running windows2000 and another server running the same both with tomcat 3.3.1. A ClassCastException occurs when trying to get any object from the ServerContext and cast it to it's actual type. One of the objects is a Connection Pool instance that allows us to get a connection object from the pool that it maintains. This throws a ClassCastException when getting a connection to logon. Our client is currently using tomcat 3.3.1 sothis restricts us at the moment. Things of interest to note: 1. This problem does not seem to happen on tomcat 4.4.10. 2. This does not happen on the Red Hat Linux machine. 3. The problem is resolved when all of the applications class files are run from a jar file in lib/apps instead of using class files in WEB-APPS/classes. If anybody can help with this problem it will be much appreciated. I would like to know what the problem is caused by and how to fix itbeforeconsideringupgrading to tomcat 4.1.12 as the fix. It will be good to know how to avoid this problem if in case it may arise in the future. Nathan. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
OK Re: ClassCastException Conn=dataSource.getConnection();
I see now. Thanks. My confusion was this in server.xml !-- Tomcat Root Context -- !-- Context path= docBase=ROOT debug=0/ -- so I had Context path= docBase=root debug=5 reloadable=true crossContext=true... instead of Context path=/root docBase=root debug=5 reloadable=true crossContext=true... and DataSource dataSource2=(DataSource)ctx.lookup(java:comp/env/jdbc/); instead of DataSource dataSource2=(DataSource)ctx.lookup(java:comp/env/jdbc/root); It's because jdbc is not a datasource, it's a container (or something similar. I have not the time to look it up). In your server.xml/web.xml files you should have a resource that's probably named jdbc/myConnection. Your code should read dataSource2=(DataSource)ctx.lookup( java:comp/env/jdbc/myConnection ); This of course is a guess. Without your config file, it's hard to tell. Sorry if this is a duplicate post, but I replied from the wrong account earlier. Andy -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: ClassCastException Conn=dataSource.getConnection();
It's because jdbc is not a datasource, it's a container (or something similar. I have not the time to look it up). In your server.xml/web.xml files you should have a resource that's probably named jdbc/myConnection. Your code should read dataSource2=(DataSource)ctx.lookup( java:comp/env/jdbc/myConnection ); This of course is a guess. Without your config file, it's hard to tell. Andy - Original Message - From: shawn [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Sunday, December 22, 2002 9:04 PM Subject: ClassCastException Conn=dataSource.getConnection(); I am getting a java.lang.ClassCastException from Connection conn = datasource.getConnection(); in the folowing: try { Context ctx = new InitialContext(); if(ctx == null ) {throw new Exception(Boom - No Context);} DataSource dataSource2=(DataSource)ctx.lookup(java:comp/env/jdbc/); if(dataSource2 == null ) {throw new Exception(Boom - No dataSource);} conn = dataSource2.getConnection(); } Why would that be? TIA Shawn PS the ds =null error I had earlier was due to not setting up my root context properly. That document base threw me off. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException Conn=dataSource.getConnection();
I am getting a java.lang.ClassCastException from Connection conn = datasource.getConnection(); in the folowing: try { Context ctx = new InitialContext(); if(ctx == null ) {throw new Exception(Boom - No Context);} DataSource dataSource2=(DataSource)ctx.lookup(java:comp/env/jdbc/); if(dataSource2 == null ) {throw new Exception(Boom - No dataSource);} conn = dataSource2.getConnection(); } Why would that be? TIA Shawn PS the ds =null error I had earlier was due to not setting up my root context properly. That document base threw me off. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: ClassCastException Conn=dataSource.getConnection();
It's because jdbc is not a datasource, it's a container (or something similar. I have not the time to look it up). In your server.xml/web.xml files you should have a resource that's probably named jdbc/myConnection. Your code should read dataSource2=(DataSource)ctx.lookup( java:comp/env/jdbc/myConnection ); This of course is a guess. Without your config file, it's hard to tell. Sorry if this is a duplicate post, but I replied from the wrong account earlier. Andy - Original Message - From: shawn [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Sunday, December 22, 2002 9:04 PM Subject: ClassCastException Conn=dataSource.getConnection(); I am getting a java.lang.ClassCastException from Connection conn = datasource.getConnection(); in the folowing: try { Context ctx = new InitialContext(); if(ctx == null ) {throw new Exception(Boom - No Context);} DataSource dataSource2=(DataSource)ctx.lookup(java:comp/env/jdbc/); if(dataSource2 == null ) {throw new Exception(Boom - No dataSource);} conn = dataSource2.getConnection(); } Why would that be? TIA Shawn PS the ds =null error I had earlier was due to not setting up my root context properly. That document base threw me off. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: ClassCastException when using BasicDataSource
Tuncay Baskan wrote: I'm trying to use a JNDI name for a JDBC resource. Configuration is as follows: Tomcat 4.0.3 DBCP 1.0 In the server.xml, I have the following DefaultContext entry. (It must be DefaultContext because there are 3 other webapps that use the same database) --= cut =-- parameter nameurl/name valuejdbc:mysql://quantranet:3306/eproject?autoReconnet=true/value /parameter May be this is not the problem you faced, but you have a typo here -- autoReconnet lacks last c letter. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException when using BasicDataSource
I'm trying to use a JNDI name for a JDBC resource. Configuration is as follows: Tomcat 4.0.3 DBCP 1.0 In the server.xml, I have the following DefaultContext entry. (It must be DefaultContext because there are 3 other webapps that use the same database) DefaultContext Resource auth=Container name=jdbc/eproject type=javax.sql.DataSource/ ResourceParams name=jdbc/eproject parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value/parameter parameter namevalidationQuery/name valueselect * from groups/value/parameter parameter namemaxWait/name value1/value/parameter parameter namemaxActive/name value100/value/parameter parameter nameusername/name valueusername/value/parameter parameter namepassword/name valuepassword/value/parameter parameter nameurl/name valuejdbc:mysql://quantranet:3306/eproject?autoReconnet=true/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value/parameter parameter namemaxIdle/name value30/value/parameter /ResourceParams /DefaultContext And in the web.xml: resource-ref id=ResourceRef_1039888737098 descriptionnone/description res-ref-namejdbc/eproject/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref I think there isn't a problem with JNDI. jndiContext.lookup() calls successfully return an object. It returns the correct object, which is BasicDataSource (a class that implements javax.sql.DataSource). I re-evaluated the code, so jndi.lookup() returns an object that has the name org.apache.commons.dbcp.BasicDataSource which implements the javax.sql.DataSource interface. But... I don't know how, I'm getting a ClassCastException when I cast it to DataSource to get a connection! (btw, returned object is not an instanceof javax.sql.DataSource, but getClass().getInterfaces() has javax.sql.DataSource) initContext = new InitialContext(); envContext = (Context)initContext.lookup(java:/comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/eproject); or, initContext = new InitialContext(); envContext = (DataSource)initContext.lookup (java:/comp/env/jdbc/eproject); fails on the lines which I'm trying to cast DataSource. So, how can it be? I really appreciate the one who can tell me why! PS: commons-collections, commons-dbcp, commons-pool is in %CATALINA_HOME%\common\lib along with mysql-connector and they are in .jar format as described in JNDI-Resources HOWTO. /tb.
RE: ClassCastException when using BasicDataSource
-Original Message- From: Tuncay Baskan (nternet Grubu) [mailto:[EMAIL PROTECTED]] Sent: Sunday, December 15, 2002 2:18 PM To: Tomcat Users List (E-mail) Subject: ClassCastException when using BasicDataSource I'm trying to use a JNDI name for a JDBC resource. Configuration is as follows: Tomcat 4.0.3 DBCP 1.0 In the server.xml, I have the following DefaultContext entry. (It must be DefaultContext because there are 3 other webapps that use the same database) DefaultContext Resource auth=Container name=jdbc/eproject type=javax.sql.DataSource/ ResourceParams name=jdbc/eproject parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namevalidationQuery/name valueselect * from groups/value/parameter parameter namemaxWait/name value1/value/parameter parameter namemaxActive/name value100/value/parameter parameter nameusername/name valueusername/value/parameter parameter namepassword/name valuepassword/value/parameter parameter nameurl/name valuejdbc:mysql://quantranet:3306/eproject?autoReconnet=true/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value/parameter parameter namemaxIdle/name value30/value/parameter /ResourceParams /DefaultContext And in the web.xml: resource-ref id=ResourceRef_1039888737098 descriptionnone/description res-ref-namejdbc/eproject/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref I think there isn't a problem with JNDI. jndiContext.lookup() calls successfully return an object. It returns the correct object, which is BasicDataSource (a class that implements javax.sql.DataSource). I re-evaluated the code, so jndi.lookup() returns an object that has the name org.apache.commons.dbcp.BasicDataSource which implements the javax.sql.DataSource interface. But... I don't know how, I'm getting a ClassCastException when I cast it to DataSource to get a connection! (btw, returned object is not an instanceof javax.sql.DataSource, but getClass().getInterfaces() has javax.sql.DataSource) initContext = new InitialContext(); envContext = (Context)initContext.lookup(java:/comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/eproject); or, initContext = new InitialContext(); envContext = (DataSource)initContext.lookup (java:/comp/env/jdbc/eproject); fails on the lines which I'm trying to cast DataSource. So, how can it be? I really appreciate the one who can tell me why! PS: commons-collections, commons-dbcp, commons-pool is in %CATALINA_HOME%\common\lib along with mysql-connector and they are in .jar format as described in JNDI-Resources HOWTO. /tb. Hmm.. I wasted one day to solve this problem. Actually, nothing solved, at least problem went away after upgrading to tomcat-4.0.6. I still wonder what caused to give ClassCastException. /tb.
Re: ClassCastException when using BasicDataSource
Unless you modifed things to use DBCP instead of Tyrex, Tomcat-4.0.3 is set up to use Tyrex. You can save yourself a lot of headache and simply upgrade to Tomcat-4.1.12. It officially uses DBCP instead of Tyrex for JNDI DataSource config and you won't be lost in the dark ages with a codebase that isn't being maintained other than security bugfixes. Jake At 02:18 PM 12/15/2002 +0200, you wrote: I'm trying to use a JNDI name for a JDBC resource. Configuration is as follows: Tomcat 4.0.3 DBCP 1.0 In the server.xml, I have the following DefaultContext entry. (It must be DefaultContext because there are 3 other webapps that use the same database) DefaultContext Resource auth=Container name=jdbc/eproject type=javax.sql.DataSource/ ResourceParams name=jdbc/eproject parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value/parameter parameter namevalidationQuery/name valueselect * from groups/value/parameter parameter namemaxWait/name value1/value/parameter parameter namemaxActive/name value100/value/parameter parameter nameusername/name valueusername/value/parameter parameter namepassword/name valuepassword/value/parameter parameter nameurl/name valuejdbc:mysql://quantranet:3306/eproject?autoReconnet=true/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value/parameter parameter namemaxIdle/name value30/value/parameter /ResourceParams /DefaultContext And in the web.xml: resource-ref id=ResourceRef_1039888737098 descriptionnone/description res-ref-namejdbc/eproject/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref I think there isn't a problem with JNDI. jndiContext.lookup() calls successfully return an object. It returns the correct object, which is BasicDataSource (a class that implements javax.sql.DataSource). I re-evaluated the code, so jndi.lookup() returns an object that has the name org.apache.commons.dbcp.BasicDataSource which implements the javax.sql.DataSource interface. But... I don't know how, I'm getting a ClassCastException when I cast it to DataSource to get a connection! (btw, returned object is not an instanceof javax.sql.DataSource, but getClass().getInterfaces() has javax.sql.DataSource) initContext = new InitialContext(); envContext = (Context)initContext.lookup(java:/comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/eproject); or, initContext = new InitialContext(); envContext = (DataSource)initContext.lookup (java:/comp/env/jdbc/eproject); fails on the lines which I'm trying to cast DataSource. So, how can it be? I really appreciate the one who can tell me why! PS: commons-collections, commons-dbcp, commons-pool is in %CATALINA_HOME%\common\lib along with mysql-connector and they are in .jar format as described in JNDI-Resources HOWTO. /tb.
ClassCastException when using BasicDataSource
I'm trying to use a JNDI name for a JDBC resource. Configuration is as follows: Tomcat 4.0.3 DBCP 1.0 In the server.xml, I have the following DefaultContext entry. (It must be DefaultContext because there are 3 other webapps that use the same database) DefaultContext Resource auth=Container name=jdbc/eproject type=javax.sql.DataSource/ ResourceParams name=jdbc/eproject parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value/parameter parameter namevalidationQuery/name valueselect * from groups/value/parameter parameter namemaxWait/name value1/value/parameter parameter namemaxActive/name value100/value/parameter parameter nameusername/name valueusername/value/parameter parameter namepassword/name valuepassword/value/parameter parameter nameurl/name valuejdbc:mysql://quantranet:3306/eproject?autoReconnet=true/value /parameter parameter namedriverClassName/name valueorg.gjt.mm.mysql.Driver/value/parameter parameter namemaxIdle/name value30/value/parameter /ResourceParams /DefaultContext And in the web.xml: resource-ref id=ResourceRef_1039888737098 descriptionnone/description res-ref-namejdbc/eproject/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref I think there isn't a problem with JNDI. jndiContext.lookup() calls successfully return an object. It returns the correct object, which is BasicDataSource (a class that implements javax.sql.DataSource). I re-evaluated the code, so jndi.lookup() returns an object that has the name org.apache.commons.dbcp.BasicDataSource which implements the javax.sql.DataSource interface. But... I don't know how, I'm getting a ClassCastException when I cast it to DataSource to get a connection! (btw, returned object is not an instanceof javax.sql.DataSource, but getClass().getInterfaces() has javax.sql.DataSource) initContext = new InitialContext(); envContext = (Context)initContext.lookup(java:/comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/eproject); or, initContext = new InitialContext(); envContext = (DataSource)initContext.lookup (java:/comp/env/jdbc/eproject); fails on the lines which I'm trying to cast DataSource. So, how can it be? I really appreciate the one who can tell me why! PS: commons-collections, commons-dbcp, commons-pool is in %CATALINA_HOME%\common\lib along with mysql-connector and they are in .jar format as described in JNDI-Resources HOWTO. /tb.
ClassCastException loading DataSource
Hi! I'm running into a ClassCastException loading jndi DataSources. I configured the resource in tomcats server.xml using the following entry (i do not mention web.xml because its working with oracle application server): Resource name=jdbc/OracleDS auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/OracleDS parameternameusername/namevaluescott/value/parameter parameternamepassword/namevaluetiger/value/parameter parameternamedriverClassName/namevalueoracle.jdbc.driver.OracleDriver/value/parameter parameternameurl/namevaluejdbc:oracle:thin:@dbdemo:1521:ORA/value/parameter /ResourceParams The Source for DataSource lookup is here: initCtx = new InitialContext(); envCtx = (Context) initCtx.lookup(java:comp/env); dataSource = (DataSource) envCtx.lookup(jdbc/OracleDS); con = dataSource.getConnection(); During runtime i get a ClassCastException when looking up the DataSource from the jndi context: java.lang.ClassCastException: tyrex.jdbc.xa.EnabledDataSource Do i have to specify the parameter factory in ResourceParams? If yes, which factory? Or is there something else wrong? Thanks in advance! Thomas Achleitner -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException when using Tomcat as RMI client
Hi, I am trying to use a Tomcat webapp as a RMI client. For the test purposes, my RMI server resides on the same machine. When I use a Tomcat webapp as a client, I consistently get a ClassCastException, while if I use a plain java class for the client, it works flawlessly. Following is my client code used in the servlet and the plain java class. System.setProperty(java.rmi.server.codebase, file:/path/to/stubfile/); try { //(line: 141) TestInterface testIf = (TestInterface) Naming.lookup(//localhost/Test); result = testIf.testMethod(); } catch (Exception e) { servlet.log(e.getMessage()); e.printStackTrace(); } I am using: JDK-1.4 tomcat-4.1.12 From the stack it looks like the stub file is located, but it cannot relate it with the interface file. java.lang.ClassCastException: Test_Stub at com.blah.blah.TestAction.perform(TestAction.java:141) at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1786) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1585) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:98) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533) at java.lang.Thread.run(Thread.java:536) Thanks in advance, Vishal __ Do you Yahoo!? Yahoo! Mail Plus Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException after reloading Context
Hi, We are experiencing a problem with Tomcat 4.0.4. We have a series of webapp that are working perfectely but this particular one will produce a ClassCastException after reloading its context with the Manager. Actually the Context is reloaded correctely but when we try to access a jsp page we get the ClassCastException. What is happening? I though that reloading the Context was the same thing as restarting Tomcat but for one webapp only. If there is any piece of code/configuration that I can send to help, please let me know. Thank you for your help, once again, Laurent -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Tomcat Manager App with Struts 1.1b2 - ClassCastException?
Subject: Tomcat Manager App with Struts 1.1b2 - ClassCastException? From: Andrej Sobkowski [EMAIL PROTECTED] === All, I'm using Struts 1.1b1 with Tomcat 4.0.4, using the manager app to dynamically stop/start my webapp. Everything works very well but I now need a few fixes from Struts 1.1b2 (note the '2'). I've therefore downloaded the b2 JAR files and copied them in my WEB-INF/lib directory (where they are supposed to be picked up by a separate class loader, if I'm not mistaken). When I re-deploy the webapp using the manager, I get a ClassCastException (reported below) from Tomcat. This doesn't happen if I restart the server (but I lose the dynamic deployment). I believe that it's a problem with the two versions of the struts.jar: one for the manager app and the new Struts 1.1b2 used by my webapp. Is this a known bug? Am I doing something wrong? Would migrating to 4.1.x solve the issue (I'll have to do it sometimes anyways)? Any help is appreciated. Thanks. Andrej PS. I haven't found an answer to this problem anywhere. Please send me a link to the solution message if I've missed it. java.lang.ClassCastException: org.apache.struts.action.RequestProcessor at org.apache.struts.action.ActionServlet.getRequestProcessor(ActionServlet.jav a:803) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java: 1027) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125 ) at java.lang.Thread.run(Thread.java:484) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException Error
Hi all, Having deployed Tomcat 4.0.4 in IIS 4.0 When I try to run a java bean program I get following error. * testbean.jsp ** html %@ page language=Java import=java.sql.* session=true % %@ page import=java.util.* % jsp:useBean id=pool scope=application class=connectionpool.ConnectionPool / % Connection con=null; out.println(enter 1); try { out.println(enter 2); //the pull is not initailized if(pool.getDriver()==null) { //initialize the pool pool.setDriver(sun.jdbc.odbc.JdbcOdbcDriver); pool.setURL(jdbc:odbc:oradsn); pool.setUsername(paytest); pool.setPassword(paytest); pool.setSize(5); pool.initializePool(); } //get a connection from the connection pool con = pool.getConnection(); out.println(connection is +con); //create the statement Statement statement1 =con.createStatement(); } catch (Exception e ) {System.out.println(CException : + e.getMessage()); } % * End Of testbean.jsp ** * ERROR ** Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error type Exception report message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception java.lang.ClassCastException: examples.connectionpool.ConnectionPool at org.apache.jsp.testbean$jsp._jspService(testbean$jsp.java:73) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:475) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:371) at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:424) at java.lang.Thread.run(Unknown Source) * END OF ERROR ** Thanks Regards Vishal -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException Error
Hi all, Having deployed Tomcat 4.0.4 in IIS 4.0 When I try to run a java bean program I get following error. * testbean.jsp ** html %@ page language=Java import=java.sql.* session=true % %@ page import=java.util.* % jsp:useBean id=pool scope=application class=connectionpool.ConnectionPool / % Connection con=null; out.println(enter 1); try { out.println(enter 2); //the pull is not initailized if(pool.getDriver()==null) { //initialize the pool pool.setDriver(sun.jdbc.odbc.JdbcOdbcDriver); pool.setURL(jdbc:odbc:oradsn); pool.setUsername(paytest); pool.setPassword(paytest); pool.setSize(5); pool.initializePool(); } //get a connection from the connection pool con = pool.getConnection(); out.println(connection is +con); //create the statement Statement statement1 =con.createStatement(); } catch (Exception e ) {System.out.println(CException : + e.getMessage()); } % * End Of testbean.jsp ** * ERROR ** Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error type Exception report message Internal Server Error description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request. exception java.lang.ClassCastException: examples.connectionpool.ConnectionPool at org.apache.jsp.testbean$jsp._jspService(testbean$jsp.java:73) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:475) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:371) at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:424) at java.lang.Thread.run(Unknown Source) * END OF ERROR ** Thanks Regards Vishal -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
ClassCastException when retrieving PostGres JDBC Connection from Tomcat 4.0.4 pool
I am running Tomcat 4.0.4 using the JNDI DataSource support to access a PostGres database. The following throws java.lang.ClassCastException: tyrex.jdbc.xa.EnabledDataSource Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/+ jndiName); return ds.getConnection(); When I build with tyrex-0.9.7.0.jar and change DataSource to EnabledDataSource, things work fine. Why do I get the exception and why does the fix work? Shouldn't the type of the resource returned match the type specification in server.xml and web.xml below? In server.xml: !-- Library Database connection pool -- Resource name=jdbc/libraryDB auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/libraryDB parameter nameuser/name valuelibuser/value /parameter parameter namepassword/name valueshould_not_be_clear_text/value /parameter parameter namedriverClassName/name valueorg.postgresql.Driver/value /parameter parameter namedriverName/name valuejdbc:postgresql://hanley/library/value /parameter /ResourceParams In web.xml: !-- Library DataSource Configuration -- resource-ref description Resource reference to a factory for java.sql.Connection instances used for connecting via JNDI to library database as configured in the server.xml file. /description res-ref-namejdbc/libraryDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref PostGres driver is in ${catalina.home}/common/lib -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Cant launch Tomcat4.1 : ClassCastException: sun.net.www.protocol.http.HttpURLConnection
Hi all, I'm trying to upgrade from Tomcat3.3 to Tomcat 4.1. When launching catalina, I get the following error: java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection at com.ibm.webdav.protocol.http.ResourceHTTPStub.setupRequest(ResourceHTTPStub.java:833) at com.ibm.webdav.protocol.http.ResourceHTTPStub.getProperties(ResourceHTTPStub.java:374) at com.ibm.webdav.Resource.getProperties(Resource.java:799) at com.ibm.webdav.Resource.getProperty(Resource.java:811) at com.ibm.webdav.Resource.isCollection(Resource.java:997) at com.ibm.webdav.ResourceFactory.create(ResourceFactory.java:111) at com.ibm.webdav.ResourceFactory.create(ResourceFactory.java:83) at webDAV.WebDAVManager.checkConnection(WebDAVManager.java:320) at webDAV.WebDAVManager.init(WebDAVManager.java:267) at webDAV.WebDAVManager.sharedInstance(WebDAVManager.java:305) at engine.managers.InitializationManager.initWebDAV(InitializationManager.java:836) at engine.managers.InitializationManager.initAll(InitializationManager.java:801) at servers.rmi.RMIInterfaceImpl.initDocSoul(RMIInterfaceImpl.java:1044) at userInterface.servlets.Servletinitializer.init(Servletinitializer.java:149) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:919) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:811) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3293) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3486) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1190) at org.apache.catalina.core.StandardHost.start(StandardHost.java:739) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1190) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:499) at org.apache.catalina.core.StandardServer.start(StandardServer.java:707) at org.apache.catalina.startup.Catalina.start(Catalina.java:504) at org.apache.catalina.startup.Catalina.execute(Catalina.java:399) at org.apache.catalina.startup.Catalina.process(Catalina.java:179) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) Does anybody know why? The same code worked prefectly under Tomcat3.3. I'm using the same jdk, same external jars. My first thought was that T4.1 was loading differently. I tried to force it to load my jars first but with no results ;-( Before this error, I get a parsing error but I don't think it is related. org.xml.sax.SAXParseException: The content of element type web-app must match (icon?,display-name?,description?,distributable?,context-param*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*). at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213) at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1851) at org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1495) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1204) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at org.apache.commons.digester.Digester.parse(Digester.java:1284) at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextConfig.java:282) at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:634) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:243) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3445) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1190) at org.apache.catalina.core.StandardHost.start(StandardHost.java:739) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1190) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:499) at org.apache.catalina.core.StandardServer.start(StandardServer.java:707) at org.apache.catalina.startup.Catalina.start(Catalina.java:504) at org.apache.catalina.startup.Catalina.execute(Catalina.java:399) at org.apache.catalina.startup.Catalina.process(Catalina.java:179) at
ClassCastException OraclePreparedStatement
Connection Pool configuration Context path=/NASApp docBase=NASApp reloadable=true Resource name=jdbc/pool auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/pool parameter nameuser/name valueDES/value /parameter parameter namepassword/name valueDES/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter namedriverName/name valuejdbc:oracle:oci8:MyUser/MyPass@MyDatabase/value /parameter /ResourceParams /Context Server.xml Jar with the driver TOMCAT\common\lib\classes12.jar Get a connection from the Connection Pool // Obtain our environment naming context javax.naming.Context initCtx = new InitialContext(); javax.naming.Context context = (Context) initCtx.lookup(java:comp/env); System.out.println(TRY CONNECT); javax.sql.DataSource ds = (javax.sql.DataSource)context.lookup(jdbc/pool); connection = ds.getConnection(); System.out.println(CONNECTED); Cast the PreparedStatement to OraclePreparedStatement import oracle.jdbc.driver.OraclePreparedStatement; (...) pstat = connection.getJDBCPreparedStatement(query); pstat.setFetchSize(fetchSize); System.out.println( pstat.getClass() + pstat.getClass() ); if(pstat instanceof oracle.jdbc.driver.OraclePreparedStatement) { System.out.println(Yes - STATprepOracle); } else { System.out.println(No - STATprepOracle); if(pstat instanceof oracle.jdbc.driver.OracleStatement) { System.out.println(Yes - STAToracle); } if(pstat instanceof java.sql.Statement) { System.out.println(Yes - STATsql); } if(pstat instanceof java.sql.PreparedStatement) { System.out.println(Yes - STATprepSql); } Class c = pstat.getClass(); System.out.println( c.getName(): + c.getName() ); System.out.println( c.getPackage(): + c.getPackage() ); System.out.println( c.getClassLoader(): + c.getClassLoader() ); } oracle.jdbc.driver.OraclePreparedStatement ostat = null; try { ostat = (oracle.jdbc.driver.OraclePreparedStatement) pstat; } catch (Throwable e) { e.printStackTrace(); } ostat.defineColumnType(CODIGOPERFIL_ROW, Types.VARCHAR); ostat.defineColumnType(TIPOERROCLO_ROW, Types.VARCHAR); Console output TRY CONNECT CONNECTED pstat.getClass()class oracle.jdbc.driver.OraclePreparedStatement No - STATprepOracle Yes - STATsql Yes - STATprepSql c.getName(): oracle.jdbc.driver.OraclePreparedStatement c.getPackage(): package oracle.jdbc.driver c.getClassLoader(): StandardClassLoader available: Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2] delegate: false repositories: file:D:\java\tomcat40\common\classes\ file:D:\java\tomcat40\common\lib\activation.jar file:D:\java\tomcat40\common\lib\classes12.jar file:D:\java\tomcat40\common\lib\crimson.jar file:D:\java\tomcat40\common\lib\jaxp.jar file:D:\java\tomcat40\common\lib\jdbc2_0-stdext.jar file:D:\java\tomcat40\common\lib\jta-spec1_0_1.jar file:D:\java\tomcat40\common\lib\ldap.jar file:D:\java\tomcat40\common\lib\mail.jar file:D:\java\tomcat40\common\lib\naming-common.jar file:D:\java\tomcat40\common\lib\naming-resources.jar file:D:\java\tomcat40\common\lib\servlet.jar file:D:\java\tomcat40\common\lib\tyrex-0.9.7.0.jar required: -- Parent Classloader: sun.misc.Launcher$AppClassLoader@71732b java.lang.ClassCastException: oracle.jdbc.driver.OraclePreparedStatement (...) at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Unknown Source) at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source) at org.apache.jasper.servlet.JspServlet.service(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source) at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source) at
RE: ClassCastException after ant build in getting object from ServletContext
I enountered the same problem, First, i put a hack with the reflect API (class Method, method invoke). In a second time , i found the problem : the javax.servlet package used is differerent when i compiled and when i run tomcat, so the signature of the class is not the same and this explain the Cast problem. Be sure that the jdbc2-ext.jar is take when you compile, normaly you are not oblige to declare in your CLASSPATH the jar of the jdbc provider. Olivier -Message d'origine- De: braswell [SMTP:[EMAIL PROTECTED]] Date: lundi 1 avril 2002 23:27 À:[EMAIL PROTECTED] Objet:ClassCastException after ant build in getting object from ServletContext Been working on a connection pool to make is to we do not need to bounce tomcat all the time. Initially we had it setup so tomcat would start and stop the connection pool when the server started. I have created an admin servlet that starts and stops the connection pool the same way starting and stopping tomcat did it... been getting a lot of class cast exceptions with the following call: dbPoolConnServlet obj =(dbPoolConnServlet) context.getAttribute(dbPoolConnServlet.KEY); i know for a fact that context.getAttribute(dbPoolConnServlet.KEY) returns a dbPoolConnServlet object because i have the following line of code before i do the cast ( i print out the object id and number) ie Object obja = context.getAttribute(dbPoolConnServlet.KEY); System.out.println(obj + obja); produces: obj dbPoolConnServlet@439a20 this indicates that obja is in-fact a dbPoolConnServlet and should cast without a problem... this is a strange error since i have not changed any code in going from tomcat starting the pool to this new servlet. I get this error after i do a ant build. IF i stop tomcat and restart -- then hit the servlet, there is not problem. IF i then do an ant build -- then hit the servlet It only appears to be a problem if it has been loaded in memory once. After a build, i get this error everytime... --error -- java.lang.ClassCastException: dbPoolConnServlet at tmplLogin.getConnectionPool_pcs(tmplLogin.java:392) -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
ClassCastException after ant build in getting object from ServletContext
Been working on a connection pool to make is to we do not need to bounce tomcat all the time. Initially we had it setup so tomcat would start and stop the connection pool when the server started. I have created an admin servlet that starts and stops the connection pool the same way starting and stopping tomcat did it... been getting a lot of class cast exceptions with the following call: dbPoolConnServlet obj =(dbPoolConnServlet) context.getAttribute(dbPoolConnServlet.KEY); i know for a fact that context.getAttribute(dbPoolConnServlet.KEY) returns a dbPoolConnServlet object because i have the following line of code before i do the cast ( i print out the object id and number) ie Object obja = context.getAttribute(dbPoolConnServlet.KEY); System.out.println(obj + obja); produces: obj dbPoolConnServlet@439a20 this indicates that obja is in-fact a dbPoolConnServlet and should cast without a problem... this is a strange error since i have not changed any code in going from tomcat starting the pool to this new servlet. I get this error after i do a ant build. IF i stop tomcat and restart -- then hit the servlet, there is not problem. IF i then do an ant build -- then hit the servlet It only appears to be a problem if it has been loaded in memory once. After a build, i get this error everytime... --error -- java.lang.ClassCastException: dbPoolConnServlet at tmplLogin.getConnectionPool_pcs(tmplLogin.java:392) -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
ClassCastException for JNI class loaded from common/lib
Hi, I would be keen to get help on an issue with using JNI classes from multiple webapps. I have 2 webapps both of which need to load a class which wraps JNI code. According to the release notes it is a good idea to place the code which loads the library (loadLibrary()) outside the webapps dir, so I put it in common/lib. When the first webapp attempts to instantiate the class, the native library is loaded apparently successfully, but the following code throws a ClassCastException myImpl = (myClass)Class.forName(name of class with JNI).newInstance(); However the confusing thing is that this works find when the class is installed in the webapps dir (webapps/WEB-INF/lib) (though the second webapp cannot load the library of course - cannot do 2 calls to loadLibrary). Has anyone done this before and if so could you please share with me the magic I need to do to make it work ? Thanks in advance, James -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
ClassCastException on javax.crypto.Cipher and Tomcat4.0.3
Hi, I have coded my security module using bouncycastle provider and clean-room jce implementation (jce-jdk13-111.jar). On standalone, the decrypt module seems to be working. When the code is integrated in the servlet and deployed on Tomcat-4.0.3, a ClassCastException is thrown: java.lang.ClassCastException: org.bouncycastle.jce.provider.JCERSACipher$NoPadding at javax.crypto.Cipher.getInstance(Cipher.java:121) ... I placed jce-jdk13-111.jar in webapps/WEB-INF/lib and tested, no luck. Tried in tomcat-home/common/lib and tested, same problem. also tried in tomcat-home/lib, tomcat-home/server/lib. It seems that this is more of a tomcat problem than a bouncycastle problem because it worked in stand alone when i placed jce-jdk13-111.jar in java-home/jre/lib/ext. Hope someone can help. Thanks. Regards, Allan __ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
EJB Realm - ClassCastException getting the EJBHome ref
Hi, I write my own Realm that connect to an EJB session bean to get the Principal. I have a probleme in my Realm class when i try to get a reference to the EJBHome class of my sessionBean class. I get a ClassCastException on the following line : LoginManagerHome homeLoginManager = (LoginManagerHome)javax.rmi.PortableRemoteObject.narrow(obj, LoginManagerHome.class); I have some difficult to find where it came from. Because the same EJB component well work when i called it from an jsp page. I put the client class files off my Beans and the EJB client class of my EJBServer in /tomcat/server/classes and /tomcat/server/lib My JNDI Context is well set and the connection to the EJB server work well. So i don't have any idear where does this CastException may come from. If any of you have a idea, it will be great. Thanks in advance for your help Nicolas PERIDONT -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
ClassCastException in tomcat4
Hello.. I have a problem with tomcat 4. My servlet application run's fine under jserv and tomcat 3.3 under tomcat4 receive a java.lang.ClassCastException deep in my startup process.. load classes with the classLoader.. try { System.out.println(loadClass:+clazz); Object o = Thread.currentThread().getContextClassLoader().loadClass(clazz).newInstance(); System.out.println(Instance:+o.toString()); de.SB.parser.hook.Section s = (de.SB.parser.hook.Section)o; } catch(Exception e) { System.out.println(e.toString()); } Here my STDOUT: loadClass:de.SB..parser.hook.Section Instance:de.SB.parser.hook.Section@62cb55 java.lang.ClassCastException: de.SB.parser.hook.Section a simple TypeCast.. I use under all versions (jserv,tomcat3.3,tomcat4) java version 1.3.1 Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24) Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode) Linux Kernal 2.4.10 I attempted also that: ClassLoader.getSystemClassLoader().loadClass(clazz).newInstance(); but the instance of Section is really ok I hope yours can help me rene -- _ never trust a klingon -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]