You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by onyii5119 <on...@gmail.com> on 2012/09/27 00:23:47 UTC

Dynamic DataSource - Exception

I was just trying out Dynamic DataSource but could not get it to work. I was
getting the exception below. I have attached a zip of the source code. I am
using Tomee 1.1.0 snapshot. I use Hibernate mapping. I don't want the
datasources defined in Tomee.xml. ccms.zip
<http://openejb.979440.n4.nabble.com/file/n4657657/ccms.zip>  

Any help would be appreciated.

Thanks,
Jonathan Ekwempu


INFO: -------------------------
TomcatWebAppBuilder.init /ccms
Sep 26, 2012 6:06:14 PM org.apache.openejb.util.JarExtractor extract
INFO: Extracting jar: C:\apache-tomee-1.1.0-snapshot\webapps\ccms.war
Sep 26, 2012 6:06:14 PM org.apache.openejb.util.JarExtractor extract
INFO: Extracted path: C:\apache-tomee-1.1.0-snapshot\webapps\ccms
Sep 26, 2012 6:06:15 PM org.apache.openejb.config.DeploymentLoader
addFacesConfigs
INFO: faces config file is null
Sep 26, 2012 6:06:15 PM org.apache.openejb.config.ConfigurationFactory
configureApplication
INFO: Configuring enterprise application:
C:\apache-tomee-1.1.0-snapshot\webapps\ccms
Sep 26, 2012 6:06:16 PM
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans
getLookupMethod
WARNING: Method 'lookup' is not available for 'javax.annotation.Resource'.
Probably using an older Runtime.
Sep 26, 2012 6:06:16 PM org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb CommonService:
EjbDeployment(deployment-id=CommonService)
Sep 26, 2012 6:06:16 PM org.apache.catalina.core.ContainerBase removeChild
SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was
attempted ([before_destroy]) for component [
StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ccms]] in
state [STARTING_PREP]
        at
org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:408)
        at
org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:298)
        at
org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:952)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:931)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:786)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
        at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Sep 26, 2012 6:06:16 PM org.apache.tomee.catalina.TomcatWebAppBuilder
startInternal
SEVERE: Unable to deploy collapsed ear in war /ccms: Exception: No provider
available for resource-ref 'null' of type 'c
om.tobisoft.datasource.router.TsDataSourceRouter' for 'CommonService'.
org.apache.openejb.OpenEJBException: No provider available for resource-ref
'null' of type 'com.tobisoft.datasource.rout
er.TsDataSourceRouter' for 'CommonService'.
        at
org.apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java:1717)
        at
org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1710)
        at
org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1661)
        at
org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1060)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:816)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
        at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:342)
        at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:825)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:781)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
        at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Sep 26, 2012 6:06:16 PM org.apache.catalina.core.ContainerBase
addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].Stan
dardContext[/ccms]]
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.tomee.catalina.TomEERuntimeException:
org.apache.openejb.OpenEJBException: No provider available f
or resource-ref 'null' of type
'com.tobisoft.datasource.router.TsDataSourceRouter' for 'CommonService'.
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:790)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
        at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
        at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 11 more
Caused by: org.apache.openejb.OpenEJBException: No provider available for
resource-ref 'null' of type 'com.tobisoft.data
source.router.TsDataSourceRouter' for 'CommonService'.
        at
org.apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java:1717)
        at
org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1710)
        at
org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1661)
        at
org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1060)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:816)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
        at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:342)
        at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:825)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:781)
        ... 17 more
Sep 26, 2012 6:06:16 PM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive
C:\apache-tomee-1.1.0-snapshot\webapps\ccms.war
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start
component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ccms]]
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
        at
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Sep 26, 2012 6:06:16 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory
C:\apache-tomee-1.1.0-snapshot\webapps\docs
Sep 26, 2012 6:06:16 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: -------------------------



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
Thanks.



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668237.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
kind of but not exactly.

TomEE supports configuration of datasources and resources (including router) in:
1) tomee.xml
2) resources.xml (app classloader)
3) system.properties or JVM system properties

All of them are static

If you want runtime resource definition you need to use internal
mecanism. Globally it doesn't need to be tomee datasource to work, it
can be custom ones. The easier will be to use DataSourceFactory:

DataSourceFactory.create(name, jta, driverOrDataSourceClass,
propertiesInString, waittime, evictionTimeout, evictableTimeout)

If you don't use JTA compatible datasource you can just use dbcp. If
you prefer just use
SystemInstance.get().getComponent(DataSourceCreator.class). The API is
maybe easier.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-03-16 21:31 GMT+01:00 onyii5119 <on...@gmail.com>:
> Are you saying that the only way it can work is for resources to be defined
> in resources.xml or tomee.xml? In other words using properties and reading
> the datasource params from a db will not work?
>
> Thanks,
> Jonathan
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668235.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
Are you saying that the only way it can work is for resources to be defined
in resources.xml or tomee.xml? In other words using properties and reading
the datasource params from a db will not work?

Thanks,
Jonathan





--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668235.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
your postconstruct is where you define resources? it is just useless
actually. Resources are defined in resources.xml or tomee.xml

all you do with it is to start another container or nothing depending
the environment
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-03-16 21:10 GMT+01:00 onyii5119 <on...@gmail.com>:
> I did what you are suggesting before posting my request.
>
> Please find my code and see if you could identify what is wrong with my code
> (it is a simple example)
>
> public class DeterminedRouter extends AbstractRouter implements Serializable
> {
>         private static final long serialVersionUID = -4973022035526665822L;
>         final Logger log = LoggerFactory.getLogger(this.getClass());
>
>     private String dataSourceNames;
>     private String defaultDataSourceName;
>     private Map<String, DataSource> dataSources = null;
>     private ThreadLocal<DataSource> currentDataSource = new
> ThreadLocal<DataSource>();
>
>         /**
>          *
>          */
>         public DeterminedRouter() {
>         }
>
>     /**
>      * @param datasourceList datasource resource name, separator is a space
>      */
>     public void setDataSourceNames(String datasourceList) {
>         dataSourceNames = datasourceList;
>     }
>
>     /**
>      * lookup datasource in openejb resources
>      */
>     private void init() {
>         dataSources = new ConcurrentHashMap<String, DataSource>();
>         for (String ds : dataSourceNames.split(" ")) {
>             try {
>                 Object o = getOpenEJBResource(ds);
>                 if (o instanceof DataSource) {
>                     dataSources.put(ds, DataSource.class.cast(o));
>                 }
>             }catch (NamingException e) {
>                 e.printStackTrace();
>             }
>         }
>     }
>
>     /**
>      * @return the user selected data source if it is set
>      *         or the default one
>      *  @throws IllegalArgumentException if the data source is not found
>      */
>     @Override
>     public DataSource getDataSource() {
>         // lazy init of routed datasources
>         if (dataSources == null) {
>             init();
>         }
>
>         // if no datasource is selected use the default one
>         if (currentDataSource.get() == null) {
>             if (dataSources.containsKey(defaultDataSourceName)) {
>                 return dataSources.get(defaultDataSourceName);
>
>             } else {
>                 throw new IllegalArgumentException("you have to specify at
> least one datasource");
>             }
>         }
>
>         // the developper set the datasource to use
>         return currentDataSource.get();
>     }
>
>     /**
>      *
>      * @param datasourceName data source name
>      */
>     public void setDataSource(String datasourceName) {
>         if (dataSources == null) {
>             init();
>         }
>         if (!dataSources.containsKey(datasourceName)) {
>             throw new IllegalArgumentException("data source called " +
> datasourceName + " can't be found.");
>         }
>         DataSource ds = dataSources.get(datasourceName);
>         currentDataSource.set(ds);
>     }
>
>     /**
>      * reset the data source
>      */
>     public void clear() {
>         currentDataSource.remove();
>     }
>
>     public void setDefaultDataSourceName(String name) {
>         this.defaultDataSourceName = name;
>     }
>
> }
>
> ////////////////////////////////////////////////////////////////
>
> @Stateless
> public class RoutedPersister implements Serializable {
>         private static final long serialVersionUID = -4630430944530409705L;
>         final Logger log = LoggerFactory.getLogger(this.getClass());
>
>     @Resource(name="TsRouter", type = DeterminedRouter.class)
>     private DeterminedRouter router;
>
>         @PersistenceContext(unitName = "router")
>     private EntityManager em;
>
>         private RoutedPersister routedPersister;
>
>         private String[] databases;
>         private Properties properties;
>
>
>         /**
>          *
>          */
>         public RoutedPersister() {
>         }
>
>         @PostConstruct
>         public void init(){
>                 try{
>                     databases = new String[]{"db1", "db2", "db3"};
>
>                     properties = new Properties();
>                     properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> LocalInitialContextFactory.class.getName());
>
>                     // resources
>                     // datasources
>                     for (int i = 1; i <= databases.length; i++) {
>                         String dbName = databases[i - 1];
>                         properties.setProperty(dbName, "new://Resource?type=DataSource");
>                         dbName += ".";
>                         properties.setProperty(dbName + "JdbcDriver",
> "com.mysql.jdbc.Driver");
>                         properties.setProperty(dbName + "JdbcUrl",
> "jdbc:mysql://domain.com:3306/" + i);
>                         properties.setProperty(dbName + "UserName", "username");
>                         properties.setProperty(dbName + "Password", "password");
>                         properties.setProperty(dbName + "JtaManaged", "true");
>                     }
>
>                     // router
>                     properties.setProperty("TsRouter",
> "new://Resource?provider=org.router:DeterminedRouter&type=" +
> DeterminedRouter.class.getName());
>                     properties.setProperty("TsRouter.DatasourceNames", "db1 db2 db3");
>                     properties.setProperty("TsRouter.DefaultDataSourceName", "db1");
>
>                     // routed datasource
>                     properties.setProperty("Routed Datasource",
> "new://Resource?provider=RoutedDataSource&type=" + Router.class.getName());
>                     properties.setProperty("Routed Datasource.Router", "TsRouter");
>
>                     Context ctx =
> EJBContainer.createEJBContainer(properties).getContext();
>                     routedPersister = (RoutedPersister)
> ctx.lookup("java:global/dynamic-datasource-routing/RoutedPersister");
>
>                 }catch(Exception e){
>                         e.printStackTrace();
>                 }
>         }
>
>     public RoutedPersister getRoutedPersister() {
>                 return routedPersister;
>         }
>
>         public void setRoutedPersister(RoutedPersister routedPersister) {
>                 this.routedPersister = routedPersister;
>         }
>
>         public void persist(int id, String name, String ds) {
>         router.setDataSource(ds);
> //        em.persist(new Person(id, name));
>     }
>
> }
>
> ////////////////////////////////////////////////////////////////////////////
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ServiceJar>
>
>         <ServiceProvider id="TsRouter"
>         service="Resource"
>         type="org.apache.openejb.resource.jdbc.Router"
>         class-name="test.datasources.DeterminedRouter"
>         >
>
>         # the parameters
>
>         DataSourceNames
>         DefaultDataSourceName
>         </ServiceProvider>
> </ServiceJar>
>
> I placed this file in WEB-INF/classes/META-INF/org.router/service-jar.xml
>
> When I run it I get the following error message:
>
> Mar 16, 2014 4:07:23 PM org.apache.tomee.catalina.TomcatWebAppBuilder
> startInternal
> SEVERE: Unable to deploy collapsed ear in war
> StandardEngine[Catalina].StandardHost[l
> ocalhost].StandardContext[/rls]
> org.apache.openejb.OpenEJBException: Can't find resource for class
> test.datas
> ources.RoutedPersister#router. (No provider available for resource-ref
> 'null' of type
>  'test.datasources.DeterminedRouter' for 'rls.Comp1509825954'.)
>         at
> org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:11
> 74)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:858)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:193)
>         at
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationF
> actory.java:396)
>         at
> org.apache.openejb.config.ConfigurationFactory.configureApplication(Config
> urationFactory.java:938)
>         at
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBu
> ilder.java:1171)
>         at
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppB
> uilder.java:1051)
>         at
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListe
> nerSupport.java:127)
>         at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupp
> ort.java:119)
>         at
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.ja
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668232.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
I did what you are suggesting before posting my request.

Please find my code and see if you could identify what is wrong with my code
(it is a simple example)

public class DeterminedRouter extends AbstractRouter implements Serializable
{
	private static final long serialVersionUID = -4973022035526665822L;
	final Logger log = LoggerFactory.getLogger(this.getClass());	

    private String dataSourceNames;
    private String defaultDataSourceName;
    private Map<String, DataSource> dataSources = null;
    private ThreadLocal<DataSource> currentDataSource = new
ThreadLocal<DataSource>();

	/**
	 * 
	 */
	public DeterminedRouter() {
	}

    /**
     * @param datasourceList datasource resource name, separator is a space
     */
    public void setDataSourceNames(String datasourceList) {
        dataSourceNames = datasourceList;
    }

    /**
     * lookup datasource in openejb resources
     */
    private void init() {
        dataSources = new ConcurrentHashMap<String, DataSource>();
        for (String ds : dataSourceNames.split(" ")) {
            try {
                Object o = getOpenEJBResource(ds);
                if (o instanceof DataSource) {
                    dataSources.put(ds, DataSource.class.cast(o));
                }
            }catch (NamingException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * @return the user selected data source if it is set
     *         or the default one
     *  @throws IllegalArgumentException if the data source is not found
     */
    @Override
    public DataSource getDataSource() {
        // lazy init of routed datasources
        if (dataSources == null) {
            init();
        }

        // if no datasource is selected use the default one
        if (currentDataSource.get() == null) {
            if (dataSources.containsKey(defaultDataSourceName)) {
                return dataSources.get(defaultDataSourceName);

            } else {
                throw new IllegalArgumentException("you have to specify at
least one datasource");
            }
        }

        // the developper set the datasource to use
        return currentDataSource.get();
    }

    /**
     *
     * @param datasourceName data source name
     */
    public void setDataSource(String datasourceName) {
        if (dataSources == null) {
            init();
        }
        if (!dataSources.containsKey(datasourceName)) {
            throw new IllegalArgumentException("data source called " +
datasourceName + " can't be found.");
        }
        DataSource ds = dataSources.get(datasourceName);
        currentDataSource.set(ds);
    }

    /**
     * reset the data source
     */
    public void clear() {
        currentDataSource.remove();
    }

    public void setDefaultDataSourceName(String name) {
        this.defaultDataSourceName = name;
    }

}

////////////////////////////////////////////////////////////////

@Stateless
public class RoutedPersister implements Serializable {
	private static final long serialVersionUID = -4630430944530409705L;
	final Logger log = LoggerFactory.getLogger(this.getClass());	

    @Resource(name="TsRouter", type = DeterminedRouter.class)
    private DeterminedRouter router;
	
	@PersistenceContext(unitName = "router")
    private EntityManager em;
	
	private RoutedPersister routedPersister;
	
	private String[] databases;
	private Properties properties;
	
    
	/**
	 * 
	 */
	public RoutedPersister() {
	}

	@PostConstruct
	public void init(){
		try{
		    databases = new String[]{"db1", "db2", "db3"};

		    properties = new Properties();
		    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
LocalInitialContextFactory.class.getName());

		    // resources
		    // datasources
		    for (int i = 1; i <= databases.length; i++) {
		        String dbName = databases[i - 1];
		        properties.setProperty(dbName, "new://Resource?type=DataSource");
		        dbName += ".";
		        properties.setProperty(dbName + "JdbcDriver",
"com.mysql.jdbc.Driver");
		        properties.setProperty(dbName + "JdbcUrl",
"jdbc:mysql://domain.com:3306/" + i);
		        properties.setProperty(dbName + "UserName", "username");
		        properties.setProperty(dbName + "Password", "password");
		        properties.setProperty(dbName + "JtaManaged", "true");
		    }

		    // router
		    properties.setProperty("TsRouter",
"new://Resource?provider=org.router:DeterminedRouter&type=" +
DeterminedRouter.class.getName());
		    properties.setProperty("TsRouter.DatasourceNames", "db1 db2 db3");
		    properties.setProperty("TsRouter.DefaultDataSourceName", "db1");

		    // routed datasource
		    properties.setProperty("Routed Datasource",
"new://Resource?provider=RoutedDataSource&type=" + Router.class.getName());
		    properties.setProperty("Routed Datasource.Router", "TsRouter");

		    Context ctx =
EJBContainer.createEJBContainer(properties).getContext();
		    routedPersister = (RoutedPersister)
ctx.lookup("java:global/dynamic-datasource-routing/RoutedPersister");
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
    public RoutedPersister getRoutedPersister() {
		return routedPersister;
	}

	public void setRoutedPersister(RoutedPersister routedPersister) {
		this.routedPersister = routedPersister;
	}

	public void persist(int id, String name, String ds) {
        router.setDataSource(ds);
//        em.persist(new Person(id, name));
    }

}

////////////////////////////////////////////////////////////////////////////

<?xml version="1.0" encoding="UTF-8"?>
<ServiceJar>
	
  	<ServiceProvider id="TsRouter" 
     	service="Resource"
      	type="org.apache.openejb.resource.jdbc.Router"
      	class-name="test.datasources.DeterminedRouter"
      	> 

    	# the parameters

    	DataSourceNames
    	DefaultDataSourceName
  	</ServiceProvider>
</ServiceJar>

I placed this file in WEB-INF/classes/META-INF/org.router/service-jar.xml

When I run it I get the following error message:

Mar 16, 2014 4:07:23 PM org.apache.tomee.catalina.TomcatWebAppBuilder
startInternal
SEVERE: Unable to deploy collapsed ear in war
StandardEngine[Catalina].StandardHost[l
ocalhost].StandardContext[/rls]
org.apache.openejb.OpenEJBException: Can't find resource for class
test.datas
ources.RoutedPersister#router. (No provider available for resource-ref
'null' of type
 'test.datasources.DeterminedRouter' for 'rls.Comp1509825954'.)
        at
org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:11
74)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:858)
        at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:193)
        at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationF
actory.java:396)
        at
org.apache.openejb.config.ConfigurationFactory.configureApplication(Config
urationFactory.java:938)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBu
ilder.java:1171)
        at
org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppB
uilder.java:1051)
        at
org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListe
nerSupport.java:127)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupp
ort.java:119)
        at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.ja



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668232.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I don't get the difference, remove the datasource parameter and that's
the same. You can take this project it is self contained.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-03-16 20:36 GMT+01:00 onyii5119 <on...@gmail.com>:
> Thanks Romain. Not exactly what I am looking for. In your case the
> datasources are hard coded in resources. I want the datasources to be
> generated dynamically. In which case the params will be read from a
> database. All I am looking for is a simple example that works, zip it up
> then I can try.
>
> Thanks again.
> Jonathan
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668230.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
Thanks Romain. Not exactly what I am looking for. In your case the
datasources are hard coded in resources. I want the datasources to be
generated dynamically. In which case the params will be read from a
database. All I am looking for is a simple example that works, zip it up
then I can try.

Thanks again.
Jonathan




--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668230.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well if you don't want to look the doc prepare a ready to run sample
with your conf showing it fails (mvn package tomee:run).

btw this sample has it
http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/polling-parent/polling-web/
( http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/polling-parent/polling-web/src/main/java/jug/routing/
) and here resources definitions
http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/polling-parent/polling-web/src/main/resources/META-INF/resources.xml
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-03-16 19:30 GMT+01:00 onyii5119 <on...@gmail.com>:
> Does anyone have a simple *working example* of dynamic dataSource I can learn
> from? Don't point me to documentations, I tried most and they don't work for
> me.
>
> Thanks.
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668226.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
Does anyone have a simple *working example* of dynamic dataSource I can learn
from? Don't point me to documentations, I tried most and they don't work for
me.

Thanks.



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4668226.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Maybe i was not clear: define the router = define it in resources not only
in java
Le 2 oct. 2012 20:43, "Romain Manni-Bucau" <rm...@gmail.com> a écrit :

> Polling example use it, please say what you dont get
> Le 2 oct. 2012 20:17, "onyii5119" <on...@gmail.com> a écrit :
>
>> If you take a look at my code, you see that I defined and registered a
>> router. Please clarify your statement or post a code snippet.
>>
>> Thanks.
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4657760.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Polling example use it, please say what you dont get
Le 2 oct. 2012 20:17, "onyii5119" <on...@gmail.com> a écrit :

> If you take a look at my code, you see that I defined and registered a
> router. Please clarify your statement or post a code snippet.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4657760.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
If you take a look at my code, you see that I defined and registered a
router. Please clarify your statement or post a code snippet.

Thanks.



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4657760.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok for datasources but you need to define the router itself

*Romain Manni-Bucau*
*Twitter: @rmannibucau*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*




2012/9/27 onyii5119 <on...@gmail.com>

> Hi Romain,
>
> If you look at the code I attached in my last email, you will notice I
> followed the example you have for Dynamic DataSource. I will like to model
> my solution like the Test example where datasource params are set in
> properties. In my code Tomee is not seeing my Stateless bean  (can't be
> lookedup).* I don't want to use Tomee.xml or resource.xml to define my
> datasources. * Everything should be dynamic.
>
> I have done a similar thing in the program I am trying to migrate to Tomee.
> This is one of the bottle necks I am having with Tomee but I don't want to
> give up because I love what I am seeing so far in Tomee.
>
> Your help will be appreciated in resolving this issue.
>
> Thanks,
> Jonathan
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4657671.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Dynamic DataSource - Exception

Posted by onyii5119 <on...@gmail.com>.
Hi Romain,

If you look at the code I attached in my last email, you will notice I
followed the example you have for Dynamic DataSource. I will like to model
my solution like the Test example where datasource params are set in
properties. In my code Tomee is not seeing my Stateless bean  (can't be
lookedup).* I don't want to use Tomee.xml or resource.xml to define my
datasources. * Everything should be dynamic.

I have done a similar thing in the program I am trying to migrate to Tomee.
This is one of the bottle necks I am having with Tomee but I don't want to
give up because I love what I am seeing so far in Tomee.

Your help will be appreciated in resolving this issue. 

Thanks,
Jonathan
 



--
View this message in context: http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4657671.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Looks very close to our canonical example:
http://tomee.apache.org/examples-trunk/dynamic-datasource-routing/README.html
 Le 25 juil. 2015 21:35, "mailtolijo" <ma...@gmail.com> a écrit :

> Please visit http://result4sure.blogspot.in/ for this
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4675599.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Dynamic DataSource - Exception

Posted by mailtolijo <ma...@gmail.com>.
Please visit http://result4sure.blogspot.in/ for this



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657p4675599.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Dynamic DataSource - Exception

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

Seems you miss some router config. Did you follow
http://tomee.apache.org/dynamic-datasource.html ?

Now i think the router can be defined using class-name in resources.xml
directly (not sure but could avoid the service-jar.xml)

Btw this example uses it
http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/polling-parent/polling-web/

- Romain
Le 27 sept. 2012 00:24, "onyii5119" <on...@gmail.com> a écrit :

> I was just trying out Dynamic DataSource but could not get it to work. I
> was
> getting the exception below. I have attached a zip of the source code. I am
> using Tomee 1.1.0 snapshot. I use Hibernate mapping. I don't want the
> datasources defined in Tomee.xml. ccms.zip
> <http://openejb.979440.n4.nabble.com/file/n4657657/ccms.zip>
>
> Any help would be appreciated.
>
> Thanks,
> Jonathan Ekwempu
>
>
> INFO: -------------------------
> TomcatWebAppBuilder.init /ccms
> Sep 26, 2012 6:06:14 PM org.apache.openejb.util.JarExtractor extract
> INFO: Extracting jar: C:\apache-tomee-1.1.0-snapshot\webapps\ccms.war
> Sep 26, 2012 6:06:14 PM org.apache.openejb.util.JarExtractor extract
> INFO: Extracted path: C:\apache-tomee-1.1.0-snapshot\webapps\ccms
> Sep 26, 2012 6:06:15 PM org.apache.openejb.config.DeploymentLoader
> addFacesConfigs
> INFO: faces config file is null
> Sep 26, 2012 6:06:15 PM org.apache.openejb.config.ConfigurationFactory
> configureApplication
> INFO: Configuring enterprise application:
> C:\apache-tomee-1.1.0-snapshot\webapps\ccms
> Sep 26, 2012 6:06:16 PM
> org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans
> getLookupMethod
> WARNING: Method 'lookup' is not available for 'javax.annotation.Resource'.
> Probably using an older Runtime.
> Sep 26, 2012 6:06:16 PM org.apache.openejb.config.InitEjbDeployments deploy
> INFO: Auto-deploying ejb CommonService:
> EjbDeployment(deployment-id=CommonService)
> Sep 26, 2012 6:06:16 PM org.apache.catalina.core.ContainerBase removeChild
> SEVERE: ContainerBase.removeChild: destroy:
> org.apache.catalina.LifecycleException: An invalid Lifecycle transition was
> attempted ([before_destroy]) for component [
> StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ccms]] in
> state [STARTING_PREP]
>         at
>
> org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:408)
>         at
> org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:298)
>         at
> org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:952)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:931)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:786)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:619)
> Sep 26, 2012 6:06:16 PM org.apache.tomee.catalina.TomcatWebAppBuilder
> startInternal
> SEVERE: Unable to deploy collapsed ear in war /ccms: Exception: No provider
> available for resource-ref 'null' of type 'c
> om.tobisoft.datasource.router.TsDataSourceRouter' for 'CommonService'.
> org.apache.openejb.OpenEJBException: No provider available for resource-ref
> 'null' of type 'com.tobisoft.datasource.rout
> er.TsDataSourceRouter' for 'CommonService'.
>         at
>
> org.apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java:1717)
>         at
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1710)
>         at
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1661)
>         at
>
> org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1060)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:816)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
>         at
>
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:342)
>         at
>
> org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:825)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:781)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:619)
> Sep 26, 2012 6:06:16 PM org.apache.catalina.core.ContainerBase
> addChildInternal
> SEVERE: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start component
> [StandardEngine[Catalina].StandardHost[localhost].Stan
> dardContext[/ccms]]
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by: org.apache.tomee.catalina.TomEERuntimeException:
> org.apache.openejb.OpenEJBException: No provider available f
> or resource-ref 'null' of type
> 'com.tobisoft.datasource.router.TsDataSourceRouter' for 'CommonService'.
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:790)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:736)
>         at
>
> org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
>         at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>         at
>
> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>         at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
>         at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>         ... 11 more
> Caused by: org.apache.openejb.OpenEJBException: No provider available for
> resource-ref 'null' of type 'com.tobisoft.data
> source.router.TsDataSourceRouter' for 'CommonService'.
>         at
>
> org.apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java:1717)
>         at
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1710)
>         at
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1661)
>         at
>
> org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1060)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:816)
>         at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:178)
>         at
>
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:342)
>         at
>
> org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:825)
>         at
>
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:781)
>         ... 17 more
> Sep 26, 2012 6:06:16 PM org.apache.catalina.startup.HostConfig deployWAR
> SEVERE: Error deploying web application archive
> C:\apache-tomee-1.1.0-snapshot\webapps\ccms.war
> java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException: Failed to start
> component
> [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ccms]]
>         at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
>         at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
>         at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
>         at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
>         at
> org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>         at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:619)
> Sep 26, 2012 6:06:16 PM org.apache.catalina.startup.HostConfig
> deployDirectory
> INFO: Deploying web application directory
> C:\apache-tomee-1.1.0-snapshot\webapps\docs
> Sep 26, 2012 6:06:16 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
> INFO: -------------------------
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Dynamic-DataSource-Exception-tp4657657.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>