views:

23

answers:

1

In doing something else, I added a jar to my lib folder called catalina.jar . This allowed me to serve static content (which works), but my previously working struts actions (which access a database through hibernate) no longer work. The first indication of failure occurs on tomcat startup:

SEVERE: Null component Catalina:type=DataSource,path=/,host=localhost,class=javax.sql.DataSource,name="jdbc/UpdatableDB"

The subsequent failures happen on running an action that access the database:

ERROR [http-8080-1 14:21:29,789] (DatasourceConnectionProvider) - Could not find datasource: java:comp/env/jdbc/UpdatableDB
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:438)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)
        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
        at com.util.HibernateUtil.<clinit>(HibernateUtil.java:58)
        at com.offers.CompleteRuleAndTemplateCache.refreshIfNecessary(CompleteRuleAndTemplateCache.java:91)
        at com.offers.CompleteRuleAndTemplateCache.refreshIfNecessary(CompleteRuleAndTemplateCache.java:73)
        at com.offers.CompleteRuleAndTemplateCache.<clinit>(CompleteRuleAndTemplateCache.java:65)
        at com.offers.actions.ShowIframeAction.getApplicableRule(ShowIframeAction.java:541)
        at com.offers.actions.ShowIframeAction.execute(ShowIframeAction.java:121)
        at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
        at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
        at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
        at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
        at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
        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.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.util.SessionFilter.doFilter(SessionFilter.java:78)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Initial SessionFactory creation failed. hibernate-offers.cfg.xml
org.hibernate.HibernateException: Could not find datasource
        at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:438)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91)
        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
        at com.util.HibernateUtil.<clinit>(HibernateUtil.java:58)
        at com.offers.CompleteRuleAndTemplateCache.refreshIfNecessary(CompleteRuleAndTemplateCache.java:91)
        at com.offers.CompleteRuleAndTemplateCache.refreshIfNecessary(CompleteRuleAndTemplateCache.java:73)
        at com.offers.CompleteRuleAndTemplateCache.<clinit>(CompleteRuleAndTemplateCache.java:65)
        at com.offers.actions.ShowIframeAction.getApplicableRule(ShowIframeAction.java:541)
        at com.offers.actions.ShowIframeAction.execute(ShowIframeAction.java:121)
        at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
        at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
        at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
        at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
        at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
        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.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at com.util.SessionFilter.doFilter(SessionFilter.java:78)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        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.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
        ... 41 more

Why would adding a jar cause this? And what can I do about it (without just getting rid of catalina.jar)?

Some suggestions I've found on the web included removing naming-common.jar, naming-factory.jar, and naming-resources.jar from your source - but I already don't have these files.

At Jim Garrison's request, heres where jdbc/UpdatableDB is bound to a DataSource - its not in server.xml, its in context.xml, and this has been working for us for a very long time:

<Resource name="jdbc/UpdatableDB" auth="Container" type="javax.sql.DataSource"
          maxActive="75" maxIdle="40" maxWait="1000"
          removeAbandoned="true" removeAbandonedTimeout="300"
          timeBetweenEvictionRunsMillis="30000"
          defaultAutoCommit="false"
          username="XXXX" password="XXXX" driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://<HOSTNAME AND PATH>?autoReconnect=true"
          connectionProperties="autoReconnect=true;cachePrepStmts=true;cacheCallableStmts=true;cacheServerConfiguration=true;useLocalSessionState=true;elideSetAutoCommits=true;alwaysSendSetIsolation=false;enableQueryTimeouts=false;"
        />
A: 

In Tomcat 5.5, we used the following syntax to look up jdbc resources:

java:/comp/env/jdbc/UpdatableDB

I am not sure if that is equivalent to what you are using, but I thought I would mention it in case it helps someone else.

jt