Exception with datasource connection..help me!!!

G

gbattine

Hi guys,
i've a question...
i've a jsf (1.1.0.1) application that works fine with Exadel Studio Pro
3.5.1.
Now i'm trying to update my Exadel to use version 4.0 that use Tomcat
5.5 instead of 5.0.
I use in my application Datasource inside Tomcat but with Exadel 4.0
when i run my application i have this exception...

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null'
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at giu.AuthenticationBean.login(AuthenticationBean.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
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.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(Unknown Source)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)
... 29 more



i have put mysql-connector-java-3.1.13-bin in tomcat/common/lib....what
have i do?
In my application i have a singleton class that creates connection
import javax.naming.Context;
import javax.naming.InitialContext;

public class Singleton {
private static Singleton singleton = null;

private static javax.sql.DataSource ds = null;


static {
try {
Context ctx = new InitialContext();
if (ctx == null) {
throw new Exception("No Context");
}
ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/MysqlJNDI");
} catch (Exception e) {
e.printStackTrace();
}

}

public static Singleton getInstance() {
if (singleton == null) {
singleton = new Singleton();
}
return singleton;
}

public javax.sql.DataSource getDataSource() {
return ds;
}



}



in my bean i use
DataSource dataSource = Singleton.getInstance().getDataSource();
conn = dataSource.getConnection();

to create connection
and this is my server.xml

<Context docBase="MicroArray" path="/MicroArray" reloadable="true"
source="org.eclipse.jst.j2ee.server:MicroArray">
<Resource name="MysqlJNDI" type="javax.sql.DataSource"/>


<ResourceParams name="MysqlJNDI">
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>shevagol</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/microarray</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</Context>

</Host>




this is my web.xml

<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>MySQL Test App</description>
<display-name>MicroArray</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>

<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MicroArray</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


it seems me strange...
please help me..
 
M

Manish Pandit

You might want to try configuring it like this:

<Resource name="jdbc/microarrayDB" auth="Container"
type="javax.sql.DataSource"
maxActive="4" maxIdle="2" maxWait="5000"
username="root" password="shevagol"
driverClassName="com.mysql.jdbc.Driver"

url="mysql://localhost:3306/microarray?autoReconnect=true"/>

-cheers,
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top