JNDI需要JDK吗?

时间:2013-09-28 08:12:22

标签: java tomcat jndi

我尝试从SUSE Linux Enterprise Server为Tomcat6配置Oracle datesource。我将数据源添加到context.xml文件:

   <Resource 
   name="jdbc/UCPPool"
   auth="Container"
   factory="oracle.ucp.jdbc.PoolDataSourceImpl"
   type="oracle.ucp.jdbc.PoolDataSource"
   description="Pas testing UCP Pool in Tomcat"
   connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
   minPoolSize="2"
   maxPoolSize="5"
   inactiveConnectionTimeout="20"
   user="scott"
   password="tiger"
   url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
        (HOST=beast.au.oracle.com)(PORT=1523))(CONNECT_DATA=
        (SERVICE_NAME=linux11gr2)))"
   connectionPoolName="UCPPool"
   validateConnectionOnBorrow="true"
   sqlForValidateConnection="select 1 from DUAL" />

在我的persistence.xml应用程序中添加非jta-data-source属性。但每当我想启动应用程序时,tomcat都会抛出此异常:

   Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:comp/env/jdbc/nameDB]
         at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)
    at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:78)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2283)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2279)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1748)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920)
    ... 28 more
   Caused by: javax.naming.NamingException: This context must be accessed throught a java: URL
   org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)

我在OpenSuse上尝试了相同的配置,并在那里工作。我发现唯一的区别是SLSE安装了JAVA SE表单IBM和openSUSE使用OpenJDK java作为defualt。

所以JNDI需要JDK,还是IBM java implmenetation中的一些错误?

1 个答案:

答案 0 :(得分:0)

要回答标题中的问题,不,JNDI是JRE的一部分。不需要JDK。