2013-04-24 4 views
1

부두가있는 GWT 프로젝트를 만들었고 데이터 소스로 JNDI를 사용합니다. GWT 앱을 실행하면 모든 것이 잘 작동하지만 .war 파일을 JBoss에 복사 할 때 오류가 발생합니다. 보스 버전 - 4.2.3.GAJBoss - 객체를 역 참조 할 수 없습니다.

javax.naming.NamingException: Could not dereference object [Root exception is 
javax.naming.NameNotFoundException: jdbc not bound] at 
org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1215) at 
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758) at 
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774) at 
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at 
javax.naming.InitialContext.lookup(InitialContext.java:392) at 

의 jboss-web.xml을

<?xml version="1.0" encoding="UTF-8"?> 
<jboss-web> 
    <resource-ref> 
     <res-ref-name>jdbc/base</res-ref-name> 
     <jndi-name>jdbc/base</jndi-name> 
     <res-type>javax.sql.DataSource</res-type> 
     <res-auth>Container</res-auth> 
    </resource-ref> 
</jboss-web> 

부두 - env.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> 
<Configure class="org.mortbay.jetty.webapp.WebAppContext"> 
<New id="base" class="org.mortbay.jetty.plus.naming.Resource"> 
    <Arg>jdbc/base</Arg> 
    <Arg> 
    <New class="org.apache.tomcat.jdbc.pool.DataSource"> 
      <Set name="driverClassName">org.postgresql.Driver</Set> 
      <Set name="url">jdbc:postgresql://database/test</Set> 
      <Set name="username">user</Set> 
      <Set name="password">password</Set> 
      <Set name="maxActive">10</Set> 
      <Set name="maxIdle">4</Set> 
    </New> 
    </Arg> 
</New> 
</Configure> 

web.xml을

<resource-ref> 
    <description>My DataSource Reference</description> 
    <res-ref-name>jdbc/base</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
</resource-ref> 

GreetingServiceImpl.java

 InitialContext ic = new InitialContext(); 
     DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/base"); 
     Connection con = ds.getConnection(); 

무엇이 잘못 되었습니까? 도움을 주셔서 감사합니다

답변

1

나는 내 문제를 해결했습니다. 나는 기본-ds.xml

<datasources> 
    <local-tx-datasource> 
     <jndi-name>jdbc/base</jndi-name> 
     <connection-url>jdbc:postgresql://database/test</connection-url> 
     <driver-class>org.postgresql.Driver</driver-class> 
     <user-name>user</user-name> 
     <password>password</password> 
     <min-pool-size>4</min-pool-size> 
     <max-pool-size>10</max-pool-size> 
    </local-tx-datasource> 
</datasources> 

을 생성하고 난 제이 보스 - web.xml 파일에 JNDI 이름을 변경

<jndi-name>java:/jdbc/base</jndi-name> 

어떻게 보스에서이 데이터 소스에 대한 톰캣의 연결 풀을 연결할 수 있습니까?

관련 문제