2017-04-25 2 views
0

여기에 내 server.xml이 있습니다. javax.naming.NameNotFoundException : 이름 UserDatabase가이 컨텍스트에 바인딩되어 있지 않습니다. 영역을 제거하면 getjavax.naming.NameNotFoundException :이 컨텍스트에서 datasource를 찾을 수 없습니다. 여기서 뭐가 잘못 됐니?봄에 톰캣으로 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 : 클래스 경로 자원 [spring/ibatis-context.xml]에 'dataSource'라는 이름의 bean을 생성하는 중 오류가 발생했습니다 : init 메소드를 호출하지 못했습니다. 중첩 예외는 javax.naming.NameNotFoundException입니다 :이 컨텍스트 내 이름 myDatabase가 바인드되지 않았습니다 –

+1

Tomcat의 ''및'java :/comp/env/jdbc/myDatabase'의'name = "jdbc/myDatabase" in Spring의'JndiObjectFactoryBean.jndiName' –

+0

그건 나를 위해 일해 .. .. :). 감사합니다 –

답변

1

여기에 나를 위해 작동 것입니다 :

name = "jdbc/myDatabase" 

Tomcat의 <Resource>

java:/comp/env/jdbc/myDatabase 

봄의 JndiObjectFactoryBean.jndiName에에.