Results 1 to 6 of 6

Thread: tcServer tries to start datasource with empty properties

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Location
    Santa Fe, NM
    Posts
    15

    Default tcServer tries to start datasource with empty properties

    This is puzzling, and is only an issue on tcServer. We were running Tomcat before and do not see this error. When tcServer starts this application, it appears it attempts to register a couple of datasources under a JMX naming context. But there are no datasources defined in context.xml for this app, only in Spring (and Hibernate) contexts. I would expect these to remain inside the app, not be accessible from the container (as happens with Tomcat).

    Here's the error I get on startup. The app, however, starts up fine after this and DB access works correctly. But it's very disconcerting to see all these errors at startup. I've run this through a debugger and everything in the PoolConfiguration object is null (including driverclass name which causes the NPE) except for "name" which is "Tomcat Connection Pool[1-16115732]". Any ideas?

    Code:
    22-Jan-2013 15:47:44.855 WARNING [localhost-startStop-1] org.apache.catalina.core.NamingContextListener.addResource Failed to register in JMX: javax.naming.NamingException
    22-Jan-2013 15:47:44.857 WARNING [localhost-startStop-1] org.apache.naming.NamingContext.lookup Unexpected exception resolving reference
     java.sql.SQLException
            at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
            at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:631)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:485)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143)
            at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
            at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
            at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:539)
            at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:237)
            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:843)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
            at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1061)
            at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:671)
            at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:270)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
            at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:968)
            at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1646)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.NullPointerException
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:247)
            at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
            ... 33 more
    
    22-Jan-2013 15:47:44.857 WARNING [localhost-startStop-1] org.apache.catalina.core.NamingContextListener.addResource Failed to register in JMX: javax.naming.NamingException

  2. #2
    Join Date
    Oct 2008
    Location
    Melbourne, Florida
    Posts
    83

    Default

    elbulla,

    Can you attach the server.xml and context.xml so we can get a better idea of your configuration? Also what version of tc Server are you using? What tc Runtime are you using 6 or 7?

    The difference you are seeing is that in tc Server the default connection pooling is tomcat-jdbc, in Apache Tomcat it is using dbcp by default.

    But, why would you have datasource defined without having the all the attributes configured?

  3. #3
    Join Date
    Jul 2008
    Location
    Santa Fe, NM
    Posts
    15

    Default

    I don't have a datasource defined at all at the server level. Somehow tcServer is picking up what's in a spring configuration and trying to make one. My server.xml is just the default plus one additional port for SSL. Context.xml has a few entries for CAS authentication and communication with another app, but no datasources.
    I can see while debugging that the name of the datasource it tries to register in JMX (there's 2 actually) are the database names used in my spring configurations. I thought at first it was picking them up from the context file of another tcServer instance under the same root (that one does have datasources defined in context.xml), but I deleted that instance altogether and still get the same behavior.

    Here's what I have defined in spring context:
    Code:
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${db.informix.driver}"/>
            <property name="url" value="${db.informix.dburl}"/>
            <property name="username" value="${db.informix.dbuser}"/>
            <property name="password" value="${db.informix.dbpassword}"/>
            <property name="testWhileIdle" value="true"/>
            <property name="validationQuery" value="select first 1 1 from systables"/>
            <property name="removeAbandoned" value="true"/>
            <property name="removeAbandonedTimeout" value="60"/>
            <property name="logAbandoned" value="true"/>
        </bean>
    
        <bean id="dataSourceRpt" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${db2.informix.driver}"/>
            <property name="url" value="${db2.informix.dburl}"/>
            <property name="username" value="${db.informix.dbuser}"/>
            <property name="password" value="${db.informix.dbpassword}"/>
            <property name="testWhileIdle" value="true"/>
            <property name="validationQuery" value="select first 1 1 from systables"/>
            <property name="removeAbandoned" value="true"/>
            <property name="removeAbandonedTimeout" value="60"/>
            <property name="logAbandoned" value="true"/>
        </bean>
    Context.xml
    Code:
    <?xml version="1.0"?>
    <Context>
        <!-- Default set of monitored resources -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <!-- Uncomment this to disable session persistence across Tomcat restarts -->
        <!--
            <Manager pathname="" />
            -->
        <!-- Uncomment this to enable Comet connection tacking (provides events
                 on session expiration as well as webapp lifecycle) -->
        <!--
            <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
            -->
    
        <!-- CAS server -->
        <Environment description="" name="cas/serverName" override="false" type="java.lang.String" value="http://alexq.docmain.state.nm.us:8081"/>
    
        <Environment description="" name="cas/AuthenticationFilter/casServerLoginUrl" override="false" type="java.lang.String" value="https://nmtcs3.docmain.state.nm.us:8443/cmisCAS/login"/>
    
        <Environment description="" name="cas/casServerUrlPrefix" override="false" type="java.lang.String" value="https://nmtcs3.docmain.state.nm.us:8443/cmisCAS"/>
    
        <Environment description="" name="cas/Saml11TicketValidationFilter/exceptionOnValidationFailure" override="false" type="java.lang.String" value="false"/>
    
        <!--
            <Environment description="" name="cas/AuthenticationFilter/casServerLoginUrl" override="false" type="java.lang.String" value="https://alexq.docmain.state.nm.us:8445/cmisCAS/login"/>
    
            <Environment description="" name="cas/casServerUrlPrefix" override="false" type="java.lang.String" value="https://alexq.docmain.state.nm.us:8445/cmisCAS"/>
        -->
    
        <!-- Core App -->
    
        <Environment description="" name="cmisCore/server" override="false" type="java.lang.String" value="https://alexq.docmain.state.nm.us:8081/cmisdev1112"/>
    
        <Environment description="" name="cmisSentencingGoodtime/server" override="false" type="java.lang.String" value="http://alexq.docmain.state.nm.us:8083/cmisSentencingGoodtime"/>
    
    </Context>
    server.xml
    Code:
    <?xml version="1.0"?>
    <Server port="${base.shutdown.port}"
            shutdown="SHUTDOWN">
        <Listener className="org.apache.catalina.core.JasperListener"/>
        <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
        <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
        <Listener className="com.springsource.tcserver.serviceability.deploy.TcContainerDeployer"/>
        <Listener accessFile="${catalina.base}/conf/jmxremote.access"
                  authenticate="true"
                  bind="127.0.0.1"
                  className="com.springsource.tcserver.serviceability.rmi.JmxSocketListener"
                  passwordFile="${catalina.base}/conf/jmxremote.password"
                  port="${base.jmx.port}"
                  useSSL="false"/>
        <GlobalNamingResources>
            <Resource auth="Container"
                      description="User database that can be updated and saved"
                      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                      name="UserDatabase"
                      pathname="conf/tomcat-users.xml"
                      type="org.apache.catalina.UserDatabase"/>
        </GlobalNamingResources>
        <Service name="Catalina">
            <Executor maxThreads="300"
                      minSpareThreads="50"
                      name="tomcatThreadPool"
                      namePrefix="tomcat-http--"/>
            <Engine defaultHost="localhost"
                    name="Catalina">
                <Realm className="org.apache.catalina.realm.LockOutRealm">
                    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                           resourceName="UserDatabase"/>
                </Realm>
                <Host appBase="webapps"
                      autoDeploy="true"
                      deployOnStartup="true"
                      deployXML="true"
                      name="localhost"
                      unpackWARs="true">
                    <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"/>
                </Host>
            </Engine>
            <Connector acceptCount="100"
                       connectionTimeout="20000"
                       executor="tomcatThreadPool"
                       maxKeepAliveRequests="15"
                       port="${bio.http.port}"
                       protocol="org.apache.coyote.http11.Http11Protocol"
                       redirectPort="${bio.https.port}"/>
            <Connector port="${bio.https.port}" protocol="HTTP/1.1" SSLEnabled="true"
                       maxThreads="150" scheme="https" secure="true"
                       keystoreFile="c:/apps/portecle-1.7/keystore.jks"
                       keyAlias="tomcat" keystorePass="changeit"
                       clientAuth="false" sslProtocol="TLS" />
        </Service>
        <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
    </Server>

  4. #4
    Join Date
    Jul 2008
    Location
    Santa Fe, NM
    Posts
    15

    Default

    Oh, and versions: VMware vFabric tc Runtime 2.8.1.RELEASE/7.0.32.B.RELEASE

  5. #5
    Join Date
    Oct 2008
    Location
    Melbourne, Florida
    Posts
    83

    Default

    elbulla,

    From looking at your configuration, this exception does not make a lot of sense. Any chance you have or can put together a sample spring app to reproduce this and attach it?

    Thanks,
    Jason

  6. #6
    Join Date
    Jul 2008
    Location
    Santa Fe, NM
    Posts
    15

    Default

    Ah, mystery solved. The process of whittling my app down to something I could share discovered the culprit, in web.xml I had:

    <resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/otrk</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>

    <resource-ref>
    <description>DB Rpt Connection</description>
    <res-ref-name>jdbc/otrk-rpt</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>

    These were not setup in JNDI, and looks like Tomcat ignored them silently. Removed them and the error went away.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •