[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Need Urgent help!!!! JDBC Driver class not found: com.mysql.
srama1
do-not-reply at jboss.com
Thu Mar 13 01:05:13 EDT 2008
I am going nuts about this error, Please help me to resolve this error. I have browsed around for solutions, but I don't see any replies for the similar posted errors.
I have a simple servlet with hibernate code to upload the data to database.
Hibernate code alone works fine without server side code, but when I try to add the hibernate code to the servlet it throws me this error, that means it's an issue with the JBOSS server.
I am using the following in my eclipse:
eclipse 3.2
JBOSS server4.0.5
HibernateTools 3.2.5
mysql-connectorjava-5.0.8-bin.jar
STACK TRACE:
21:16:14,484 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
21:16:14,484 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
21:16:14,515 INFO [Configuration] Reading mappings from resource: subscription.hbm.xml
21:16:14,578 INFO [HbmBinder] Mapping class: com.corporate.wiki.SubscriptionBean -> subscription
21:16:14,593 INFO [Configuration] Configured SessionFactory: null
21:16:14,593 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
21:16:14,593 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 10
21:16:14,593 INFO [DriverManagerConnectionProvider] autocommit mode: false
21:16:14,593 FATAL [DriverManagerConnectionProvider] JDBC Driver class not found: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: No ClassLoaders found for: com.mysql.jdbc.Driver
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at com.corporate.wiki.WikiServlet.init(WikiServlet.java:22)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
21:16:14,593 ERROR [STDERR] org.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:66)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:397)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at com.corporate.wiki.WikiServlet.init(WikiServlet.java:22)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.mysql.jdbc.Driver
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:61)
... 24 more
21:16:14,609 ERROR [[WikiServlet]] Servlet.service() for servlet WikiServlet threw exception
java.lang.NullPointerException
at com.corporate.wiki.WikiServlet.doGet(WikiServlet.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)
21:16:40,765 INFO [DriverManagerConnectionProvider] cleaning up connection pool: null
Servlet code:
public class WikiServlet extends HttpServlet{
|
| SessionFactory sessionFactory;
| Session session = null;
|
| public void init(){
|
| try{
| // This step will read hibernate.cfg.xml and prepare hibernate for use
| sessionFactory = new Configuration().configure().buildSessionFactory();
| }catch(Exception e){
| e.printStackTrace();
| }
| }
|
| public void doGet(HttpServletRequest req, HttpServletResponse res)
| throws ServletException, IOException{
|
| String cmd = req.getParameter("cmd");
| session = sessionFactory.openSession();
|
| if ((cmd==null) || (cmd.length() <=0)){
| System.out.println("Inside if block");
| subscription(req, res, session);
| }
| }
|
| public void subscription(HttpServletRequest req, HttpServletResponse res, Session session)
| throws ServletException, IOException{
|
| try{
| String target = "/subscription.jsp";
|
| //use as url parameter later
| String userid = "1";
| String wikiid = "03";
|
| System.out.println("\nUSERID: "+userid +"\n"+"WIKIID: "+wikiid);
|
| SubscriptionBean subscribe = new SubscriptionBean(userid,wikiid);
| System.out.println("Instanciated bean");
| subscribe.print();
|
| //later change it to other code set
| HttpSession hsession=req.getSession(true);
| hsession.setAttribute("Subscription",subscribe);
|
| //Create new instance of Contact and set values in it by reading them from object
| System.out.println("Inserting Record to subscribe table");
|
| subscribe.setuser_id("10");
| subscribe.setwiki_page_id("39");
| subscribe.setsub_id(3);
|
| session.save(subscribe);
|
| System.out.println("Done");
| dispatch(req, res, target);
| }catch(Exception e){
| System.out.println(e.getMessage());
| }finally{
| // Actual contact insertion will happen at this step
| session.flush();
| session.close();
| }
| }
config file
<?xml version='1.0' encoding='utf-8'?>
| <!DOCTYPE hibernate-configuration PUBLIC
| "-//Hibernate/Hibernate Configuration DTD//EN"
| "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
|
| <hibernate-configuration>
| <session-factory>
| <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
| <property name="hibernate.connection.url">jdbc:mysql://localhost/COWS</property>
| <property name="hibernate.connection.username">root</property>
| <property name="hibernate.connection.password"></property>
| <property name="hibernate.connection.pool_size">10</property>
| <property name="show_sql">true</property>
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="hibernate.hbm2ddl.auto">update</property>
| <!-- Mapping files -->
| <mapping resource="subscription.hbm.xml"/>
| </session-factory>
| </hibernate-configuration>
Mapping file
| <hibernate-mapping>
| <class name="com.corporate.wiki.SubscriptionBean" table="subscription">
| <id name="sub_id" column="SUB_ID">
| <generator class="assigned"/>
| </id>
| <property name="user_id">
| <column name="USER_ID" />
| </property>
| <property name="wiki_page_id">
| <column name="WIKI_PAGE_ID"/>
| </property>
| </class>
| </hibernate-mapping>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136169#4136169
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136169
More information about the jboss-user
mailing list