Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

not able to run two site simultaneously in a tomcat websrever

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

we have purchasing 10 domain plesk server from webhosting company.
on that our 1st site is running successfully. After uploading 2nd site the problem arise.

We are using tomcat as application server , jdk1.6 and mysql 5.0 database.

while running both the site simultaneously it gives us class cast exception
Which ever site running 1st after restarting tomcat is working fine, the other site which we run second is not working it gives class cast exception.

Error :

rror in ConnectBean : java.lang.ClassCastException: com.mysql.jdbc.Connection cannot be cast to com.mysql.jdbc.Connection
java.lang.ClassCastException: com.mysql.jdbc.Connection cannot be cast to com.mysql.jdbc.Connection
at SaarthiBean.DB.SaarthiConnectBean.changeDB(
at SaarthiBean.DB.SaarthiConnectBean.changeDB(
at SaarthiBean.DB.SaarthiConnectBean.<init>(
at org.apache.jsp._1_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.jk.server.JkCoyoteHandler.invoke(
at org.apache.jk.common.HandlerRequest.invoke(
at org.apache.jk.common.ChannelSocket.invoke(
at org.apache.jk.common.ChannelSocket.processConnection(
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(
at org.apache.tomcat.util.threads.ThreadPool$

can any one tell me what is the reason of problem?
how we can solve it?

Posts: 43028
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Tomcat uses different classloaders to load the classes for each web app (or each individual site). I'll bet that you have more than one copy of the MySQL JDBC driver jar file, so those would be loaded by different classloaders, which makes them incompatible.

Try moving the jar file to a location that's shared by all web apps (and sites) on the Tomcat, like the TOMCAT_HOME/shared/lib or the TOMCAT_HOME/common/endorsed directory.
[ December 18, 2008: Message edited by: Ulf Dittmer ]
expectation is the root of all heartache - shakespeare. tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic