2012-04-26 3 views
3

jetty-maven 플러그인을 사용하여 데이터 소스를 추가 할 수 없습니다. 던져진 오류가 있지만 내가 컨텍스트를 보면 데이터 소스가 추가되지 않았습니다. 나는 그 파일의 경로가 정확하다는 것과 그 파싱이 잘못된 클래스 이름을 넣음으로써 오류가 발생한다는 것을 확인했다. 태그를 사용하고 WebAppContext 구성으로 구성했지만이 파일은 완전히 무시되었습니다.Jetty.xml에서 JNDI 데이터 소스 리소스를 추가하지 않는 jetty-maven-plugin

의 pom.xml

<plugin> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>jetty-maven-plugin</artifactId> 
    <version>8.1.3.v20120416</version> 
    <configuration> 
    <jettyXml>somePath/jetty.xml</jettyXml> 
    </configuration> 
    <dependencies>   
    <dependency> 
    <groupId>postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    <version>9.0-801.jdbc4</version> 
    </dependency> 
</dependencies> 
</plugin> 

jetty.xml의이

<Configure class="org.eclipse.jetty.server.Server"> 

<New id="jdbc/postgres" class="org.eclipse.jetty.plus.jndi.Resource"> 
    <Arg>jdbc/postgres</Arg> 
    <Arg> 
     <New class="org.postgresql.ds.PGSimpleDataSource"> 
      <Set name="User">postgres</Set> 
      <Set name="Password">postgres</Set> 
      <Set name="DatabaseName">myDB</Set> 
      <Set name="ServerName">localhost</Set> 
      <Set name="PortNumber">5432</Set> 
     </New> 
    </Arg> 
</New> 

자바 코드

Context ctx = new InitialContext(); 
Context context = (Context) ctx.lookup("java:comp/env"); 
ds = (DataSource) context.lookup("jdbc/postgres"); 

어떤 도움을 주시면 감사하겠습니다.

+0

이 부두가 아닌 jndi와 defaukt에 의해 구성됩니다. 구성을 찾고 있지만 까다 롭습니다. http://docs.codehaus.org/display/JETTY/JNDI –

답변

0

가 또는 단순히 당신의 web.xml에 추가 : 나는 비슷한 문제를 가지고 보인다

<resource-ref> 
    <res-ref-name>jdbc/postgres</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
</resource-ref> 
관련 문제