users@glassfish.java.net

Re: GF 3.1.1 using CORBA interoperable naming syntax for ...

From: Bernhard Thalmayr <bernhard.thalmayr_at_painstakingminds.com>
Date: Sun, 18 Dec 2011 12:09:14 +0100

Thanks for the pointer Cheng, unfortunately this did not help. I still
get a NPE ..


[#|2011-12-18T12:01:57.549+0100|INFO|glassfish3.1.1|javax.enterprise.system.std.
com.sun.enterprise.server.logging|_ThreadID=22;_ThreadName=Thread-2;|javax.namin
g.NamingException: Lookup failed for 'java:comp/env/ejb/Calculator' in
SerialCon
text[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialIni
tContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rm
i.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming}
[Root exception is javax.naming.NamingException: Exception resolving Ejb
for 'Re
mote ejb-ref name=ejb/Calculator,Remote 3.x interface
=null,ejb-link=null,lookup
=,mappedName=,jndi-name=corbaname:iiop:localhost:3700#ejb/Calc,refType=Session'

. Actual (possibly internal) Remote JNDI name used for lookup is
'corbaname:iio
p:localhost:3700#ejb/Calc__3_x_Internal_RemoteBusinessHome__' [Root
exception is
  java.lang.NullPointerException]]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.jav
a:518)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.jav
a:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.painstakingminds.math.Calculator.doTotal(Calculator.java:14)
        at com.painstakingminds.web.EjbTest.processRequest(EjbTest.java:44)
        at com.painstakingminds.web.EjbTest.doGet(EjbTest.java:72)


..............


Caused by: javax.naming.NamingException: Exception resolving Ejb for
'Remote ejb
-ref name=ejb/Calculator,Remote 3.x interface
=null,ejb-link=null,lookup=,mapped
Name=,jndi-name=corbaname:iiop:localhost:3700#ejb/Calc,refType=Session'
. Actua
l (possibly internal) Remote JNDI name used for lookup is
'corbaname:iiop:localh
ost:3700#ejb/Calc__3_x_Internal_RemoteBusinessHome__' [Root exception is
java.la
ng.NullPointerException]
        at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNami
ngReferenceManagerImpl.java:178)
        at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbR
eferenceProxy.create(ComponentEnvManagerImpl.java:1106)
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(Glas
sfishNamingManagerImpl.java:776)
        at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(Glas
sfishNamingManagerImpl.java:744)
        at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.j
ava:172)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.jav
a:498)
        ... 33 more
Caused by: java.lang.NullPointerException
        at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768
)
        at org.glassfish.web.loader.WebappClassLoader.findLoadedClass0(WebappCla
ssLoader.java:2442)
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoade
r.java:1416)
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoade
r.java:1369)
        at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNami
ngReferenceManagerImpl.java:147)
        ... 38 more
|#]


in glassfish-web.xml 'classloader delegate=true' is set ... however this
would be the default for WebApp CL anyway.

Thanks and regards,
Bernhard


On 12/16/2011 05:33 PM, Cheng Fang wrote:
> Try
> glassfish-web.xml
> ...
> <ejb-ref>
> <ejb-ref-name>ejb/Calculator</ejb-ref-name>
> <jndi-name>corbaname:iiop:localhost:3700#ejb/Calc</jndi-name>
> </ejb-ref>
>
> Your list-jndi-entries output looks correct.
>
> If the webapp is running on v2.x, use sun-web.xml; if on v3.x, use
> either glassfish-web.xml (preferrred), or sun-web.xml.
>
> -cheng
>
> On 12/16/11 10:41 AM, Bernhard Thalmayr wrote:
>> On 12/14/2011 03:39 PM, forums_at_java.net wrote:
>>> The preferrred way is to declare portable ejb-ref (via web.xml,
>>> ejb-jar.xml,
>>> etc, or with annotation), and map the ejb-ref to its target in
>>> sun-ejb-jar.xml/sun-web.xml (GlassFish 2.x) or
>>> glassfish-ejb-jar.xml/glassfish-web.xml (GlassFish 3.x). Avoid directly
>>> looking up GlassFish-specific global names, or corba interop names with
>>> location info.
>>
>> Thanks for the pointers Cheng.
>>
>> I tried what you have suggested ... however it seems I did not do it
>> in a correct way.
>>
>> Components involded
>> Stateless Session Bean...
>>
>> ...
>> @Stateless(mappedName="ejb/Calc")
>> public class CalcBean implements CalcBeanRemote {
>>
>> public int sumItUp(int i, int j) {
>> return i + j;
>> }
>> }
>> ...
>>
>> Utility class
>>
>> public class Calculator {
>> public static int doTotal(int i, int j) {
>> int sum = 0;
>>
>> CalcBeanRemote calculator;
>> InitialContext ic = null;
>> try {
>> ic = new InitialContext();
>> calculator = (CalcBeanRemote)ic.lookup("java:comp/env/ejb/Calculator");
>> sum = calculator.sumItUp(i, j);
>> return sum;
>> } catch (Exception ex) {
>> ex.printStackTrace(System.out);
>> return sum;
>> }
>> }
>>
>> }
>>
>> Servlet which uses the utility class
>>
>> ...
>> int sum = Calculator.doTotal(i, j);
>> out.println("Sum: " + sum );
>> ...
>>
>>
>> Descriptors for Web-App:
>>
>> web.xml
>> ...
>> <ejb-ref>
>> <ejb-ref-name>ejb/Calculator</ejb-ref-name>
>> </ejb-ref>
>> ...
>>
>> glassfish-web.xml
>> ...
>> <ejb-ref>
>> <ejb-ref-name>ejb/Calculator</ejb-ref-name>
>> <jndi-name>corba:iiop:localhost:3700#ejb/Calc</jndi-name>
>> </ejb-ref>
>> ...
>>
>> This leads to
>>
>> [#|2011-12-16T16:37:42.756+0100|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=24;_ThreadName=Thread-2;|javax.naming.NamingException:
>> Lookup failed for 'java:comp/env/ejb/Calculator' in
>> SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
>> java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
>> java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root
>> exception is javax.naming.NamingException: Exception resolving Ejb for
>> 'Remote ejb-ref name=ejb/Calculator,Remote 3.x interface
>> =null,ejb-link=null,lookup=,mappedName=,jndi-name=corba:iiop:localhost:3700#ejb/Calc,refType=Session'
>> . Actual (possibly internal) Remote JNDI name used for lookup is
>> 'corba:iiop:localhost:3700#ejb/Calc#null' [Root exception is
>> java.lang.NullPointerException]]
>> at
>> com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
>>
>> at
>> com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
>>
>> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>> at com.painstakingminds.math.Calculator.doTotal(Calculator.java:14)
>> at com.painstakingminds.web.EjbTest.processRequest(EjbTest.java:44)
>> at com.painstakingminds.web.EjbTest.doGet(EjbTest.java:72)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
>>
>>
>> Listing the jndi ejb context shows ..
>>
>> ./asadmin list-jndi-entries --context ejb
>> Calc: javax.naming.Reference
>> mgmt: com.sun.enterprise.naming.impl.TransientContext
>> Calc__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
>> Calc#com.painstakingminds.ejb.CalcBeanRemote: javax.naming.Reference
>>
>> Unfortunately I'm still some kind of 'newbie' with regards to this EJB
>> stuff :-(.
>>
>> Could you please shed some light?
>>
>> TIA,
>> Bernhard
>>
>>
>>>
>>> The mapping can be portable global jndi name, GlassFish-specific global
>>> jndi
>>> name, or corba interop names.
>>>
>>> -Cheng
>>>
>>>
>>> --
>>>
>>> [Message sent by forum member 'cf126330']
>>>
>>> View Post: http://forums.java.net/node/873593
>>>
>>>
>>>
>>
>>
>


-- 
Painstaking Minds
IT-Consulting Bernhard Thalmayr
Herxheimer Str. 5, 83620 Vagen (Munich area), Germany
Tel: +49 (0)8062 7769174
Mobile: +49 (0)176 55060699
bernhard.thalmayr_at_painstakingminds.com - Solution Architect
This e-mail may contain confidential and/or privileged information.If 
you are not the intended recipient (or have received this email in 
error) please notify the sender immediately and delete this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.