[英]glassfish-4 + spring jndi name java:comp/env/jdbc/
In spring web-app we have a bean 在春季网络应用中,我们有一个bean
<bean id="test" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/testRes"/>
</bean>
in glassfish4 config this source declared as jdbc/testRes 在glassfish4配置中,此源声明为jdbc / testRes
it's all work but if we write jndi name like this 都可以,但是如果我们这样写jndi名称
<bean id="test" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/testRes"/>
</bean>
it stops working. 它停止工作。
this web app have many declares jndi name like java:comp/env/jdbc/testRes and we need to maintain compatibility in tomcat7 and glassfish4. 此Web应用程序有许多声明的jndi名称,例如java:comp / env / jdbc / testRes,我们需要维护tomcat7和glassfish4的兼容性。
how can we configure a mapping of this names ? 我们如何配置此名称的映射?
we have found a solution but it doesn't work 我们找到了一个解决方案,但是没有用
<resource-ref>
<res-ref-name>java:comp/env/jdbc/testRes</res-ref-name>
<jndi-name>jdbc/testRes</jndi-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Please help 请帮忙
Probably you found solution but if anyone else is having same issue... 可能您找到了解决方案,但是如果其他任何人也遇到了同样的问题...
Try to add to resource-ref this line: 尝试将以下行添加到resource-ref:
<lookup-name>jdbc/testRes</lookup-name>
so it looks like this: 所以看起来像这样:
<resource-ref>
<res-ref-name>java:comp/env/jdbc/testRes</res-ref-name>
<jndi-name>jdbc/testRes</jndi-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<lookup-name>jdbc/testRes</lookup-name>
</resource-ref>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.