You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by asookazian2 <as...@gmail.com> on 2014/04/25 22:28:15 UTC
datasource jndi lookup problem in WAB
I have the following datasource.xml that is referenced by another xml file
during Spring bootstrap:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/WorkflowDataSource"/>
</beans>
I am getting the following stack trace on start of the WAB:
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource': Invocation of init method failed;
nested exception is javax.naming.NotContextException:
jdbc/WorkflowDataSource
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
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:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at
com.nextgate.mm.workflow.ws.server.WorkflowManagerFactory.getInstance(WorkflowManagerFactory.java:17)
at
com.nextgate.mm.workflow.ws.server.WorkflowManagerWS.<init>(WorkflowManagerWS.java:67)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)[:1.7.0_51]
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_51]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_51]
at
java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_51]
at
org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:329)
at
org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:962)
at
org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:331)
... 65 more
Caused by: javax.naming.NotContextException: jdbc/WorkflowDataSource
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:165)
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:605)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
at javax.naming.InitialContext.lookup(InitialContext.java:411)[:1.7.0_51]
at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
The datasource.xml is in the karaf deploy directory (with a bundle id less
than the WAB's bundle id):
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="dataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<property name="url" value="jdbc:mysql://localhost:3306/workflow"/>
<property name="user" value="foo"/>
<property name="password" value="bar"/>
</bean>
<service interface="javax.sql.DataSource" ref="dataSource">
<service-properties>
<entry key="osgi.jndi.service.name"
value="jdbc/WorkflowDataSource"/>
</service-properties>
</service>
</blueprint>
Reproduces exception if I embed the XML into the main XML...
--
View this message in context: http://karaf.922171.n3.nabble.com/datasource-jndi-lookup-problem-in-WAB-tp4032971.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: datasource jndi lookup problem in WAB
Posted by asookazian2 <as...@gmail.com>.
Thx but I ended up using this instead in Spring context xml (it works in
another app):
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:./etc/nextgate/wf/wfConfig.properties</value>
</list>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
--
View this message in context: http://karaf.922171.n3.nabble.com/datasource-jndi-lookup-problem-in-WAB-tp4032971p4032976.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: datasource jndi lookup problem in WAB
Posted by Achim Nierbeck <bc...@googlemail.com>.
Your jndi lookup isn't correct.
You'll need something like the following:
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/
WorkflowDataSource)
regards, Achim
2014-04-25 22:28 GMT+02:00 asookazian2 <as...@gmail.com>:
> I have the following datasource.xml that is referenced by another xml file
> during Spring bootstrap:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:tx="http://www.springframework.org/schema/tx"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jee="http://www.springframework.org/schema/jee"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-2.5.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
> http://www.springframework.org/schema/jee
> http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
>
> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/WorkflowDataSource"/>
>
> </beans>
>
> I am getting the following stack trace on start of the WAB:
>
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'dataSource': Invocation of init method failed;
> nested exception is javax.naming.NotContextException:
> jdbc/WorkflowDataSource
> at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
> 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:294)
> at
>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
> at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
> at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
> at
>
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
> at
>
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
> at
>
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
> at
>
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
> at
>
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
> at
>
> com.nextgate.mm.workflow.ws.server.WorkflowManagerFactory.getInstance(WorkflowManagerFactory.java:17)
> at
>
> com.nextgate.mm.workflow.ws.server.WorkflowManagerWS.<init>(WorkflowManagerWS.java:67)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)[:1.7.0_51]
> at
>
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)[:1.7.0_51]
> at
>
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.7.0_51]
> at
> java.lang.reflect.Constructor.newInstance(Constructor.java:526)[:1.7.0_51]
> at
>
> org.apache.aries.blueprint.utils.ReflectionUtils.newInstance(ReflectionUtils.java:329)
> at
>
> org.apache.aries.blueprint.container.BeanRecipe.newInstance(BeanRecipe.java:962)
> at
>
> org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:331)
> ... 65 more
> Caused by: javax.naming.NotContextException: jdbc/WorkflowDataSource
> at
>
> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:165)
> at
>
> org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:605)
> at
> org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
> at
> javax.naming.InitialContext.lookup(InitialContext.java:411)[:1.7.0_51]
> at
> org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
> at
> org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
> at
> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
> at
> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
> at
>
> org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
> at
>
> org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
> at
>
> org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
> at
>
> org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
> at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
> at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
>
>
> The datasource.xml is in the karaf deploy directory (with a bundle id less
> than the WAB's bundle id):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
> <bean id="dataSource"
> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
> <property name="url" value="jdbc:mysql://localhost:3306/workflow"/>
> <property name="user" value="foo"/>
> <property name="password" value="bar"/>
> </bean>
>
> <service interface="javax.sql.DataSource" ref="dataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name"
> value="jdbc/WorkflowDataSource"/>
> </service-properties>
> </service>
> </blueprint>
>
> Reproduces exception if I embed the XML into the main XML...
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/datasource-jndi-lookup-problem-in-WAB-tp4032971.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Software Architect / Project Manager / Scrum Master