This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How can i look up a EJB residing in different machine from client side?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai ,

How can i look up a EJB residing in different machine from client side?




this is my code...........i don't know what should i use as Initial Context Factory...................i am using a sun appserver 8............


package com.parx.lms.lmsdelegate;

import com.parx.lms.exception.LMSException;
import javax.naming.Context;
import javax .ejb.CreateException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import java.rmi.RemoteException;
import com.parx.lms.controller.*;
import com.parx.lms.vo.UserVo;
import com.parx.lms.exception.BusinessException;
import java.util.Hashtable;

import java.lang.*;

public class LmsDelegate{
private final static String JNDI_NAME="LmsBean";
private static String url="http://localhost:4848";

public static Lms lms = null;
public void getController() throws CreateException,
NamingException,RemoteException{
if(lms == null){
Hashtable h=new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY," ********what should i use here???*************************");
h.put(Context.PROVIDER_URL,url);
System.out.println("Before Loading Context in Delegate");
Context ctx=new InitialContext(h);
System.out.println("Loaded Context in Delegate");

Object obj=ctx.lookup(JNDI_NAME);
System.out.println("Loaded Object in Delegate");


System.out.println("Before Loading Home in Delegate");

LmsHome home = (LmsHome )PortableRemoteObject.narrow(obj,com.parx.lms.controller.LmsHome.class);
System.out.println("Loaded Home in Delegate");

lms = home.create();

System.out.println("Loaded remote in Delegate");
}

}
public void addUserDelegate(UserVo vo) throws BusinessException{
try{
getController();
System.out.println("Before calling the addUser of Session");
lms.addUser(vo);
}catch(CreateException e){
System.out.println("Create Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);
}catch(NamingException e){
System.out.println("Naming Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);
}
catch(RemoteException e){
System.out.println("Remote Exception in Delegate due to--->"+e);
e.printStackTrace();
throw new BusinessException(e);

}catch(LMSException e){
System.out.println("duplicate user name--->"+e);
e.printStackTrace();
throw new BusinessException(e);
}
}
}


pls help me..........
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest you to look at the Documentation of your Server, as the JNDI service is being provided by the App Server, it has got different implementatons.

You may try these values, but I am not sure (as I havn't worked with Sun AppServer 8).

com.sun.enterprise.naming.SerialInitContextFactory
com.sun.jndi.cosnaming.CNCtxFactory
 
p anish
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai,

thanks 4 ur replay Mishra Anshu

when i use com.sun.enterprise.naming.SerialInitContextFactory

it is not working.........i got the exception...

Inside Client before calling delegate
Before Loading Context in Delegate
Naming Exception in Delegate due to--->javax.naming.NoInitialContextException: C
annot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Roo
t exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.Seria
lInitContextFactory]
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterp
rise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundE
xception: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
0)
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:50)
at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialIni
tContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
... 6 more
Business Exception in Client due to--->com.parx.lms.exception.BusinessException:
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enter
prise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFound
Exception: com.sun.enterprise.naming.SerialInitContextFactory]
com.parx.lms.exception.BusinessException: javax.naming.NoInitialContextException
: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [
Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.Se
rialInitContextFactory]
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:60)
at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com
.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.Cla
ssNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
0)
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:50)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialIni
tContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
... 6 more


But when i use com.sun.jndi.cosnaming.CNCtxFactory

........i got the exception........

Inside Client before calling delegate
Before Loading Context in Delegate
Naming Exception in Delegate due to--->javax.naming.ConfigurationException: http
://localhost:4848 does not contain an IOR
javax.naming.ConfigurationException: http://localhost:4848 does not contain an I
OR
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:421)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:198)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.ja
va:32)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
0)
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:50)
at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
Business Exception in Client due to--->com.parx.lms.exception.BusinessException:
javax.naming.ConfigurationException: http://localhost:4848 does not contain an
IOR
com.parx.lms.exception.BusinessException: javax.naming.ConfigurationException: h
ttp://localhost:4848 does not contain an IOR
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:60)
at com.parx.lms.client.consoleClient.Client.main(Unknown Source)
Caused by: javax.naming.ConfigurationException: http://localhost:4848 does not c
ontain an IOR
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:421)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:198)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:69)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.ja
va:32)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
62)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at com.parx.lms.lmsdelegate.LmsDelegate.getController(LmsDelegate.java:3
0)
at com.parx.lms.lmsdelegate.LmsDelegate.addUserDelegate(LmsDelegate.java
:50)
... 1 more




pls go tru my results.........and pls advice..........
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the Sun AppServer 8 documentation suggest using (following up on Mishra's suggestion)?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic