`

Spring配置JNDI(WebLogic92)NameNotFoundException: Unable to resolve解决

阅读更多
请参见:
Struts2.2+Spring3.1+Hibernate3.6整合(登录示例)
http://liuzidong.iteye.com/blog/935493
在这个示例作了修改!
参考资料
1 spring通过weblogic配置的jndi实现数据库操作
http://mariosissy.blogbus.com/logs/48042786.html
2 Spring - Weblogic - Hibernate datasource problem
http://forum.springsource.org/showthread.php?t=37872
一 环境:XP+Myeclipse6.6+WebLogic92+JDK1.5
二 具体步骤如下:
jdbc.properties:注意事项:配置的端口:7002是WEBLOGIC服务器创建域是设置的端口
## JNDI Datasource
Context.INITIAL_CONTEXT_FACTORY=weblogic.jndi.WLInitialContextFactory
Context.PROVIDER_URL=t3://127.0.0.1:7002
JNDI=s2sh
RESOURCEREF=true
#如果你不想使用 'java:comp/env/'前缀的话请设置下面的值为true, 默认值为false
#JNDI=java:comp/env/s2sh
#RESOURCEREF=false

bean.xml中配置:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">   
	    <property name="jndiName">
	    	<value>${JNDI}</value>
	    </property>  
	    <property name="resourceRef">
            <value>${RESOURCEREF}</value>
        </property>	    
	    <property name="jndiEnvironment"> 
	     <props> 
	        <prop key="java.naming.provider.url">${Context.PROVIDER_URL}</prop> 
	        <prop key="java.naming.factory.initial">${Context.INITIAL_CONTEXT_FACTORY}</prop> 	       
	     </props>    
	   </property>  
</bean>

web.xml
<resource-ref> 
	  <description>s2sh</description> 
	  <res-ref-name>s2sh</res-ref-name> 
	  <res-type>javax.sql.DataSource</res-type> 
	  <res-auth>Container</res-auth> 
</resource-ref> 

位置:WEB-INF/weblogic.xml
<?xml version='1.0' encoding='utf-8'?> 
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<container-descriptor>
		<prefer-web-inf-classes>true</prefer-web-inf-classes>		
	</container-descriptor>
	<context-root>/</context-root>
	<resource-description>    
	    <res-ref-name>s2sh</res-ref-name>    
	    <jndi-name>s2sh</jndi-name>
  </resource-description>	
</weblogic-web-app>

注意其中的配置很重要!:
<resource-description>   
    <res-ref-name>s2sh</res-ref-name>   
    <jndi-name>s2sh</jndi-name>
  </resource-description>

不配置会出现错误:

<2011-3-15 下午01时54分31秒 CST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Injection of resource dependencies failed; nested exception is

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property

'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property

'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is

javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'];

remaining name 'oracle'.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Injection of resource dependencies failed; nested exception is

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property

'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property

'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is

javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'];

remaining name 'oracle'
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
Truncated. see log file for complete stacktrace
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property

'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property

'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL

[file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is

javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'];

remaining name 'oracle'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB

-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-

INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is

javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc']; remaining name 'oracle'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [file:/E:/bea/user_projects/domains/s2shdomain/autodeploy/S2SHJNDI/WEB-

INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is

javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc']; remaining name 'oracle'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
Truncated. see log file for complete stacktrace
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'];

remaining name 'oracle'
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
at weblogic.jndi.internal.ServerNamingNode_920_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:374)
Truncated. see log file for complete stacktrace
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:178)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
Truncated. see log file for complete stacktrace
>
<2011-3-15 下午01时54分31秒 CST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application '_appsdir_S2SHJNDI_dir'.
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:894)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:336)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
Truncated. see log file for complete stacktrace
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.oracle'. Resolved 'jdbc'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:178)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
Truncated. see log file for complete stacktrace



另外在WebLogic中创建域请参考以下:
图解Weblogic92域创建及与Myeclipse服务配置
http://liuzidong.iteye.com/blog/929740
另外在WEB-INF/lib下加入weblogic.jar文件

以下是各种应用服务器的不同的properties集合:
websphere: 
java.naming.provider.url->iiop://websphere.machine.domain.com:900 
java.naming.factory.initial ->com.ibm.websphere.naming.WsnInitialContextFactory 
java.naming.factory.url.pkgs ->com.ibm.ws.naming 
org.omg.CORBA.ORBClass->com.ibm.rmi.iiop.ORB 
org.omg.CORBA.ORBSingletonClass->com.ibm.rmi.corba.ORBSingleton 
javax.rmi.CORBA.UtilClass->com.ibm.rmi.javax.rmi.CORBA.Util 
javax.rmi.CORBA.StubClass->com.ibm.rmi.javax.rmi.CORBA.StubDelegateImpl 
javax.rmi.CORBA.PortableRemoteObjectClass->com.ibm.rmi.javax.rmi.PortableRemoteObject 

weblogic: 
java.naming.factory.initial -> weblogic.jndi.WLInitialContextFactory 
java.naming.provider.url -> t3://localhost:7001 

jboss: 
ava.naming.factory.initial ->org.jnp.interfaces.NamingContextFactory 
java.naming.factory.url.pkgs->org.jboss.naming.client 
java.naming.provider.url ->jnp://10.0.0.18:1099 

sunone IMQ ldap: 
java.naming.provider.url -> ldap://localhost:389/dc=yusong,dc=com 
java.naming.factory.initial -> com.sun.jndi.ldap.LdapCtxFactory 

sunone Application Server: 
java.naming.provider.url -> iiop://192.168.0.34:3700 
java.naming.factory.initial -> com.sun.jndi.cosnaming.CNCtxFactory 

oracle oc4j: 
java.naming.factory.initial->com.evermind.server.ApplicationClientInitialContextFactory 
java.naming.provider.url->ormi://localhost/bmpapp
分享到:
评论

相关推荐

    spring获取weblogic jndi数据源的两种方式

    本文将详细介绍如何在Spring中配置两种不同的方式来获取WebLogic JNDI数据源。 #### 一、本地WebLogic Server获取 这种方式适用于当Spring应用与WebLogic服务器在同一台物理机器上运行时的情况。在这种模式下,...

    weblogic spring jndi配置

    NULL 博文链接:https://zzy603.iteye.com/blog/1039826

    spring配置JNDI数据源

    Spring框架作为一个强大的IoC(Inversion of Control)和AOP(Aspect Oriented Programming)容器,提供了多种配置数据源的方式,其中包括通过JNDI(Java Naming and Directory Interface)来查找和配置数据源。JNDI...

    java工程错误信息解析和总结

    nested exception is javax.naming.NameNotFoundException: Unable to resolve 'J2YD' Resolved; remaining name 'J2YD' org.springframework.beans.factory.BeanCreationException: Error creating bean with ...

    spring 配置jndi

    - 在Java应用服务器(如Tomcat、JBoss、WebLogic等)中,你需要先配置一个JNDI数据源。这通常在服务器的管理控制台或者配置文件(如Tomcat的`context.xml`)中完成。例如,在Tomcat中,可以在`server.xml`或`...

    weblogic CVE-2018-3191 exp(含weblogic-spring-jndi-10.3.6.0.jar)

    自用CVE-2018-3191 weblogic反序列化exp。

    如何在spring中等价配置得到原本由jndi配置实现的数据源

    然而,有时我们可能希望在非Web环境下或不使用JNDI的情况下配置数据源,这时我们需要在Spring的配置文件中等价地实现JNDI的数据源配置。以下是如何在Spring中进行这种转换的详细步骤和知识点: 1. **理解JNDI配置**...

    weblogic下配置JNDI数据源

    WebLogic 下配置 JNDI 数据源 WebLogic 是一款功能强大的 Java 应用服务器,提供了强大的集成和管理功能,而 JNDI(Java Naming and Directory Interface)是 Java 中的一种命名和目录接口,用于在 Java 应用程序中...

    Spring配置weblogic中的Datasource

    3. **WebLogic与Spring的集成**:确保Spring应用能够找到WebLogic注册的数据源,需要在`weblogic.xml`配置文件中指定JNDI名称: ```xml &lt;wls:weblogic-web-app xmlns:wls=...

    在Weblogic上配置Hibernate为JNDI

    在Weblogic上配置Hibernate为JNDI涉及到的关键技术包括Weblogic服务器、Hibernate持久化框架以及Java Naming and Directory Interface (JNDI)。JNDI是一个Java API,它允许应用程序查找和访问不同类型的命名和目录...

    Tomcat6+spring+jndi配置数据源说明.docx

    Tomcat6+Spring+JNDI配置数据源说明 本文档主要介绍了Tomcat6+Spring+JNDI配置数据源的详细步骤和原理。数据源是一个池子,里面有若干个数据连接对象,当需要时就从里面拿一个使用,使用完毕就放回去,如果超过最大...

    weblogic9.1下配置JNDI数据源

    本文将详细介绍在WebLogic 9.1环境下配置JNDI数据源的步骤,并结合实际操作中的常见问题提供解决方案。 #### 二、准备工作 在开始配置之前,需要准备以下几项: 1. **环境搭建**:确保WebLogic 9.1服务器已安装并...

    spring,weblogic配置jms

    - 在配置JNDI查找时,正确指定JMS资源的JNDI名称,这通常可以在WebLogic控制台的JMS配置中找到。 - 考虑到事务管理,根据业务需求选择合适的事务配置,例如`CLIENT_ACKNOWLEDGE`或`AUTO_ACKNOWLEDGE`等确认模式。 - ...

    spring-jndi-lookup:如何使用Spring从JNDI查找数据源

    如何使用Spring从JNDI查找数据源 Server.xml &lt;资源名称=“ jdbc / javatechie”全局=“ jdbc / javatechie” auth =“容器” type =“ javax.sql.DataSource” driverClassName =“ com.mysql.jdbc.Driver” url...

    Javax.naming.NameNotFoundException

    当你在JBoss中配置了一个资源,例如一个数据库连接池,并试图通过JNDI名来访问它,如果找不到对应的配置,就会抛出NameNotFoundException。这个错误可能由于以下原因: 1. **配置错误**:你可能在应用的部署描述符...

    Spring+Weblogic JMS

    本项目提供的下载资料可能包含Spring配置文件、Java源代码、测试脚本等,可以帮助学习者了解如何在实际项目中使用Spring与WebLogic JMS的集成。通过深入研究这些文件,你可以了解到如何在企业级环境中利用消息队列...

    配置 JNDI 数据源

    在Spring框架与Tomcat服务器的集成中,配置JNDI数据源是将数据库连接管理交给服务器来处理,提高应用的可移植性和资源利用率。下面将详细解释配置JNDI数据源的相关知识点。 一、JNDI数据源的概念 JNDI数据源是一种...

    eclipse+mysql+tomcat配置JNDI

    本篇文章将深入探讨如何在这样的环境下配置JNDI(Java Naming and Directory Interface),以便于应用程序能方便地查找和使用数据库资源。JNDI是Java平台中的一种标准服务,它提供了一个统一的接口来查找和管理各种...

Global site tag (gtag.js) - Google Analytics