-
1. Re: Accessing EJBs from applet
sergeibatiuk Jan 8, 2002 9:33 AM (in response to sergeibatiuk)I have finally received a reaction to my attempts to connect to an EJB. Here is the exception i received:
javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub; Local class not compatible: stream classdesc serialVersionUID=2 local class serialVersionUID=0]
Here is the code I use to connect to the EJB:
Hashtable properties = new Hashtable();
String host = this.getCodeBase().getHost();
//host = "thunder";
properties.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
properties.put( Context.PROVIDER_URL, "jnp://" + host + ":1099" );
properties.put( Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
properties.put( Context.SECURITY_PRINCIPAL, "sbatiuk" );
properties.put( Context.SECURITY_CREDENTIALS, "mf" );
try {
Context ctx = new InitialContext( properties );
Object obj = ctx.lookup( "Employee" );
EmployeeHome employeeHome = ( EmployeeHome )javax.rmi.PortableRemoteObject.narrow( obj, bsv.employees.EmployeeHome.class );
//EmployeeHome employeeHome = ( EmployeeHome )obj;
Employee employee = employeeHome.create();
textArea.append( employee.getName() );
}
catch( ServiceUnavailableException ex ) {
....
}
catch( Exception ex ) {
....
}
Please HELP!!
Sincerely,
Sergei Batiuk. -
2. Re: Accessing EJBs from applet
larry054 Jan 8, 2002 10:42 PM (in response to sergeibatiuk)Remember when you use appletviewer, your client is running in the same VM as the server. That means you have access to the lib/ext and anything else in your classpath. An applet running in the browser can only count on whatever is in the archive. You should have everything your applet needs in a jar file named in the archive tag. (That includes any interface classes for your RMI.)
-
3. Re: Accessing EJBs from applet
sergeibatiuk Jan 9, 2002 12:56 AM (in response to sergeibatiuk)Dear larry054,
Thank you very much! I did think that I have included all the jars, but oops! I checked once again and it appeared that one was missing... It works now!!!
Sincerely,
Sergei Batiuk.