我收到了要维护的旧应用。 SDK 7和Tomcat 6
当我启动Tomcat时,发生致命错误:
[FATAL] [2019-04-12 11:33:14,242] (DatasourceConnectionProvider.java:47) - Could not find datasource: java:comp/env/jdbc/grifoBD
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:776)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLinkFactory.java:152)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:799)
at org.apache.naming.NamingContext.lookup(NamingContext.java:146)
at org.apache.naming.NamingContext.lookup(NamingContext.java:787)
at org.apache.naming.NamingContext.lookup(NamingContext.java:146)
at org.apache.naming.NamingContext.lookup(NamingContext.java:787)
at org.apache.naming.NamingContext.lookup(NamingContext.java:146)
at org.apache.naming.NamingContext.lookup(NamingContext.java:787)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at xxx.inicializar(xxx.java:160)
at xxx.contextInitialized(xxx.java:84)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4276)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4779)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
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:761)
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)
当我导出战争并在eclipse之外的Tomcat上部署时,它工作正常。
我已经检查了以下配置:
1)Tomcat context.xml
<Resource
name="jdbc/testDB"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
username="username"
password="password"
url="jdbc:oracle:thin:@10.0.0.1:1521:dbname"
maxActive="10"
maxIdle="1"
maxWait="500000000"
validationQuery="select 1 from dual" />
2)WebContent / META-INF / context.xml
<Context path="/grifo" reloadable="true">
<ResourceLink global="jdbc/testDB" name="jdbc/testDB" type="javax.sql.Datasource"/>
</Context>
3)WebContent / WEB-INF / web.xml
<resource-ref>
<description>Container DataSource</description>
<res-ref-name>jdbc/testeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4)src / hibernate.cfg.xml
<property name="hibernate.connection.datasource">java:comp/env/jdbc/testeDB</property>