Hi Cheng, I got one step further....
If I specify the remote-interface in web.xml using
<remote>[interface]</remote>
then I do not get the NPE but instead I get the exception which I get when
using the corba interop name syntax directly for the lookup ...
[#|2011-12-19T11:29:21.969+0100|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=95;_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
=com.painstakingminds.ejb.CalcBeanRemote,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:iiop:localhost:3700#ejb/Calc__3_x_Internal_RemoteBusinessHome__'
[Root exception is org.omg.CORBA.BAD_PARAM: FINE: IOP00100009:
string_to_object conversion failed due to bad schema specific part in name
ejb/Calc__3_x_Internal_RemoteBusinessHome__ vmcid: SUN minor code: 9
completed: No]]
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:411)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
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)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.naming.NamingException: Exception resolving Ejb for
'Remote ejb-ref name=ejb/Calculator,Remote 3.x interface
=com.painstakingminds.ejb.CalcBeanRemote,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:iiop:localhost:3700#ejb/Calc__3_x_Internal_RemoteBusinessHome__'
[Root exception is org.omg.CORBA.BAD_PARAM: FINE: IOP00100009:
string_to_object conversion failed due to bad schema specific part in name
ejb/Calc__3_x_Internal_RemoteBusinessHome__ vmcid: SUN minor code: 9
completed: No]
at
com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:178)
at
com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1106)
at
com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
at
com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
at
com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:172)
at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
... 33 more
Caused by: org.omg.CORBA.BAD_PARAM: FINE: IOP00100009: string_to_object
conversion failed due to bad schema specific part in name
ejb/Calc__3_x_Internal_RemoteBusinessHome__ vmcid: SUN minor code: 9
completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at
com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
at
com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:95)
at
com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.handleFullLogging(WrapperGenerator.java:387)
at
com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator.access$400(WrapperGenerator.java:107)
at
com.sun.corba.ee.spi.orbutil.logex.WrapperGenerator$2.invoke(WrapperGenerator.java:511)
at
com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:99)
at $Proxy133.soBadSchemaSpecific(Unknown Source)
at
com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveCorbaname(INSURLOperationImpl.java:227)
at
com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveINSURL(INSURLOperationImpl.java:154)
at
com.sun.corba.ee.impl.resolver.INSURLOperationImpl.operate(INSURLOperationImpl.java:145)
at
com.sun.corba.ee.impl.orb.ORBImpl.string_to_object(ORBImpl.java:976)
at
com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:171)
... 38 more
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:
omg.org/CosNaming/NamingContext/NotFound:1.0
at
org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
at
org.omg.CosNaming._NamingContextExtStub.resolve_str(_NamingContextExtStub.java:165)
at
com.sun.corba.ee.impl.resolver.INSURLOperationImpl.resolveCorbaname(INSURLOperationImpl.java:222)
... 42 more
If I don't use the corba interop name syntax but the portal or GlassFish
specific JNDI name if works.
Any additional pointers available?
TIA,
Bernhard
On Fri, Dec 16, 2011 at 5:33 PM, Cheng Fang <cheng.fang_at_oracle.com> 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<http://forums.java.net/node/873593>
>>>
>>>
>>>
>>>
>>
>>
--
IT-Consulting Bernhard Thalmayr
- Painstaking Minds -
83620 Vagen (Munich area)
Germany