You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by padou <pm...@imtf.ch> on 2015/05/26 14:18:19 UTC

OpenEjb, Injection of datasource using "jboss naming"

Hello,

I have some unit test that works perfectly when I use 

@Resource ("jdbc/defaultDS")
Datasource ds ;

My project has been ported to jboss and I have to use:

@Resource ("java:/jdbc/defaultDS")
Datasource ds ;

I fixed the code:

from
...
properties.put ("jdbc/DefaultDS", "new://Resource?type=DataSource");
properties.put ("jdbc/DefaultDS.JdbcDriver", "org.h2.Driver");
properties.put ("jdbc/DefaultDS.JdbcUrl",
"jdbc:h2:mem:test;MODE=Oracle;MVCC=TRUE;AUTOCOMMIT=OFF;LOCK_MODE=3;LOG=2");
...
to 

properties.put ("java:/jdbc/DefaultDS", "new://Resource?type=DataSource");
properties.put ("java:/jdbc/DefaultDS.JdbcDriver", "org.h2.Driver");
properties.put ("java:/jdbc/DefaultDS.JdbcUrl",
"jdbc:h2:mem:test;MODE=Oracle;MVCC=TRUE;AUTOCOMMIT=OFF;LOCK_MODE=3;LOG=2");

The datasource is not injected in the beans...
I get:
....
May 26, 2015 2:27:38 PM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=java:/jdbc/DefaultDS, type=Resource,
provider-id=Default JDBC Database)
....
INFO: Auto-linking resource-ref 'java:/jdbc/DefaultDS' in bean
PermissionDAOBean to Resource(id=java:/jdbc/DefaultDS)
May 26, 2015 2:27:44 PM org.apache.openejb.config.AutoConfig
processResourceRef
...
*May 26, 2015 2:27:44 PM org.apache.openejb.config.JndiEncInfoBuilder insert
WARNING: Invalid referenceName suffix. name: java:/jdbc/DefaultDS.*
...
WARNING: Injection data not found in JNDI context:
jndiName='comp/env/test.persistency.impl.jaasgroup.PermissionDAOBean/dataSource',
target=test.persistency.impl.jaasgroup.PermissionDAOBean/dataSource
...
May 26, 2015 2:28:05 PM
org.apache.openejb.core.transaction.EjbTransactionUtil handleSystemException
SEVERE: EjbTransactionUtil.handleSystemException: null
java.lang.NullPointerException
        at
test.persistency.impl.jaasgroup.PermissionDAOBean.getPermission(PermissionDAOBean.java:204)
....

Any suggestions ?

Pat








--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Mark was right it is the 7.0.0-SNAPSHOT and not 5.0.0 but the repo is right


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-27 14:31 GMT+02:00 padou <pm...@imtf.ch>:

> Hello Romain,
> I tried to figure out what repository I should use...
> I checked in nexus here:
>
> https://repository.apache.org/content/groups/snapshots/org/apache/openejb/openejb-core/5.0.0-SNAPSHOT/
>
> but the latest snapshot is from Wed May 13 ...
>
> Did the build failed ?
>
> Thanks
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675055.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by padou <pm...@imtf.ch>.
Hello Romain,
I tried to figure out what repository I should use...
I checked in nexus here:
https://repository.apache.org/content/groups/snapshots/org/apache/openejb/openejb-core/5.0.0-SNAPSHOT/

but the latest snapshot is from Wed May 13 ...

Did the build failed ?

Thanks





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675055.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by Romain Manni-Bucau <rm...@gmail.com>.
right, think we got all version all over the threads from release 2.0.0,
here the 5.0.0 but all converge to 7.0.0 ;)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-27 8:57 GMT+02:00 Mark Struberg <st...@yahoo.de>:

> you mean 7.0.0-SNAPSHOT right?
>
> LieGrue,
> strub
>
>
> > Am 26.05.2015 um 18:14 schrieb Romain Manni-Bucau <rmannibucau@gmail.com
> >:
> >
> > Le 26 mai 2015 09:00, "padou" <pm...@imtf.ch> a écrit :
> >>
> >> Hello
> >>
> >> I saw that you already improved it
> >> Is there a way to test with a SNAPSHOT ? what version of openEJB should
> I
> >> use (I see it was committed in tomEE) ?
> >
> > 5.0.0-SNAPSHOT. Should be redeployed tomorrow
> >
> >> There is no way to use java:global or java:app with (only java:/ or
> >> java:jboss/ are supported by jboss)... Makes me crazy...
> >>
> >
> > java:global should on a EE6 server
> >
> >> Thanks
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675047.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>
>

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by Mark Struberg <st...@yahoo.de>.
you mean 7.0.0-SNAPSHOT right?

LieGrue,
strub


> Am 26.05.2015 um 18:14 schrieb Romain Manni-Bucau <rm...@gmail.com>:
> 
> Le 26 mai 2015 09:00, "padou" <pm...@imtf.ch> a écrit :
>> 
>> Hello
>> 
>> I saw that you already improved it
>> Is there a way to test with a SNAPSHOT ? what version of openEJB should I
>> use (I see it was committed in tomEE) ?
> 
> 5.0.0-SNAPSHOT. Should be redeployed tomorrow
> 
>> There is no way to use java:global or java:app with (only java:/ or
>> java:jboss/ are supported by jboss)... Makes me crazy...
>> 
> 
> java:global should on a EE6 server
> 
>> Thanks
>> 
>> 
>> 
>> 
>> --
>> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675047.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.


Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by hwaastad <he...@waastad.org>.
Wel,
i guess going back/from jboss you usually have this issue having to adjust
app anyway.

However, kudos for making tomee "jboss friendly"!

Br hw



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675051.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well it is still in the app so still not portable



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-26 14:15 GMT-07:00 hwaastad <he...@waastad.org>:

> Hi,
> would'nt it be better adding resource-ref to make it portable?
>
> br hw
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675049.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by hwaastad <he...@waastad.org>.
Hi,
would'nt it be better adding resource-ref to make it portable?

br hw




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675049.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 26 mai 2015 09:00, "padou" <pm...@imtf.ch> a écrit :
>
> Hello
>
> I saw that you already improved it
> Is there a way to test with a SNAPSHOT ? what version of openEJB should I
> use (I see it was committed in tomEE) ?

5.0.0-SNAPSHOT. Should be redeployed tomorrow

> There is no way to use java:global or java:app with (only java:/ or
> java:jboss/ are supported by jboss)... Makes me crazy...
>

java:global should on a EE6 server

> Thanks
>
>
>
>
> --
> View this message in context:
http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675047.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

Posted by padou <pm...@imtf.ch>.
Hello

I saw that you already improved it 
Is there a way to test with a SNAPSHOT ? what version of openEJB should I
use (I see it was committed in tomEE) ?
There is no way to use java:global or java:app with (only java:/ or
java:jboss/ are supported by jboss)... Makes me crazy...

Thanks




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044p4675047.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: OpenEjb, Injection of datasource using "jboss naming"

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

openejb binds by default resource in openejb:Resource. We support java:app
and java:global namespaces as well but java:/jdbc is not portable.

you should even get a warn "invalid reference suffix"

FYI: https://issues.apache.org/jira/browse/TOMEE-1592



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-26 14:18 GMT+02:00 padou <pm...@imtf.ch>:

> Hello,
>
> I have some unit test that works perfectly when I use
>
> @Resource ("jdbc/defaultDS")
> Datasource ds ;
>
> My project has been ported to jboss and I have to use:
>
> @Resource ("java:/jdbc/defaultDS")
> Datasource ds ;
>
> I fixed the code:
>
> from
> ...
> properties.put ("jdbc/DefaultDS", "new://Resource?type=DataSource");
> properties.put ("jdbc/DefaultDS.JdbcDriver", "org.h2.Driver");
> properties.put ("jdbc/DefaultDS.JdbcUrl",
> "jdbc:h2:mem:test;MODE=Oracle;MVCC=TRUE;AUTOCOMMIT=OFF;LOCK_MODE=3;LOG=2");
> ...
> to
>
> properties.put ("java:/jdbc/DefaultDS", "new://Resource?type=DataSource");
> properties.put ("java:/jdbc/DefaultDS.JdbcDriver", "org.h2.Driver");
> properties.put ("java:/jdbc/DefaultDS.JdbcUrl",
> "jdbc:h2:mem:test;MODE=Oracle;MVCC=TRUE;AUTOCOMMIT=OFF;LOCK_MODE=3;LOG=2");
>
> The datasource is not injected in the beans...
> I get:
> ....
> May 26, 2015 2:27:38 PM org.apache.openejb.config.ConfigurationFactory
> configureService
> INFO: Configuring Service(id=java:/jdbc/DefaultDS, type=Resource,
> provider-id=Default JDBC Database)
> ....
> INFO: Auto-linking resource-ref 'java:/jdbc/DefaultDS' in bean
> PermissionDAOBean to Resource(id=java:/jdbc/DefaultDS)
> May 26, 2015 2:27:44 PM org.apache.openejb.config.AutoConfig
> processResourceRef
> ...
> *May 26, 2015 2:27:44 PM org.apache.openejb.config.JndiEncInfoBuilder
> insert
> WARNING: Invalid referenceName suffix. name: java:/jdbc/DefaultDS.*
> ...
> WARNING: Injection data not found in JNDI context:
>
> jndiName='comp/env/test.persistency.impl.jaasgroup.PermissionDAOBean/dataSource',
> target=test.persistency.impl.jaasgroup.PermissionDAOBean/dataSource
> ...
> May 26, 2015 2:28:05 PM
> org.apache.openejb.core.transaction.EjbTransactionUtil
> handleSystemException
> SEVERE: EjbTransactionUtil.handleSystemException: null
> java.lang.NullPointerException
>         at
>
> test.persistency.impl.jaasgroup.PermissionDAOBean.getPermission(PermissionDAOBean.java:204)
> ....
>
> Any suggestions ?
>
> Pat
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/OpenEjb-Injection-of-datasource-using-jboss-naming-tp4675044.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>