I am using the Persistent Manager Implementation on the tomcat server with a JDBC Store, Which stores the session data in the DB table instead of storing in tomcat. I Configured my context.xml file like shown below for my oracle DB.

<Valve className="org.apache.catalina.valves.PersistentValve" />

        <Resource name="jdbc/mydb" type="javax.sql.DataSource"
        maxActive="50" maxIdle="20" maxWait="5000" validationQuery="select 1 from dual"
        removeAbandoned="true" logAbandoned="true" driverClassName="oracle.jdbc.driver.OracleDriver"
        username="myusername" password="mypassword"
        url="jdbc:oracle:thin:@192.168.1.63:1521/orcl" />

    <Manager className="org.apache.catalina.session.PersistentManager"
        distributable="true"  processExpiresFrequency="3" maxIdleBackup="1" saveOnRestart='false'>
        <Store className="org.apache.catalina.session.JDBCStore"
            dataSourceName="jdbc/mydb"
            sessionAppCol="app_name" sessionDataCol="session_data" sessionIdCol="session_id"
            sessionLastAccessedCol="last_access" sessionMaxInactiveCol="max_inactive"
            sessionTable="tomcat_sessions" sessionValidCol="valid_session" />
    </Manager>

The session data is storing in DB table as excepted. But now i want to do the same for my MySQL DB and I configured in the same way which i did for Oracle DB. Only made required changes for MySQL in the Resource as shown below. But it is throwing NullPointerException.

<Resource name="jdbc/mydb" type="javax.sql.DataSource"
                        maxActive="150" maxIdle="100" maxWait="5000" validationQuery="select 1"
                        removeAbandoned="true" logAbandoned="true" driverClassName="com.mysql.jdbc.Driver"
                        username="myusername" password="mypassword"
                        url="jdbc:mysql://192.168.1.205:2222/mydbname" />   

Stack Trace:

 SEVERE: Error manager.start()
    java.lang.NullPointerException
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:195)
            at org.apache.catalina.session.JDBCStore.open(JDBCStore.java:861)
            at org.apache.catalina.session.JDBCStore.getConnection(JDBCStore.java:833)
            at org.apache.catalina.session.JDBCStore.start(JDBCStore.java:968)
            at org.apache.catalina.session.PersistentManagerBase.start(PersistentManagerBase.java:995)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4714)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
            at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
            at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
            at org.apache.catalina.core.StandardService.start(StandardService.java:525)
            at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:606)
            at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

    May 12, 2019 2:32:07 PM org.apache.catalina.core.StandardContext start
    SEVERE: Context [] startup failed due to previous errors
    May 12, 2019 2:32:07 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8090
    May 12, 2019 2:32:07 PM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8011
    May 12, 2019 2:32:07 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/22  config=null
    May 12, 2019 2:32:07 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 262912 ms
    Exception in thread "Quartz Scheduler [SCHEDULERS]" May 12, 2019 2:33:58 PM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load org.quartz.utils.ExceptionHelper.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
            at org.quartz.SchedulerException.getUnderlyingException(SchedulerException.java:169)
            at org.quartz.SchedulerException.toString(SchedulerException.java:265)
            at java.lang.String.valueOf(String.java:2849)
            at java.lang.StringBuilder.append(StringBuilder.java:128)
            at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
            at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:74)
            at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
            at java.lang.Throwable.toString(Throwable.java:480)
            at java.lang.String.valueOf(String.java:2849)
            at java.io.PrintStream.println(PrintStream.java:821)
            at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:242)
            at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748)
            at java.lang.Throwable.printStackTrace(Throwable.java:655)
            at java.lang.Throwable.printStackTrace(Throwable.java:643)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1061)
            at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052)
            at java.lang.Thread.dispatchUncaughtException(Thread.java:1986)


    Exception: java.lang.NoClassDefFoundError thrown from the UncaughtExceptionHandler in thread "Quartz Scheduler [SCHEDULERS]"
    Exception in thread "Quartz Scheduler [SCHEDULERS]"
    Exception: java.lang.NoClassDefFoundError thrown from the UncaughtExceptionHandler in thread "Quartz Scheduler [SCHEDULERS]"

0 Answers