2017-04-25 13 views
0

ここに私のserver.xmlがあります。 javax.naming.NameNotFoundException:名前UserDatabaseはこのコンテキストにバインドされていません。レルムを削除すると、getjavax.naming.NameNotFoundException:このコンテキストではデータソースが見つかりません。何が間違っている?tomcatで春にjndi databseを設定できません

<?xml version="1.0" encoding="UTF-8"?> 
<Server port="8005" shutdown="SHUTDOWN"> 
<Listener SSLEngine="on" 
    className="org.apache.catalina.core.AprLifecycleListener" /> 
<Listener className="org.apache.catalina.core.JasperListener" /> 
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> 
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> 
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> 
<GlobalNamingResources> 
    <Resource auth="Container" description="Pas testing UCP Pool in Tomcat" 
     driverClassName="oracle.jdbc.OracleDriver" maxIdle="10" maxWait="-1" 
     name="myDatabase" password="abc123" pathname="conf/context.xml" 
     readOnly="true" type="javax.sql.DataSource" 
     url="myurl" user="admin" 
     vreadOnly="true" xActive="20" /> 
</GlobalNamingResources> 
<Service name="Catalina"> 
    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" 
     redirectPort="8443" /> 
    <!-- Define an AJP 1.3 Connector on port 8009 --> 
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 

    <Engine defaultHost="localhost" name="Catalina"> 
     <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
      resourceName="UserDatabase" /> 

     <Host appBase="webapps" autoDeploy="true" name="localhost" 
      unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false"> 
     </Host> 
    </Engine> 
</Service> 
</Server> 

のcontext.xml

<?xml version="1.0" encoding="UTF-8"?> 
<Context> 
<!-- Default set of monitored resources --> 
<ResourceLink auth="Container" global="myDatabase" 
    name="myDatabase" type="javax.sql.DataSource" /> 
<WatchedResource>WEB-INF/web.xml</WatchedResource> 

</Context> 

スプリングビーンXML

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd 
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="jndiName" value="myDatabase"/> 
</bean> 

web.xmlが私は線の下に追加されている

<resource-ref> 
    <description>DB Connection</description> 
    <res-ref-name>CitilinxJdbcDatasource</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
</resource-ref> 
+0

エラーの詳細:org.springframework.beans.factory.BeanCreationException:クラスパスのリソースで定義された 'dataSource'という名前のBeanを作成中にエラーが発生しました[spring/ibatis-context.xml]:initメソッドの呼び出しに失敗しました。ネストされた例外はjavax.naming.NameNotFoundExceptionです:名前myDatabaseはこのコンテキストでバインドされていません –

+1

Tomcatの ''と 'java:/ comp/env/jdbc/myDatabase'の' name = "jdbc/myDatabase" Springの 'JndiObjectFactoryBean.jndiName'で –

+0

それは私のためにも働きました.. :)。ありがとうございます –

答えて

1

は、ここで私のためにどのような作品です:

name = "jdbc/myDatabase" 

Tomcatの<Resource>

java:/comp/env/jdbc/myDatabase 

春の JndiObjectFactoryBean.jndiName中で。

関連する問題