Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring3JNDI在glassfish3中查找_Spring_Glassfish_Jndi - Fatal编程技术网

Spring3JNDI在glassfish3中查找

Spring3JNDI在glassfish3中查找,spring,glassfish,jndi,Spring,Glassfish,Jndi,我想从glassfish v3服务器中配置的JNDI中查找一些属性。我想用弹簧来做。以下是我的spring配置: <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" xm

我想从glassfish v3服务器中配置的JNDI中查找一些属性。我想用弹簧来做。以下是我的spring配置:

<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>
没关系。我看到我的属性键和值


有人能告诉我哪里出了问题吗?

这可能是因为您的“jndi名称”属性

您不必在名称中添加“java:comp/env/”

“resource ref”属性默认为true,除非将其设置为false,否则它将自动将java:comp/env添加到名称中

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