Struts/Spring WebSphere jndi error -
i'm new websphere (mainly worked tomcat) , trying host struts/spring/hibernate website. website supposed able data oracle database , display information.
i'm not able website running , seems jndi error. here error:
[error ] context initialization failed error creating bean name 'entitymanagerfactory' defined in servletcontext resource [/web-inf/applicationcontext.xml]: cannot resolve reference bean 'datasource' while setting bean property 'datasource'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'datasource': invocation of init method failed; nested exception javax.naming.namingexception: cwnen1001e: object referenced java:comp/env/jdbc/test jndi name not instantiated. if reference name maps jndi name in deployment descriptor bindings application performing jndi lookup, make sure jndi name mapping in deployment descriptor binding correct. if jndi name mapping correct, make sure target resource can resolved specified name relative default initial context. [root exception com.ibm.wsspi.injectionengine.injectionexception: cwnen0030e: server unable obtain object instance java:comp/env/jdbc/test reference. exception message was: cwnen1003e: server unable find jdbc/test binding javax.sql.datasource type java:comp/env/jdbc/test reference.] [error ] srve0283e: exception caught while initializing context: org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in servletcontext resource [/web-inf/applicationcontext.xml]: cannot resolve reference bean 'datasource' while setting bean property 'datasource'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'datasource': invocation of init method failed; nested exception javax.naming.namingexception: cwnen1001e: object referenced java:comp/env/jdbc/test jndi name not instantiated. if reference name maps jndi name in deployment descriptor bindings application performing jndi lookup, make sure jndi name mapping in deployment descriptor binding correct. if jndi name mapping correct, make sure target resource can resolved specified name relative default initial context. [root exception com.ibm.wsspi.injectionengine.injectionexception: cwnen0030e: server unable obtain object instance java:comp/env/jdbc/test reference. exception message was: cwnen1003e: server unable find jdbc/test binding javax.sql.datasource type java:comp/env/jdbc/test reference.] @ org.springframework.beans.factory.support.beandefinitionvalueresolver.resolvereference(beandefinitionvalueresolver.java:336) @ org.springframework.beans.factory.support.beandefinitionvalueresolver.resolvevalueifnecessary(beandefinitionvalueresolver.java:108) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applypropertyvalues(abstractautowirecapablebeanfactory.java:1456) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1197) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:475) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:304) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:228) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:300) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:195) @ org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext.java:973) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:750) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:482) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) @ com.ibm.ws.webcontainer.webapp.webapp.notifyservletcontextcreated(webapp.java:2374) @ [internal classes] caused by: javax.naming.namingexception: cwnen1001e: object referenced java:comp/env/jdbc/test jndi name not instantiated. if reference name maps jndi name in deployment descriptor bindings application performing jndi lookup, make sure jndi name mapping in deployment descriptor binding correct. if jndi name mapping correct, make sure target resource can resolved specified name relative default initial context. [root exception com.ibm.wsspi.injectionengine.injectionexception: cwnen0030e: server unable obtain object instance java:comp/env/jdbc/test reference. exception message was: cwnen1003e: server unable find jdbc/test binding javax.sql.datasource type java:comp/env/jdbc/test reference.] @ com.ibm.ws.injectionengine.osgi.internal.naming.injectionjavacolonhelper.newcannotinstantiateobjectexception(injectionjavacolonhelper.java:134) @ [internal classes] @ javax.naming.initialcontext.lookup(unknown source) @ org.springframework.jndi.jnditemplate$1.doincontext(jnditemplate.java:155) @ org.springframework.jndi.jnditemplate.execute(jnditemplate.java:87) @ org.springframework.jndi.jnditemplate.lookup(jnditemplate.java:152) @ org.springframework.jndi.jnditemplate.lookup(jnditemplate.java:179) @ org.springframework.jndi.jndilocatorsupport.lookup(jndilocatorsupport.java:95) @ org.springframework.jndi.jndiobjectlocator.lookup(jndiobjectlocator.java:106) @ org.springframework.jndi.jndiobjecttargetsource.afterpropertiesset(jndiobjecttargetsource.java:97) @ org.springframework.jndi.jndiobjectfactorybean$jndiobjectproxyfactory.createjndiobjectproxy(jndiobjectfactorybean.java:318) @ org.springframework.jndi.jndiobjectfactorybean$jndiobjectproxyfactory.access$000(jndiobjectfactorybean.java:307) @ org.springframework.jndi.jndiobjectfactorybean.afterpropertiesset(jndiobjectfactorybean.java:200) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1612) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1549) ... 24 more caused by: com.ibm.wsspi.injectionengine.injectionexception: cwnen0030e: server unable obtain object instance java:comp/env/jdbc/test reference. exception message was: cwnen1003e: server unable find jdbc/test binding javax.sql.datasource type java:comp/env/jdbc/test reference. @ com.ibm.wsspi.injectionengine.injectionbinding.getinjectionobject(injectionbinding.java:1087) ... 38 more caused by: com.ibm.wsspi.injectionengine.injectionexception: cwnen1003e: server unable find jdbc/test binding javax.sql.datasource type java:comp/env/jdbc/test reference. @ com.ibm.ws.injectionengine.osgi.internal.indirectjndilookupobjectfactory.getobjectinstance(indirectjndilookupobjectfactory.java:201) ... 38 more
here websphere server.xml
<server description="new server"> <featuremanager continueonerror="false"> <feature>localconnector-1.0</feature> <feature>servlet-3.0</feature> <feature>jsp-2.2</feature> <feature>jaxrs-1.1</feature> <feature>jndi-1.0</feature> </featuremanager> <applicationmonitor updatetrigger="disabled"/> <application id="proxy" location="proxy.war" name="proxy" type="war"> </application> <httpendpoint id="defaulthttpendpoint" host="localhost" httpport="9080" httpsport="9443" /> <datasource id="oracle" jndiname="jdbc/test" type="javax.sql.datasource"> <jdbcdriver libraryref="oracle-lib" id="oracle-driver"/> <connectionmanager numconnectionsperthreadlocal="10" id="connectionmanager" minpoolsize="1"/> <properties.oracle user="test" password="test" url="jdbc:oracle:thin:@test.local:1521:stilog"/> </datasource> <library id="oracle-lib"> <fileset dir="c:/users/test/workspace/webadmin/webcontent/web-inf/lib/" includes="ojdbc6.jar"/> </library> <application context-root="webadmin" id="webadmin" location="webadmin.war" name="webadmin" type="war"> <classloader delegation="parentlast" commonlibraryref="oracle-lib"/> </application> </server>
applicationcontext.xml
<?xml version="1.0" encoding="utf-8"?> <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:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"> <bean class="org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor" /> <bean id="commonservice" class="com.ddvc.service.commonserviceimpl"/> <bean id="mainmenuservice" class="com.ddvc.service.mainmenuserviceimpl"/> <bean id="storefilterservice" class="com.ddvc.service.storefilterserviceimpl"/> <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> <property name="datasource" ref="datasource" /> <property name="jpavendoradapter"> <bean class="org.springframework.orm.jpa.vendor.hibernatejpavendoradapter"> <property name="database" value="oracle" /> <property name="showsql" value="true" /> </bean> </property> <property name="persistenceunitname" value="pu1" /> <property name="jpaproperties"> <props> <prop key="org.hibernate.envers.store_data_at_delete">true</prop> </props> </property> </bean> <bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jndiname"> <!-- value>java:/comp/env/ivrconfig</value --> <!-- value>ivrconfigcluster</value --> <value>java:comp/env/jdbc/test</value> </property> <property name="lookuponstartup" value="true"/> <property name="cache" value="true"/> <property name="proxyinterface" value="javax.sql.datasource"/> </bean> <!-- <jee:jndi-lookup id="datasource" --> <!-- jndi-name="java:comp/env/jdbc/test" --> <!-- cache="true" --> <!-- resource-ref="true" --> <!-- lookup-on-startup="true" --> <!-- proxy-interface="javax.sql.datasource"> --> <!-- </jee:jndi-lookup> --> <!-- <bean class="org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor" /> --> <!-- <bean id="pum" --> <!-- class="org.springframework.orm.jpa.persistenceunit.defaultpersistenceunitmanager"> --> <!-- <property name="persistencexmllocations"> --> <!-- <list> --> <!-- <value>classpath:meta-inf/persistence.xml</value> --> <!-- </list> --> <!-- </property> --> <!-- <property name="defaultdatasource" ref="datasource"></property> --> <!-- </bean> --> <!-- <bean id="emf-p" --> <!-- class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> --> <!-- <property name="persistencexmllocation" value="/webcontent/meta-inf/persistence.xml" /> --> <!-- <property name="persistenceunitmanager" ref="pum"/> --> <!-- <property name="persistenceunitname" value="pu1" /> --> <!-- <property name="loadtimeweaver"> --> <!-- <bean class="org.springframework.instrument.classloading.instrumentationloadtimeweaver" /> --> <!-- </property> --> <!-- </bean> --> <bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager"> <property name="entitymanagerfactory" ref="entitymanagerfactory" /> </bean> <tx:annotation-driven transaction-manager="transactionmanager" /> <bean id="loginaction" scope="prototype" class="com.ddvc.action.loginaction"> <constructor-arg ref="commonservice" /> </bean> <bean id="useraction" scope="prototype" class="com.ddvc.action.useraction"> <constructor-arg ref="commonservice" /> </bean> <bean id="mainmenuaction" scope="prototype" class="com.ddvc.action.mainmenuaction"> <constructor-arg ref="mainmenuservice" /> </bean> </beans>
ibm-web-bnd.xml
<?xml version="1.0" encoding="utf-8"?> <web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0"> <virtual-host name="default_host" /> <resource-ref name="jdbc/test" binding-name="jdbc/test"/> </web-bnd>
web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app id="webapp_id" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>webadmin</display-name> <!-- include if using hibernate --> <filter> <filter-name>spring openentitymanagerinviewfilter</filter-name> <filter-class> org.springframework.orm.jpa.support.openentitymanagerinviewfilter </filter-class> </filter> <filter-mapping> <filter-name>spring openentitymanagerinviewfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <listener> <listener-class> org.springframework.web.context.contextloaderlistener </listener-class> </listener> <resource-ref> <description>datasource</description> <res-ref-name>jdbc/test</res-ref-name> <res-type>javax.sql.datasource</res-type> <res-auth>container</res-auth> <res-sharing-scope>shareable</res-sharing-scope> <mapped-name>jdbc/test</mapped-name> </resource-ref> </web-app>
it suggested try <jee:jndi-lookup id="datasource">
, , got hooked up. acted exact same way <bean id="datasource">
.
this not correct way it. follows:
- in eclipse, go
help > eclipse marketplace
- search ibm liberty, find - websphere application server liberty profile developer tools luna (or other eclipse version using). install tools.
- after installation, able create new server - websphere application server liberty profile - create it. web preview trying use static files, not java ee applications.
in wizard creating server have option download server runtime, it. can download manually wasdev.net:
add application server. in servers view, expand liberty server , double click server configuration. have feature manager there, , able add jdbc there.
Comments
Post a Comment