Question

I have a web application that works via eclipse (locally) but after I deploy it to the server with a war file the authentication does not work, I keep getting the failure page when I'm trying to login.

I see that the username and password exist in the database and a page that uses the database and shows the users list works.

In the server.xml I have this entry :

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>


    <Context docBase="aid" path="/aid" reloadable="true" source="org.eclipse.jst.jee.server:aid">
       <Realm allRolesMode="authOnly" className="org.apache.catalina.realm.JDBCRealm" connectionURL="jdbc:mysql://localhost:3306/aid?user=root&amp;password=root" driverName="com.mysql.jdbc.Driver" roleNameCol="Role" userCredCol="Password" userNameCol="Username" userRoleTable="ROLES" userTable="USERS"/>
    </Context>
  </Host>
  • Assume that the database's name is "aid" and the username and password are "root"
  • The app is deployed under /webapps/aid
  • The tomcat version is 7.0.26

My guess is that some how I missing a configuration for the tomcat authentication mechanism. Any ideas?

Update

This is the exception I'm getting:

SEVERE: Exception performing authentication java.sql.SQLException: com.mysql.jdbc.Driver at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:701) at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:352) at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:295) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:450) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:679)

Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:188) at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:697) ... 14 more

Était-ce utile?

La solution

It is indicating towards a possible classpath problem.

Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 

mysql-connector-java-3.1.14-bin.jar might be missing in the server classpath, while it is there in the eclipse.

Check build path in the eclipse and find out location of the jar. Then add the location/jar path-> specify it in shared.loader or common.loader property of /conf/catalina.properties.

You might want to read more about tomcat classpath issues/solution at http://www.mulesoft.com/tomcat-classpath

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top