Topic
  • 4 replies
  • Latest Post - ‏2012-02-28T22:30:24Z by LaurentTCT
Kaplica
Kaplica
1 Post

Pinned topic Executing rules with remote ejb - jndi configuration error?

‏2011-08-22T13:35:32Z |
Hi,

I am able to execute the rules deployed on a development server by using an ant script on my local machine.This script prepares the JNDI InitialContext using the "jndi.properties" file and executes the main class that uses IlrEJB3SessionFactory and createStatelessSession() method.
When i try to execute the same class in another application deployed to WAS 7 on my local machine , it gets the error below.I debugged the applicaiton and saw that the "java.naming.provider.url=corbaloc:rir:/NameServiceServerRoot" property of the initial context is not the value that i specified in "jndi.properties" file.(my configuration was:java.naming.provider.url=corbaloc:iiop:10.21.12.112:19817 which is working with the ant script.) It is said that java.naming.provider.url is set from the first jndi.properties file that the classloader loads. My application's classloader configuration is set to "parent last",so i expect that the server loads my property file first.Websphere gets all the other properties defined in my jndi.properties file but the java.naming.provider.url is the only exceptional case.How can i change this property or is there another sample war that i can examine and learn how to execute rules using EJB? Any ideas?
8/22/11 15:49:43:610 EEST 0000001c SystemErr R ilog.rules.res.session.IlrSessionCreationException: An error occurred while the rule session was created.:
javax.naming.NameNotFoundException: Context: GMCIMIT893Node01Cell/nodes/GMCIMIT893Node01/servers/server1, name: ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote: First component in name ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote not found.
org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0

8/22/11 15:49:43:610 EEST 0000001c SystemErr R at ilog.rules.res.session.IlrEJB3SessionFactory.createStatelessSession(IlrEJB3SessionFactory.java:56)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at com.ykb.hmn.inf.coremanagement.service.internal.RuleExecutionController2.<init>(RuleExecutionController2.java:29)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at com.ykb.hmn.inf.coremanagement.service.internal.StoredProcedureRefreshmentService.validate(StoredProcedureRefreshmentService.java:132)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at java.lang.reflect.Method.invoke(Method.java:599)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
8/22/11 15:49:43:610 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:165)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:165)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:165)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:165)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:165)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at com.ykb.hmn.inf.core.service.aspect.profiler.ServiceProfiler.profile(ServiceProfiler.java:58)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at java.lang.reflect.Method.invoke(Method.java:599)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:160)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at $Proxy65.validate(Unknown Source)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at java.lang.reflect.Method.invoke(Method.java:599)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:60)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at java.util.concurrent.FutureTask.run(FutureTask.java:149)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
8/22/11 15:49:43:626 EEST 0000001c SystemErr R at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:113)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:97)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:458)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:185)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:148)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1449)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1384)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:785)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R Caused by: javax.naming.NameNotFoundException: Context: GMCIMIT893Node01Cell/nodes/GMCIMIT893Node01/servers/server1, name: ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote: First component in name ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote not found.
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.mapNotFoundException(CNContextImpl.java:4360)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1793)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1748)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1499)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:636)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at javax.naming.InitialContext.lookup(Unknown Source)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at ilog.rules.res.session.IlrEJB3SessionFactory.lookupAndNarrow(IlrEJB3SessionFactory.java:81)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at ilog.rules.res.session.IlrEJB3SessionFactory.createStatelessSession(IlrEJB3SessionFactory.java:54)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R ... 79 more
8/22/11 15:49:43:641 EEST 0000001c SystemErr R Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:543)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:2163)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(_NamingContextStub.java:538)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl$2.run(CNContextImpl.java:2792)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl$2.run(CNContextImpl.java:2788)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.util.CommonHelpers.retry(CommonHelpers.java:762)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:2786)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1789)
8/22/11 15:49:43:641 EEST 0000001c SystemErr R ... 87 more
Thanks,
Caner.
Updated on 2012-02-28T22:30:24Z at 2012-02-28T22:30:24Z by LaurentTCT
  • LaurentTCT
    LaurentTCT
    47 Posts

    Re: Executing rules with remote ejb - jndi configuration error?

    ‏2011-09-09T22:43:32Z  
    Hello,

    I saw indeed the same behavior with the 'java.naming.provider.url' property on my side.

    In any case, be aware is not very good practice to package a jndi.properties in a app, as it could also get picked up by other applications in the same server.

    That is why there are plans to re-introduce a way to set the jndi properties by API (like it was the case with the JRules EJB2 rule session API) in the EJB3 JRules rule session API. This way there is no conflict nor classloading issues.

    In the meantime, as workaround in your case could be to prefix the jndi name set through the session API with the server URL:

    IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();
    ...
    sessionFactory.setStatelessRemoteJndiName("iiop://<remoteHost:port>/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");
    or perform the session lookup with the Java API:
    IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();

    Properties props = new Properties();
    props.setProperty(Context.SECURITY_PRINCIPAL, "...");
    props.setProperty(Context.SECURITY_CREDENTIALS, "...");
    props.setProperty(Context.PROVIDER_URL, "...");
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "...");
    InitialContext context = new InitialContext(props);
    IlrStatelessSession session = (IlrStatelessSession)context.lookup(jndiName);
    ...

    I hope it helps,
    Laurent
  • SivaV
    SivaV
    1 Post

    Re: Executing rules with remote ejb - jndi configuration error?

    ‏2012-01-11T07:05:13Z  
    Hello,

    I saw indeed the same behavior with the 'java.naming.provider.url' property on my side.

    In any case, be aware is not very good practice to package a jndi.properties in a app, as it could also get picked up by other applications in the same server.

    That is why there are plans to re-introduce a way to set the jndi properties by API (like it was the case with the JRules EJB2 rule session API) in the EJB3 JRules rule session API. This way there is no conflict nor classloading issues.

    In the meantime, as workaround in your case could be to prefix the jndi name set through the session API with the server URL:

    IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();
    ...
    sessionFactory.setStatelessRemoteJndiName("iiop://<remoteHost:port>/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote");
    or perform the session lookup with the Java API:
    IlrEJB3SessionFactory sessionFactory = new IlrEJB3SessionFactory();

    Properties props = new Properties();
    props.setProperty(Context.SECURITY_PRINCIPAL, "...");
    props.setProperty(Context.SECURITY_CREDENTIALS, "...");
    props.setProperty(Context.PROVIDER_URL, "...");
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "...");
    InitialContext context = new InitialContext(props);
    IlrStatelessSession session = (IlrStatelessSession)context.lookup(jndiName);
    ...

    I hope it helps,
    Laurent
    Hello,
    I generated a SCA component for Rule App using support pac LA71. My RES is installed in WAS7. While I access the rule application I am getting a name not found exception. I am able to access the same using a standalone client. In the standalone client I created the remote context using below snippet
    Properties props = new Properties();
    props.setProperty(Context.PROVIDER_URL, providerUrl); //corbaloc:iiop:<host>:2811
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    InitialContext context = new InitialContext(props);
    IlrStatelessSession session = (IlrStatelessSession)context.lookup(jndiName);
    In SCA component generated code
    Remote JNDI name of stateless session is set as iiop://<host>:2811/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote
    While I invoke it I am getting a naming exception. Also I observed that it is not hitting the remote WAS, instead trying lookup the session in the local context. Could you please suggest me a way to make in look up the remote context.

    Thanks in advance.
    Siva
  • SystemAdmin
    SystemAdmin
    945 Posts

    Re: Executing rules with remote ejb - jndi configuration error?

    ‏2012-01-11T09:27:43Z  
    • SivaV
    • ‏2012-01-11T07:05:13Z
    Hello,
    I generated a SCA component for Rule App using support pac LA71. My RES is installed in WAS7. While I access the rule application I am getting a name not found exception. I am able to access the same using a standalone client. In the standalone client I created the remote context using below snippet
    Properties props = new Properties();
    props.setProperty(Context.PROVIDER_URL, providerUrl); //corbaloc:iiop:<host>:2811
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    InitialContext context = new InitialContext(props);
    IlrStatelessSession session = (IlrStatelessSession)context.lookup(jndiName);
    In SCA component generated code
    Remote JNDI name of stateless session is set as iiop://<host>:2811/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote
    While I invoke it I am getting a naming exception. Also I observed that it is not hitting the remote WAS, instead trying lookup the session in the local context. Could you please suggest me a way to make in look up the remote context.

    Thanks in advance.
    Siva
    Hi Siva,

    Could you try to change your code as follow:

    IlrEJB3SessionFactory session = (IlrEJB3SessionFactory)context.lookup(jndiName);
    sessionFactory.setRemote(true);
    ...

    and validate that the remote EJB is call?

    Nicol@s
  • LaurentTCT
    LaurentTCT
    47 Posts

    Re: Executing rules with remote ejb - jndi configuration error?

    ‏2012-02-28T22:30:24Z  
    • SivaV
    • ‏2012-01-11T07:05:13Z
    Hello,
    I generated a SCA component for Rule App using support pac LA71. My RES is installed in WAS7. While I access the rule application I am getting a name not found exception. I am able to access the same using a standalone client. In the standalone client I created the remote context using below snippet
    Properties props = new Properties();
    props.setProperty(Context.PROVIDER_URL, providerUrl); //corbaloc:iiop:<host>:2811
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
    InitialContext context = new InitialContext(props);
    IlrStatelessSession session = (IlrStatelessSession)context.lookup(jndiName);
    In SCA component generated code
    Remote JNDI name of stateless session is set as iiop://<host>:2811/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote
    While I invoke it I am getting a naming exception. Also I observed that it is not hitting the remote WAS, instead trying lookup the session in the local context. Could you please suggest me a way to make in look up the remote context.

    Thanks in advance.
    Siva
    Hello Siva,

    You do not need to (and should not) set the remote JNDI name of stateless session using the provider URL ("iiop://<host>:2811/ilog.rules.res.session.impl.ejb3.IlrStatelessSessionRemote") if you are looking up the session passing that same URL to the Java EJB API as shown in your code snippet.

    Appending the provider URL to the JNDI name is one way to workaround the fact that the provider URL does not get picked up from the jndi.properties, but if you are using the Java API, you are using another solution.

    In that case, you will keep the JNDI name as it is listed in the JRules 7.1 doc at "Rule Execution Server > Introducing Rule Execution Server > Rule Execution Server basics > JNDI bindings > Local and remote EJB bindings", and will simply replace the following line of our samples using the RES EJB3 client API (see our Hello World sample at http://www-01.ibm.com/support/docview.wss?uid=swg21461685):

    session = sessionFactory.createStatelessSession();

    with the code snippet we provided:

    Properties props = new Properties();
    props.setProperty(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2813"); //corbaloc:iiop:<host>:2811
    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
    InitialContext context = new InitialContext(props);
    session = (IlrStatelessSession)context.lookup(jndiName);
    Everything else remains the same : you still use the IlrEJB3SessionFactory to build the request object which you pass to the IlrStatelessSession to execute.

    I hope this makes sense,
    Laurent