1
我想從glassfish v3服務器中配置的JNDI中查找一些屬性。我想用春天來做。這裏是我的Spring配置:Spring 3 JNDI在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>
我在sun-web.xml中和web.xml文件映射jndi/ws_properties
。問題是這個查找總是給我null屬性。但如果我在java代碼中執行它:
try {
InitialContext context = new InitialContext();
properties = (Properties) context.lookup("jndi/ws_properties");
} catch (NamingException e) {
LOGGER.error("", e);
}
沒關係。我看到我的屬性鍵和值。
有人能告訴我這裏的問題在哪裏嗎?
是的,謝謝你,我按照你說的那樣做了,它工作。 – 2012-05-05 18:36:23