You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Atit <at...@gmail.com> on 2010/08/16 11:06:42 UTC

Setting up JNDI for DB2

Hi All,

I am unable to setup a JNDI connection for my DB2 (v9.7) database in
ServiceMix 3.3.1 and JDK1.6.
I have done the following:

1. Modified my jndi.xml (apache-servicemix-3.3.1\conf) to look like

       
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="jndi" class="org.apache.xbean.spring.jndi.DefaultContext">
    <property name="entries">
      <map>
        <entry key="java:comp/env/jdbc/ephgDB">
   <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    destroy-method="close" singleton="false">
    <property name="driverClassName" value="com.ibm.db2.jcc.DB2DataSource"/>
    <property name="url" value="jdbc:db2://localhost:50000/EPHG_DEV"/>
    <property name="username" value="db2admin"/>
    <property name="password" value="password"/>
   </bean>
        </entry>
      </map>
    </property>
  </bean>
</beans>

       
2. Have added the following in the xbean.xml of my ServiceUnit

         
        <import resource="classpath*:jndi.xml" />
         and
         
        <bean id="DataSourceBean"
                 class="org.springframework.jndi.JndiObjectFactoryBean">
             <property name="jndiName"
value="java:comp/env/jdbc/myDatabase"/>
       </bean>
       
3. Have tried to access the JNDI from the InitialContext with
       
        try {
              final Context ctx = new InitialContext();
              DataSource dataSource = (DataSource) ctx.lookup("jdbc/ephg");
        } catch (NamingException e) {
               e.printStackTrace();
        }
       

I get the following exception:

<component-task-result
xmlns="http://java.sun.com/xml/ns/jbi/management-message">
        <component-name>servicemix-file</component-name>
        <component-task-result-details>
                <task-result-details>
                        <task-id>deploy</task-id>
                        <task-result>SUCCESS</task-result>
                </task-result-details>
        </component-task-result-details>
</component-task-result>
<component-task-result
xmlns="http://java.sun.com/xml/ns/jbi/management-message">
        <component-name>servicemix-quartz</component-name>
        <component-task-result-details>
                <task-result-details>
                        <task-id>deploy</task-id>
                        <task-result>FAILED</task-result>
                        <message-type>ERROR</message-type>
                        <task-status-msg>
<msg-loc-info>
<loc-token/>
<loc-message>Could not deploy xbean service unit</loc-message>
</msg-loc-info>
</task-status-msg>
                        <exception-info>
                                <nesting-level>1</nesting-level>
                                <msg-loc-info>
                                        <loc-token/>
                                        <loc-message>Error creating bean
with name 'DataSourceBean' defined in file [C:\Program
Files\apache-servicemix-3.3.1\da
ce-assemblies\serviceassembly\version_1\sus\servicemix-quartz\serviceunit\xbean.xml]:
Invocation of init method failed; nest
 is javax.naming.NamingException: scheme java not recognized</loc-message>
                                       
<stack-trace><![CDATA[org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'DataSource
d in file [C:\Program
Files\apache-servicemix-3.3.1\data\smx\service-assemblies\serviceassembly\version_1\sus\servicemix-quartz\schedu
nit\xbean.xml]: Invocation of init method failed; nested exception is
javax.naming.NamingException: scheme java not recognized
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
        at
org.apache.servicemix.common.xbean.AbstractXBeanDeployer.deploy(AbstractXBeanDeployer.java:87)
        at
org.apache.servicemix.common.BaseServiceUnitManager.doDeploy(BaseServiceUnitManager.java:88)
        at
org.apache.servicemix.common.BaseServiceUnitManager.deploy(BaseServiceUnitManager.java:69)
        at
org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:520)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(AutoDeploymentService.java:473)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents(AutoDeploymentService.java:526)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary(AutoDeploymentService.java:313)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:253)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.naming.NamingException: scheme java not recognized
        at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
        at
org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
        at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
        at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
        at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
        at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
        at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:200)
        at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:186)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
        ... 25 more
]]></stack-trace>
                                </msg-loc-info>
                        </exception-info>
                </task-result-details>
        </component-task-result-details>
</component-task-result>
<component-task-result
xmlns="http://java.sun.com/xml/ns/jbi/management-message">
        <component-name>servicemix-camel</component-name>
        <component-task-result-details>
                <task-result-details>
                        <task-id>deploy</task-id>
                        <task-result>SUCCESS</task-result>
                </task-result-details>
        </component-task-result-details>
</component-task-result>
</jbi-task-result>
</jbi-task>

        at
org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:125)
        at
org.apache.servicemix.jbi.framework.ManagementSupport.failure(ManagementSupport.java:111)
        at
org.apache.servicemix.jbi.framework.DeploymentService.deployServiceAssembly(DeploymentService.java:555)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingSAs(AutoDeploymentService.java:473)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.checkPendingComponents(AutoDeploymentService.java:526)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateSharedLibrary(AutoDeploymentService.java:313)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:253)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)

INFO  - ComponentMBeanImpl             - Starting component:
servicemix-wsn2005
INFO  - ComponentMBeanImpl             - Initializing component:
servicemix-wsn2005
ERROR - ComponentMBeanImpl             - Could not start component
javax.jbi.JBIException: Error calling init
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.init(SyncLifeCycleWrapper.java:44)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.init(ComponentMBeanImpl.java:201)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(ComponentMBeanImpl.java:287)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.start(ComponentMBeanImpl.java:216)
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:331)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateComponent(AutoDeploymentService.java:288)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:251)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.naming.NamingException: scheme java not recognized
        at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.apache.servicemix.wsn.component.WSNComponent.lookupConnectionFactory(WSNComponent.java:275)
        at
org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:156)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:203)
        ... 12 more
ERROR - InstallationService            - Failed to start Component:
servicemix-wsn2005
javax.jbi.JBIException: Error calling init
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.init(SyncLifeCycleWrapper.java:44)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.init(ComponentMBeanImpl.java:201)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(ComponentMBeanImpl.java:287)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.start(ComponentMBeanImpl.java:216)
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:331)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateComponent(AutoDeploymentService.java:288)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:251)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.naming.NamingException: scheme java not recognized
        at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.apache.servicemix.wsn.component.WSNComponent.lookupConnectionFactory(WSNComponent.java:275)
        at
org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:156)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:203)
        ... 12 more
ERROR - AutoDeploymentService          - Failed to update Component:
servicemix-wsn2005
javax.jbi.management.DeploymentException: javax.jbi.JBIException: Error
calling init
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:338)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateComponent(AutoDeploymentService.java:288)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:251)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.jbi.JBIException: Error calling init
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.init(SyncLifeCycleWrapper.java:44)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.init(ComponentMBeanImpl.java:201)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(ComponentMBeanImpl.java:287)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.start(ComponentMBeanImpl.java:216)
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:331)
        ... 7 more
Caused by: javax.naming.NamingException: scheme java not recognized
        at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.apache.servicemix.wsn.component.WSNComponent.lookupConnectionFactory(WSNComponent.java:275)
        at
org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:156)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:203)
        ... 12 more
WARN  - AutoDeploymentService          - Directory: hotdeploy: Automatic
install of C:\Program
Files\apache-servicemix-3.3.1\hotdeploy\servicemix-wsn2005-2009.0
zip failed
javax.jbi.management.DeploymentException: Failed to update Component:
servicemix-wsn2005
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateComponent(AutoDeploymentService.java:299)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateArchive(AutoDeploymentService.java:251)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.monitorDirectory(AutoDeploymentService.java:658)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.access$800(AutoDeploymentService.java:63)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService$1.run(AutoDeploymentService.java:622)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
Caused by: javax.jbi.management.DeploymentException: javax.jbi.JBIException:
Error calling init
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:338)
        at
org.apache.servicemix.jbi.framework.AutoDeploymentService.updateComponent(AutoDeploymentService.java:288)
        ... 6 more
Caused by: javax.jbi.JBIException: Error calling init
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
        at
org.apache.servicemix.common.SyncLifeCycleWrapper.init(SyncLifeCycleWrapper.java:44)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.init(ComponentMBeanImpl.java:201)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.doStart(ComponentMBeanImpl.java:287)
        at
org.apache.servicemix.jbi.framework.ComponentMBeanImpl.start(ComponentMBeanImpl.java:216)
        at
org.apache.servicemix.jbi.framework.InstallationService.install(InstallationService.java:331)
        ... 7 more
Caused by: javax.naming.NamingException: scheme java not recognized
        at
org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.apache.servicemix.wsn.component.WSNComponent.lookupConnectionFactory(WSNComponent.java:275)
        at
org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:156)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:203)
        ... 12 more
INFO  - AutoDeploymentService          - Directory: hotdeploy: Archive
changed: processing servicemix-xmpp-2009.01-installer.zip ...
INFO  - ComponentMBeanImpl             - Starting component: servicemix-xmpp
INFO  - ComponentMBeanImpl             - Initializing component:
servicemix-xmpp
INFO  - AutoDeploymentService          - Directory: hotdeploy: Finished
installation of archive:  servicemix-xmpp-2009.01-installer.zip


Can you point out what it is that I have done wrong or have I missed
anything?

I haven’t been able to locate a tutorial which describes the complete
process of setting up JNDI for a database in ServiceMix. Can you post the
links?

Thanks
Atit 
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/Setting-up-JNDI-for-DB2-tp2636466p2636466.html
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.