简体   繁体   English

glassfish-4 + spring jndi名称java:comp / env / jdbc /

[英]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.

相关问题 如何在 Glassfish 4.1 中设置 java:comp/env/foo JNDI 变量? - How to set a java:comp/env/foo JNDI variable in Glassfish 4.1? 不使用web.xml时如何将JDBC数据源绑定到JNDI上下文“ java:comp / env / jdbc” - How to bind a JDBC datasource to JNDI context “java:comp/env/jdbc” when not to use web.xml Spring应用程序侦听器-ContextRefreshedEvent java:comp / env / jdbc / db未找到 - Spring Application Listener - ContextRefreshedEvent java:comp/env/jdbc/db not found 服务器无法找到java:comp / env / jdbc / my_db数据源…在上下文“ java:”中找不到名称comp / env / jdbc - The server cannot locate the java:comp/env/jdbc/my_db data source … Name comp/env/jdbc not found in context “java:” 无法在Liberty中实例化java:comp / env / HRONLINEFSDEV2 JNDI名称引用的对象 - The object referenced by the java:comp/env/HRONLINEFSDEV2 JNDI name could not be instantiated in Liberty 访问不带java:comp / env前缀的JNDI DataSource - Accessing a JNDI DataSource without the java:comp/env prefix Tomcat 中的 jndi 资源没有 java:/comp/env/ 前缀 - jndi resource in Tomcat without java:/comp/env/ prefix 在Tomcat上的java:comp / env之外查找JNDI名称? - Lookup JNDI names outside of java:comp/env on Tomcat? Spring + Websphere 8.5:无法查找JNDI名称[java:comp / websphere / ExtendedJTATransaction] - Spring + Websphere 8.5: Unable to lookup JNDI name [java:comp/websphere/ExtendedJTATransaction] 根异常是 javax.naming.NameNotFoundException: Name jdbc not found in context &quot;java:comp/env&quot; - Root exception is javax.naming.NameNotFoundException: Name jdbc not found in context "java:comp/env"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM