File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot access sessionLocal

 
Dave Jian
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using WSAD 5.1 and create HelloWorld stateless session bean with local interface, but WSAD does not allow me to create reference to access the local and local home.It only has remote one. How should I do to fix this problem?

Thanks so much

DJ
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33713
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
If you create a local interface, WSAD automatically creates a JNDI name:
local:ejb/ejb/com/....

(Starting with com, substitute in the rest of the corresponding remote name.)

And welcome to JavaRanch!
 
Dave Jian
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your message. Still have a problem in JNDI lookup. Please give me some idea to fix it. Thanks again

Remote interface works as below:
JNDIName = "java:comp/env/ejb/HelloWorldSession";
initContext = new InitialContext();
Object obj = initContext.lookup(JNDIName);
helloWorldSessionHome =(HelloWorldSessionHome) PortableRemoteObject.narrow(
obj,
HelloWorldSessionHome.class);
Local interface does not work as replacing HelloWorldSession, or HelloWorldSessionLocal:
String JNDIName = "local:ejb/ejb/com/HelloWorldSession";
initContext = new InitialContext();
Object obj = initContext.lookup(JNDIName);//exception
helloWorldSessionLocalHome = (HelloWorldSessionLocalHome)obj;

javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: local
at com.ibm.ws.naming.jndicos.CNContextImpl.checkForUrlContext(CNContextImpl.java:2770)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1220)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at helloworld.ejb.clients.HelloWorldEJBTestClient.main(HelloWorldEJBTestClient.java:41)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.websphere.client.applicationclient.launchClient.createContainerAndLaunchApp(launchClient.java:616)
at com.ibm.websphere.client.applicationclient.launchClient.main(launchClient.java:420)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
 
Dave Jian
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried local:ejb/ejb/HolloWorldSessionLocalHome, it still the same error.

This is a session bean and I cannot create client reference for local. I believe server did it. When I use UTC, I can see the jndi tree from jndi explorer as:
[Local EJB beans]
ejb
helloworld
ejb
HelloWorldSessionHome(helloworld.ejb.EJSLocalStatelessHelloWorldSessionHome_293bfcaf)

but how can I use it to do the lookup code?

I tried
"local:ejb/ejb/helloworld/ejb/HelloWorldSessionLocalHome", it does not work eighter.

Here is the ejb descripter:

<session id="HelloWorldSession">
<ejb-name>HelloWorldSession</ejb-name>
<home>helloworld.ejb.HelloWorldSessionHome</home>
<remote>helloworld.ejb.HelloWorldSession</remote>
<local-home>helloworld.ejb.HelloWorldSessionLocalHome</local-home>
<local>helloworld.ejb.HelloWorldSessionLocal</local>
<ejb-class>helloworld.ejb.HelloWorldSessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33713
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
You still need the java:comp/env part before using the local path.

What type of client is this? Remember that only clients running on the server can access local interfaces. I've used local interfaces from servlets and EJBs. From the client, you have to use the application assembly tool to truly run on the server. It was more trouble than it was worth, so I just used a remote interface.
 
Dave Jian
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of client is this?

This is J2EE Hello World sample at http://devx.com/ibm/Article/16365/0/page/1

I try application client in the same ear file and it also includes ejb.jar

Please let me know if you have any further suggestion to access local interface from that client.

Thanks

DJ
 
r. zweers
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone found a solution for the problem above?? I'm running into the same issue.

Thanks in advance
 
Rajeev Shrivastava
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application client is only for Remote Interface guy's. You can not run local interface with that.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic