You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Charles Moulliard <cm...@gmail.com> on 2011/12/06 18:55:47 UTC
unit test with openejb on karaf
Hi,
I have deployed a EJB stateless bean (= Calculator example) in OpenEJB
running on Apache Karaf. It is deployed
2011-12-06 18:43:15,570 | INFO | FelixStartLevel | startup
| ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
4.0.0.beta-2-SNAPSHOT | Jndi(name=CalculatorBeanLocalBean) -->
Ejb(deployment-id=CalculatorBean)
2011-12-06 18:43:15,570 | INFO | FelixStartLevel | startup
| ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
4.0.0.beta-2-SNAPSHOT |
Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean)
--> Ejb(deployment-id=CalculatorBean)
2011-12-06 18:43:15,571 | INFO | FelixStartLevel | startup
| ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
4.0.0.beta-2-SNAPSHOT |
Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean) -->
Ejb(deployment-id=CalculatorBean)
But when in a unit test, I try to access it, that fails
Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
initialContext = new InitialContext(p);
Object object = initialContext.lookup("CalculatorBeanLocalBean");
javax.naming.NameNotFoundException: /CalculatorBeanLocalBean does not exist
in the system. Check that the app was successfully deployed.
at
org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:271)
What could be the reason/problem ?
Regards,
Charles
--
View this message in context: http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4165748.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: unit test with openejb on karaf
Posted by Jean-Louis MONTEIRO <je...@gmail.com>.
Hi Charles,
the openejb.embedded.remotable system property must be set in the server
side (ie. Karaf). Otherwise, OpenEJB won't start remote services.
Jean-Louis
2011/12/7 Charles Moulliard <cm...@gmail.com>
> Same error if I use this config too.
>
> protected void setUp() throws Exception {
> Properties p = new Properties();
> p.put("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
> p.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
> p.put("openejb.authentication.realmName", "karaf");
> p.put("openejb.embedded.remotable","true");
> initialContext = new InitialContext(p);
>
> //Object object =
>
> initialContext.lookup("global/simple-stateless-1.1-SNAPSHOT/CalculatorBean");
> Object object = initialContext.lookup("CalculatorBeanLocalBean");
> CalculatorBean calculator = (CalculatorBean)object;
>
> }
>
> /**
> * Test Add method
> */
> public void testAdd() throws NamingException {
>
> assertEquals(10, calculator.add(4, 6));
>
> }
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4167776.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: unit test with openejb on karaf
Posted by Charles Moulliard <cm...@gmail.com>.
I make a test with a standalone openejb 4.0.0-beta-2 and have also the same
error.
so if my bean is registered like that
App(id=/Users/charlesmoulliard/MyApplications/apache-openejb-4.0.0-beta-2-SNAPSHOT/apps/simple-stateless-1.1-SNAPSHOT.jar)
EjbJar(id=simple-stateless-1.1-SNAPSHOT,
path=/Users/charlesmoulliard/MyApplications/apache-openejb-4.0.0-beta-2-SNAPSHOT/apps/simple-stateless-1.1-SNAPSHOT.jar)
Ejb(ejb-name=CalculatorBean, id=CalculatorBean)
Jndi(name=CalculatorBeanLocalBean)
Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean)
Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean)
How Can I have access to it using jndi lookup ?
--
View this message in context: http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4168309.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: unit test with openejb on karaf
Posted by Charles Moulliard <cm...@gmail.com>.
Same error if I use this config too.
protected void setUp() throws Exception {
Properties p = new Properties();
p.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
p.put("openejb.authentication.realmName", "karaf");
p.put("openejb.embedded.remotable","true");
initialContext = new InitialContext(p);
//Object object =
initialContext.lookup("global/simple-stateless-1.1-SNAPSHOT/CalculatorBean");
Object object = initialContext.lookup("CalculatorBeanLocalBean");
CalculatorBean calculator = (CalculatorBean)object;
}
/**
* Test Add method
*/
public void testAdd() throws NamingException {
assertEquals(10, calculator.add(4, 6));
}
--
View this message in context: http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4167776.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: unit test with openejb on karaf
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Did you add openejb.embedded.remotable (system) property on your server?
- Romain
Le 6 déc. 2011 20:23, "Charles Moulliard" <cm...@gmail.com> a écrit :
> Same error if @remote is added
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4165869.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: unit test with openejb on karaf
Posted by Charles Moulliard <cm...@gmail.com>.
Same error if @remote is added
--
View this message in context: http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4165869.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: unit test with openejb on karaf
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,
I don't remember if calculator is annotated @Remote, i though no.
- Romain
Le 6 déc. 2011 18:59, "Charles Moulliard" <cm...@gmail.com> a écrit :
> Hi,
>
> I have deployed a EJB stateless bean (= Calculator example) in OpenEJB
> running on Apache Karaf. It is deployed
>
> 2011-12-06 18:43:15,570 | INFO | FelixStartLevel | startup
> | ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
> 4.0.0.beta-2-SNAPSHOT | Jndi(name=CalculatorBeanLocalBean) -->
> Ejb(deployment-id=CalculatorBean)
> 2011-12-06 18:43:15,570 | INFO | FelixStartLevel | startup
> | ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
> 4.0.0.beta-2-SNAPSHOT |
>
> Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean)
> --> Ejb(deployment-id=CalculatorBean)
> 2011-12-06 18:43:15,571 | INFO | FelixStartLevel | startup
> | ache.openejb.util.Slf4jLogStream 86 | 179 - org.apache.openejb.core -
> 4.0.0.beta-2-SNAPSHOT |
> Jndi(name=global/simple-stateless-1.1-SNAPSHOT/CalculatorBean) -->
> Ejb(deployment-id=CalculatorBean)
>
> But when in a unit test, I try to access it, that fails
>
> Properties p = new Properties();
> p.put("java.naming.factory.initial",
> "org.apache.openejb.client.RemoteInitialContextFactory");
> p.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
> initialContext = new InitialContext(p);
> Object object = initialContext.lookup("CalculatorBeanLocalBean");
>
> javax.naming.NameNotFoundException: /CalculatorBeanLocalBean does not exist
> in the system. Check that the app was successfully deployed.
> at
> org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:271)
>
> What could be the reason/problem ?
>
> Regards,
>
> Charles
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/unit-test-with-openejb-on-karaf-tp4165748p4165748.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>