2012-03-28 6 views
1

Ich möchte einige Eigenschaften von JNDI in Glassfish v3 Server konfiguriert suchen. Ich möchte es mit Feder machen. Hier ist meine Federkonfiguration:Spring 3 JNDI nachschlagen in Glassfish3

<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:jee="http://www.springframework.org/schema/jee" 
     xmlns:jaxws="http://cxf.apache.org/jaxws" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans.xsd 
          http://www.springframework.org/schema/aop 
          http://www.springframework.org/schema/aop/spring-aop-2.0.xsd 
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
          http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd 
          http://www.springframework.org/schema/jee 
          http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"> 

    <import resource="classpath:META-INF/cxf/cxf.xml"/> 
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 

    <!-- 
     JNDI look ups. 
    !--> 
    <jee:jndi-lookup id="properties" 
        jndi-name="java:comp/env/jndi/ws_properties" 
        expected-type="java.util.Properties"/> 

</beans> 

I jndi/ws_properties in sun-web.xml und web.xml-Dateien zugeordnet haben. Problem ist, dass diese Suche mir immer null Eigenschaften gibt. Aber wenn ich es in Java-Code mache:

try { 
     InitialContext context = new InitialContext(); 
     properties = (Properties) context.lookup("jndi/ws_properties"); 
    } catch (NamingException e) { 
     LOGGER.error("", e); 
    } 

Es ist in Ordnung. Ich sehe meine Eigenschaften Schlüssel und Werte.

Kann mir jemand sagen, wo ist das Problem hier?

Antwort

2

Dies liegt wahrscheinlich an Ihrer Eigenschaft "jndi-name".

Sie müssen nicht "java: comp/env /" in den Namen eingeben.

Die Eigenschaft "resource-ref" ist standardmäßig true. Wenn Sie sie nicht auf false setzen, wird java: comp/env automatisch zum Namen hinzugefügt.

+0

Ja danke, ich habe es getan wie du gesagt hast und es hat funktioniert. –