aspose file tools*
The moose likes JBoss/WildFly and the fly likes How to configure mulitple datasource files on JBoss 4.3 application server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to configure mulitple datasource files on JBoss 4.3 application server ?" Watch "How to configure mulitple datasource files on JBoss 4.3 application server ?" New topic
Author

How to configure mulitple datasource files on JBoss 4.3 application server ?

Anoop Nair
Ranch Hand

Joined: Oct 29, 2008
Posts: 70
Hi All,

I am using JBoss-eap-4.3.0.GA_CP06.

I have multiple applications deployed in the same instance of Jboss server. Each application connects to a different database.
I want to have separate datasource file for the each application.

Is this possible ? If yes, then where do I configure it.
uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

For each datasource deploy seperate *-ds.xml file and use the corresponding JNDI in your application to access the datasource.
Anoop Nair
Ranch Hand

Joined: Oct 29, 2008
Posts: 70
I tried putting different data source files with the names *-ds.xml . But the application doesnt work with it.
But when I put all the datasources in a single file it works.

uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

What is the error that you are getting? Please post all the *-ds.xml files along with their contents.
Anoop Nair
Ranch Hand

Joined: Oct 29, 2008
Posts: 70
I am getting the below error when server starts up


javax.naming.NameNotFoundException: APP2_DS not bound
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)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:732)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)


Below are my DS files:
DS1


DS2



But if i put both in a single file it works fine.
uttam kumar
Ranch Hand

Joined: Jan 27, 2009
Posts: 128

<depends>jboss:service=Hypersonic,database=localDB</depends>

I dont think its necessary.

Moreover, you can have multiple <local-tx-datasource> mapped to different JNDIs in a single *-ds.xml file. Since you are using Oracle database, you can name the file as oracle-ds.xml and put both the datasources in the same file. It will not affect anything.
Anoop Nair
Ranch Hand

Joined: Oct 29, 2008
Posts: 70
Anoop Nair wrote:I tried putting different data source files with the names *-ds.xml . But the application doesnt work with it.
But when I put all the datasources in a single file it works.



Thats what I am doing currently. Both applications are being developed by different teams and are deployed in different directories. So the requirement is that the datasource file should be present alongwith the application deployed (each in its own directory).
my myjob
Greenhorn

Joined: Sep 06, 2012
Posts: 1
Hi I am meeting the same problem now, did you get any solutions on this issue?
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

What does the URLs element look like in jboss-service.xml?


In this case all our xxx-ds.xml definitions are in the datasources folder.

If you want multiple folders, then add them to the URLs attribute.

WP
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

"my myjob", please see you private messages regarding an important administrative matter.


JBoss In Action
Siitesh Hind
Ranch Hand

Joined: Sep 06, 2012
Posts: 51
security-domain xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
depends jboss:service=Hypersonic,database=localDB </depends

Wondering why do you need these 2 entries.

It works just fine on JBoss 5.1.0 GA.

Rgds,

Seetesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to configure mulitple datasource files on JBoss 4.3 application server ?