Hi
Did you try 1.6.0 snapshot?
Le 1 mai 2013 20:37, "OCal" <[email protected]> a écrit :
> I created a small application with datasource definition in resources.xml.
> It
> works without any error in TomEE 1.5.1 however, 1.5.2 does not recognize
> this and datasource does not get created. I am running both servers in
> Eclipse. Here is how it is done and error messages:
>
> WEB-INF/resources.xml:
>
> ---------------------------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <tomee>
> <Resource id="defaultDS" type="DataSource">
> JdbcDriver com.mysql.jdbc.Driver
> JdbcUrl
> jdbc:mysql://localhost:3306/testdb?zeroDateTimeBehavior=convertToNull
> UserName testdb
> Password SomePass
> JtaManaged false
> MaxActive 20
> MaxIdle 5
> MaxWait 10000
> </Resource>
> </tomee>
>
> WEB-INF/web.xml
>
> ---------------------------------------------------------------------------------------------
> . . .
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>defaultDS</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> </resource-ref>
> . . .
>
> And my code goes something like this:
>
> ---------------------------------------------------------------------------------------------
> . . .
> private DataSource getDataSourceFromJNDI(String jndiDataSourceName) {
> try {
> InitialContext initialContext = new
> InitialContext();
> DataSource dataSource = (DataSource)
> initialContext.lookup("java:comp/env/defaultDS");
> return dataSource;
> } catch (NamingException e) {
> log.error("JNDI error while retrieving " +
> "java:comp/env/defaultDS", e);
> throw new AuthorizationException(e);
> }
> }
> . . .
>
> While this works great on 1.5.1, I get Exceptions in 1.5.2.
>
> -----------------------------------------------------------------------------------
> Error in database operation
> java.lang.ClassCastException: org.apache.openejb.core.ivm.naming.IvmContext
> cannot be cast to javax.sql.DataSource
> at
>
> com.example.test.remoteapp.core.utils.DBUtils.getDefaultDataSource(DBUtils.java:48)
> at
>
> com.example.test.remoteapp.core.http.SystemContextInitilizer.cleanUserSessions(SystemContextInitilizer.java:95)
> at
>
> com.example.test.remoteapp.core.http.SystemContextInitilizer.contextInitialized(SystemContextInitilizer.java:35)
> at
>
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
> at
>
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
> at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at
>
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
> at
>
> org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
> at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:722)
>
>
> I'm running from Eclipse Juno SR1 on JDK 1.7.0.21 on Windows 7 64bit. Both
> 1.5.1 and 1.5.2 are configured in Eclipse. The project uses dependencies
> from 1.5.2. Tried removing all servers and creating from scratch.
>
> Any help on this is appreciated.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Datasource-problem-with-TomEE-1-5-2-Works-in-1-5-1-tp4662607.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>