tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Eriksson" <Dan.Eriks...@springmobil.se>
Subject tomcat not able to connect to postgresql?
Date Thu, 10 Apr 2008 02:15:08 GMT
Hi list!

I am trying to configure apache + tomcat using mod_jk on different machines with virtual hosts,
i.e one frontend running apache (2.2.3-4+etch4), one backend running tomcat 6 (binary apache-tomcat-6.0.16)
with postgresql (postgresql-8.1, 8.1.11-0etch1) on debian etch.

My virtual host is called myapp.mydomain.com.

The problem is that when I am using context in my virtual host config for tomcat I receive
the following in my logfile, catalina.out,

javax.naming.NamingException: Cannot create resource instance
        at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at se.springmobil.groupadmin.servlets.ControlServlet.init(ControlServlet.java:86)
        at javax.servlet.GenericServlet.init(GenericServlet.java:212)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
ContextListener: attributeAdded('com.sun.faces.ApplicationAssociate', 'com.sun.faces.application.ApplicationAssociate@ecb67f')

If I try to connect to my vhost now everything looks ok, no errors anywhere, but when I try
to login I get a message that the database is not online and in my logfile I see this:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for
connect UR
L 'null'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at se.springmobil.groupadmin.servlets.ControlServlet.createManagementSession(ControlServlet.
java:496)
        at se.springmobil.groupadmin.servlets.ControlServlet.processRequest(ControlServlet.java:178)
        at se.springmobil.groupadmin.servlets.ControlServlet.doGet(ControlServlet.java:444)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
        at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
        at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
        at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
        at java.sql.DriverManager.getDriver(DriverManager.java:253)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
        ... 23 more

My server.xml looks like this:

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <GlobalNamingResources>
    <Environment
              description=""
              name="configdir"
              type="java.lang.String"
              value="/etc/myapp"/>
    <Environment
              description=""
              name="ior_file"
              type="java.lang.String"
              value="/etc/myapp/direct.ior"/>
    <Resource
              name="jdbc/springmobil_db"
              type="javax.sql.DataSource"
              password="mypasswd"
              driverClassName="org.postgresql.Driver"
              maxIdle="2"
              maxWait="5000"
              validationQuery="SELECT 1"
              username="myapp"
              url="jdbc:postgresql://10.10.120.80/myapp_db"
              maxActive="4"/>
    <Resource
              auth="Container"
              description="User database that can be updated and saved"
              name="UserDatabase"
              type="org.apache.catalina.UserDatabase"
              pathname="conf/tomcat-users.xml"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
  </GlobalNamingResources>

  <Service name="Catalina">
        <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

   <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

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

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
      </Host>

      <Host name="myapp.mydomain.com" appBase="webapps/myapp"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="" debug="0" reloadable="true"/>

        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="vaxeladmin_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
      </Host>

    </Engine>
  </Service>
</Server>

If I remove the row,
<Context path="" docBase="" debug="0" reloadable="true"/>
from myapp.mydomain.com vhost I get the following error in catalina.out,

Apr 10, 2008 4:06:34 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 806 ms
Apr 10, 2008 4:06:34 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 10, 2008 4:06:34 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
Apr 10, 2008 4:06:35 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /usr/local/tomcat/webapps/myapp/myapp does
not exist or is not a readable directory
        at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Apr 10, 2008 4:06:35 AM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Apr 10, 2008 4:06:35 AM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
Apr 10, 2008 4:06:35 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/acdadmin] startup failed due to previous errors
Apr 10, 2008 4:06:35 AM org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[myapp.mydomain.com].[/myapp]
has not been started
Apr 10, 2008 4:06:37 AM org.apache.catalina.startup.ContextConfig validateSecurityRoles
Apr 10, 2008 4:06:38 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for this context. The
duplicate definition has been ignored.
Apr 10, 2008 4:06:38 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for this context. The
duplicate definition has been ignored.
ContextListener: attributeAdded('com.sun.faces.ApplicationAssociate', 'com.sun.faces.application.ApplicationAssociate@1de45e2')
Apr 10, 2008 4:06:38 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Apr 10, 2008 4:06:38 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Apr 10, 2008 4:06:38 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Apr 10, 2008 4:06:38 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/45  config=null
Apr 10, 2008 4:06:38 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4156 ms

It says that it cant find webapps/myapp/myapp, but I have only specified it once, what I can
see.
What am I doing wrong here?

If I remove webapps/myapp from my vhost config, and just put "webapps" there I get the standard
default tomcat web page, which is not good enough :)

I am using the same jsp-files for database connection, and the same app, on another server
(dev), and it works.
The only difference is that I only have one vhost, the default localhost, on that server.

Have anyone else had this problem?

Thanks in advance!

Best regards,
Dan

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message