Hi,
I've found my problem related to the NullPointerException when i made a
lookup remoting object. In fact i used differents versions of OpenEJB !!!
For the client side it was OpenEJB version 3.1 and for the server side (with
OSGi bundles) it was OpenEJB version 3.1.1-SNAPSHOT. So now with the same
version it's working.
I can communicate with an OSGi embedded EJB server thanks to the ejbd
protocol.
But i always need to start in explicitly way an ejbd server from a bundle.
Mickael
Keulkeul wrote:
>
> Below, you find the Java code related to the call of EJB in remoting way.
>
> try {
> Properties properties = new Properties();
> properties.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.openejb.client.RemoteInitialContextFactory");
> properties.put(Context.PROVIDER_URL, "ejbd://localhost:" + "4202");
>
> InitialContext context = new InitialContext(properties);
>
> NamingEnumeration<Binding> listBindings = context.listBindings("");
> Map<String, Object> map = new HashMap<String, Object>();
> while (listBindings.hasMoreElements()) {
> Binding pair = listBindings.nextElement();
> System.out.println(pair.getName());
> // map.put(pair.getName(), pair.getObject());
> }
>
> Object ref = context.lookup("EchoImplRemote");
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> I can't lookup remoting object because a nullpointer exception is thrown.
> But i can enumerate EJB naming.
>
> .
> EchoImplRemote
> EJBBonjourRemote
> java.lang.NullPointerException
> at
> org.apache.openejb.client.JNDIContext.createBusinessObject(JNDIContext.java:203)
> at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:247)
> at javax.naming.InitialContext.lookup(InitialContext.java:392)
> at test.openejb.remote.StandaloneClient.main(StandaloneClient.java:84)
>
>
> From the OpenEJB server side logs, i notice that there is one method have
> been invoked
>
> INFO - invoking method create on EchoImpl
> DEBUG - finished invoking method create. Return
> value:proxy=fr.ensma.lisi.testejbbundle.Echo;deployment=EchoImpl;pk=null
> DEBUG - JNDI REQUEST: JNDI_LOOKUP:null:EchoImplRemote -- RESPONSE:
> JNDI_BUSINESS_OBJECT:STATELESS:EchoImpl:fr.ensma.lisi.testejbbundle.Echo
> DEBUG - JNDI REQUEST: JNDI_LOOKUP:null:EchoImplRemote -- RESPONSE:
> JNDI_BUSINESS_OBJECT:STATELESS:EchoImpl:fr.ensma.lisi.testejbbundle.Echo
>
> As you can see, pk value is null
>
> Thanks a lot
>
> Mickael
>
>
>
> Jonathan Gallimore-2 wrote:
>>
>> That looks good to me- I did have a look around the code, and your
>> suggestion was pretty much what I was thinking. I didn't get enough
>> time to get it working due to work commitments. I'm away for a couple
>> of days, but will keep playing with this if I can.
>>
>> Can you send the stack trace for your NullPointerException?
>>
>> Cheers,
>>
>> Jon
>>
>> Sent from my iPhone
>>
>> On 13 Jun 2009, at 08:38, Keulkeul <[email protected]> wrote:
>>
>>>
>>> Hi,
>>>
>>> I just noticed that to try to execute OpenEJB container in remotable
>>> context, i was creating new InitialContext object (with
>>> openejb.embedded.remotable key initialization) into the start method
>>> of the
>>> TestEJB bundle.
>>>
>>> Bundle bundle = context.getBundle();
>>> OpenEjbApplication application = new OpenEjbApplication(bundle);
>>> context.registerService(OpenEjbApplication.class.getName(),
>>> application,
>>> null);
>>>
>>> // New Instructions ...
>>> Properties properties = new Properties();
>>> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>> properties.setProperty("openejb.embedded.remotable", "true");
>>>
>>> new InitialContext(properties);
>>>
>>> I think it is wrong way, because i suppose that the
>>> openejb.embedded.remotable parameter must be activated into the
>>> classes of
>>> the org.apache.openejb.server bundle.
>>>
>>> So now, i am trying to create an EJBD server in explicity way.
>>> Thanks to the
>>> JUnit class tests of OpenEJB, i have created an EJBD server into the
>>> OpenEJBServer class of the org.apache.openejb.server bundle, like
>>> this:
>>>
>>> public void init(File baseDir) throws OpenEJBException {
>>> ...
>>> properties.put("openejb.home", homeDir.getAbsolutePath());
>>> properties.put("openejb.base", baseDir.getAbsolutePath());
>>> properties.put("openejb.configuration",
>>> configFile.getAbsolutePath());
>>> properties.put("openejb.deployments.classpath", "false");
>>>
>>> OpenEJB.init(properties);
>>>
>>> EjbServer ejbServer = new EjbServer();
>>> Properties initProps = new Properties();
>>> try {
>>> ejbServer.init(initProps);
>>> ServiceDaemon serviceDaemon = new ServiceDaemon(ejbServer, 0,
>>> "localhost");
>>> serviceDaemon.start();
>>> } catch (Exception e) {
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>> So, the EJBD server is created. I can connect a standalone
>>> application to
>>> EJBD protocol (it's working), i can enumerate EJB naming (it's
>>> working).
>>>
>>> But i can't to lookup object because a nullpointer exception is
>>> thrown. I
>>> suppose the classpath isn't initialized into the EJBD server
>>> configuration
>>> ...
>>>
>>> Do you think i'm crazy to do like this ?
>>>
>>> Mickael
>>>
>>>
>>> Jonathan Gallimore-2 wrote:
>>>>
>>>> That's a total guess on my part. I'm going have a quick play around
>>>> with
>>>> this now, I'll let you know if I get it going :)
>>>>
>>>> Jon
>>>>
>>>> On Thu, Jun 11, 2009 at 8:26 PM, Keulkeul <[email protected]>
>>>> wrote:
>>>>
>>>>>
>>>>> Hi Jonathan,
>>>>>
>>>>> Thanks for your replying.
>>>>>
>>>>> Your said "so I suspect that either the setting you're applying
>>>>> isn't
>>>>> being
>>>>> passed through to the OpenEJB server in the bundle". I don't think
>>>>> so
>>>>> because when i'm setting InitialContext with
>>>>> openejb.embedded.remotable
>>>>> key
>>>>> value, it is taken into account because the following message is
>>>>> displaying
>>>>>
>>>>> ** Starting Services **
>>>>> NAME IP PORT
>>>>>
>>>>> Mickael
>>>>>
>>>>>
>>>>>
>>>>> Jonathan Gallimore-2 wrote:
>>>>>>
>>>>>> I had to comment something out in terms of applying properties to
>>>>>> the
>>>>>> embedded OpenEJB in the code I put up on my people.apache.org
>>>>>> page, as
>>>>> I
>>>>>> was
>>>>>> getting a ConcurrentModificationException with the code left in,
>>>>>> so I
>>>>>> suspect that either the setting you're applying isn't being passed
>>>>> through
>>>>>> to the OpenEJB server in the bundle.
>>>>>>
>>>>>> I'll have a poke around the code this evening and see if I can
>>>>>> get it
>>>>>> working with remotable working.
>>>>>>
>>>>>> Jon
>>>>>>
>>>>>> On Wed, Jun 10, 2009 at 3:45 PM, Keulkeul <[email protected]>
>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am using OpenEJB 3.1.1 with the Equinox OSGi container thanks to
>>>>> this
>>>>>>> post
>>>>>>> (http://openejb.apache.org/osgi-openejb.html) and this topic
>>>>>>> (http://www.nabble.com/OpenEJB-and-OSGi-td23423565.html#a23423565)
>>>>>>> related
>>>>>>> to the OpenEJB OSGi integration. I can create one bundle with
>>>>>>> several
>>>>> EJB
>>>>>>> stateless POJOs and it is working fine.
>>>>>>>
>>>>>>> So now, i would like to implement WebServices in using EJB
>>>>>>> Stateless
>>>>>>> annoted
>>>>>>> with the @stateless and @Webservice instructions (like
>>>>>>> HelloEjbService
>>>>>>> class
>>>>>>> example located into the openejb-examples-3.1 examples package).
>>>>>>>
>>>>>>> However, i have a problem during the initialization of the OpenEJB
>>>>>>> InitialContext. I suppose that OpenEJB must be executed in
>>>>>>> remotable
>>>>>>> context, so openejb.embedded.remotable key is fixed to true value.
>>>>> But,
>>>>>>> no
>>>>>>> server (httpejbd, ejbd) have been created.
>>>>>>>
>>>>>>> With OpenEJB OSGi integration i'm getting
>>>>>>>
>>>>>>> ** Starting Services **
>>>>>>> NAME IP PORT
>>>>>>>
>>>>>>> In opposition, without OpenEJB OSGi integration i was getting
>>>>>>>
>>>>>>> ** Starting Services **
>>>>>>> NAME IP PORT
>>>>>>> httpejbd 127.0.0.1 4204
>>>>>>> admin thread 127.0.0.1 4200
>>>>>>> ejbd localhost 4202
>>>>>>>
>>>>>>> In fact, i would like your opinion about this issue.
>>>>>>>
>>>>>>> Is anybody test another kind of EJB into OpenEJB OSGi
>>>>>>> integration like
>>>>>>> WebService ? or just calling EJBs declared into a bundle in
>>>>>>> remote way
>>>>> ?
>>>>>>>
>>>>>>> Mickael
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>>
>>>>> http://www.nabble.com/OpenEJB%2C-OSGi-and-OpenEJB3%27s-remoting-capabilities-tp23963809p23963809.html
>>>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/OpenEJB%2C-OSGi-and-OpenEJB3%27s-remoting-capabilities-tp23963809p23987456.html
>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/OpenEJB%2C-OSGi-and-OpenEJB3%27s-remoting-capabilities-tp23963809p24010064.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/OpenEJB%2C-OSGi-and-OpenEJB3%27s-remoting-capabilities-tp23963809p24219992.html
Sent from the OpenEJB User mailing list archive at Nabble.com.