spring jndi datasource setup -
hi trying use jndi data source. below code
context.xml
<context antijarlocking="true" path="/springmvctest"> <resource auth="container" driverclassname="com.mysql.jdbc.driver" maxactive="20" maxidle="10" maxwait="10000" name="jdbc/pluto" password="" type="javax.sql.datasource" url="jdbc:mysql://localhost:3306/spring?zerodatetimebehavior=converttonull" username="pluto"/> </context>
in spring-servlet config bean is:
<bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jdbc/pluto" value="java:comp/env/jdbc/pluto"/> </bean>
i getting error
org.springframework.beans.factory.beancreationexception: error creating bean name 'contactcontroller': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private app.contact.service.contactservice app.contact.controller.contactcontroller.contactservice; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'contactserviceimpl': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private app.contact.dao.contactdao app.contact.service.contactserviceimpl.contactdao; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'contactdaoimpl': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.hibernate.sessionfactory app.contact.dao.contactdaoimpl.sessionfactory; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'sessionfactory' defined in servletcontext resource [/web-inf/spring-servlet.xml]: cannot resolve reference bean 'datasource' while setting bean property 'datasource'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'datasource' defined in servletcontext resource [/web-inf/spring-servlet.xml]: error setting property values; nested exception org.springframework.beans.notwritablepropertyexception: invalid property 'jdbc/pluto' of bean class [org.springframework.jndi.jndiobjectfactorybean]: bean property 'jdbc/pluto' not writable or has invalid setter method. parameter type of setter match return type of getter? related cause: org.springframework.beans.factory.beancreationexception: error creating bean name 'datasource' defined in servletcontext resource [/web-inf/spring-servlet.xml]: error setting property values; nested exception org.springframework.beans.notwritablepropertyexception: invalid property 'jdbc/pluto' of bean class [org.springframework.jndi.jndiobjectfactorybean]: bean property 'jdbc/pluto' not writable or has invalid setter method. parameter type of setter match return type of getter?
you have bean definition such
<bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jdbc/pluto" value="java:comp/env/jdbc/pluto"/> </bean>
the property name jdbc/pluto
supposed match setter, spring expects setjdbc/pluto()
not correct java syntax.
looking @ jndiobjectfactorybean
looks want setjndiname()
method jndiobjectlocator
super class.
so bean should like
<bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jndiname" value="java:comp/env/jdbc/pluto"/> </bean>
Comments
Post a Comment