2012-05-23 2 views
1

JBoss 7.1의 GateIn 3.2.0에 배포 한 포틀릿에서 데이터 소스를 가져 오려고합니다. JBoss 7.1의 GateIn 포틀릿에서 JNDI 데이터 소스

우선 제가 또한 드라이버 및 드라이버의 모듈을 추가

  <datasource jta="true" jndi-name="java:jboss/datasources/ccr" pool-name="ccr-pool" enabled="true" use-java-context="false" use-ccm="true"> 
       <connection-url>jdbc:mysql://localhost:42006/contentrepository</connection-url> 
       <driver>com.mysql</driver> 
       <security> 
        <user-name>node</user-name> 
       </security> 
       <statement> 
        <prepared-statement-cache-size>100</prepared-statement-cache-size> 
        <share-prepared-statements>true</share-prepared-statements> 
       </statement> 
      </datasource> 

standalone.xml의 소스를 만들었다. 내 포틀릿에서

나는

dataSource = (DataSource) new InitialContext().lookup("java:jboss/datasources/ccr"); 

를 사용하여 데이터 소스에 액세스하기 위해 노력하고있어하지만 난 단지 javax.naming.NameNotFoundException납니다 : 이름 '보스' ''컨텍스트에서 찾을 수 없습니다.

또한

dataSource = (DataSource) new InitialContext().lookup("java:comp/env/datasources/ccr"); 

과를 가져 시도은 web.xml과 jboss-web.xml을

web.xml에 다음과 같은 항목으로 매핑 :

<resource-ref> 
    <description>MySQL DS</description> 
    <res-ref-name>datasources/ccr</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
</resource-ref> 

jboss-web.xml :

<?xml version="1.0" encoding="UTF-8"?> 
<jboss-web> 
    <resource-ref> 
     <res-ref-name>datasources/ccr</res-ref-name> 
     <res-type>javax.sql.DataSource</res-type> 
     <jndi-name>java:jboss/datasources/ccr</jndi-name> 
    </resource-ref> 
</jboss-web> 

그런 다음 javax.naming.NameNotFoundException을 얻었습니다. 이름 'comp'을 컨텍스트 '에서 찾을 수 없습니다.'

무엇이 누락 되었습니까? 내 응용 프로그램이 데이터 소스를 가져 오지 못하게하는 보안 설정이 있습니까?

이상하게도 서블릿을 사용할 때 동일한 웹 응용 프로그램에서 데이터 소스를 가져올 수 있지만 doGet/doPost 메서드에서만 가능하며 init()에서는 사용할 수 없습니다.

답변

관련 문제