2014-04-01 68 views
0

因此,我在Tomcat 7的context.xml中有一個JNDI設置。 這應該連接到我的Oracle 10g數據庫。 我在Tomcat的/ lib文件夾中包含了classes12dms_g.jar,orai18n.jar,ojdbc14dms_g.jar和ons.jar。在我的Tomcat 7服務器中配置的Oracle 10g JNDI數據源不起作用

由於某些原因,當我在Tomcat上部署應用程序時,會引發錯誤。

WARN : org.hibernate.engine.jdbc.internal.JdbcServicesImpl - HHH000342: Could not obtain connection to query metadata : Cannot create JDBC driver of class '' for connect URL 'null' 
ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000319: Could not get database metadata 
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) 
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) 
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) 
    at com.sun.proxy.$Proxy12.getConnection(Unknown Source) 
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139) 
    at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) 
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194) 
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) 
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:522) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) 
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672) 
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543) 
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484) 
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    at javax.servlet.GenericServlet.init(GenericServlet.java:158) 
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1279) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1192) 
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087) 
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

的context.xmlC:\ Program Files文件\ Apache軟件基金會\ Tomcat的7.0 \的conf包含

<Resource name="jdbc/myoracle" auth="Container" 
      type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" 
      url="jdbc:oracle:thin:@127.0.0.1:1521:XE" 
      username="BIS" password="ducky" maxActive="20" maxIdle="10" 
      maxWait="-1"/> 

的web.xml包含

<resource-ref> 
    <description>Oracle Spring JNDI Datasource</description> 
    <res-ref-name>jdbc/myoracle</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
    </resource-ref> 

servlet-context.xml包含

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
    <property name="jndiName" value="java:comp/env/jdbc/myoracle"/> 
    <property name="lookupOnStartup" value="true"/> 
    <property name="proxyInterface" value="javax.sql.DataSource"/> 
</bean> 

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
    <property name="dataSource" ref="dataSource" /> 
    <property name="configLocation" value="/WEB-INF/hibernate.cfg.xml"/> 
    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> 
      <prop key="hibernate.show_sql">true</prop> 
      <prop key="hibernate.hbm2ddl.auto">update</prop> 
     </props> 
    </property> 
</bean> 

的hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
     <mapping class="com.fake.domain.LoginBean" /> 
    </session-factory> 
</hibernate-configuration> 

回答

0

確定,所以解決這個問題是通過從文件系統從蝕配置Tomcat和不固定的。當您將Tomcat服務器添加到包含context.xml的名爲Servers的eclipse中時,會在Package Explorer中添加一個文件夾。

作爲一個側面說明,我遇到了另一個問題後,我這樣做。如果你想使用dms罐子,你需要另一個名爲dms.jar的罐子,所以我只是降級到classes12.jar和ojdbc14.jar。

相關問題