Deploy Problem
jokim1979 Feb 8, 2008 4:09 AMHello,
I've got a problem to access to a Remote SessionBean with JNDI and EJB 3.0
In Developt Enviroment (IDE NetBeans 5.5) all works fine. But in Production (Client and Server separates) doesn't work.
The .ear which I use in Server side is the same that compile NetBeans (in Develop) and is in <JBOSS_HOME>\server\default\deploy
The .jar which I use in Client side is the same that compile NetBeans (in Develop) and is in <PROYECTO_HOME>\<PROY_NAME>-app-client\dist
The order to run the client-server that I'm using is
java -jar <PROY_NAME>-app-client.jar
Context in server side is loading like:
iniCtx = new InitialContext();
and it's configurated throw parameters as system properties (java -Dclave=valor)
-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=jnp://192.200.10.1:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Client side code:
private controladorPUsuarios() {
uBean = lookupUsuariosBean();
}
private Hashtable Contexto() {
Hashtable env2 = new Hashtable();
env2.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env2.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
env2.put(Context.PROVIDER_URL, "jnp://localhost:1099");
return env2;
}
private UsuariosRemote lookupUsuariosBean() {
Context iniCtx;
try {
Map env = null;
Set propertiesSet = null;
Iterator it = null;
iniCtx = new InitialContext();
env = this.Contexto();
propertiesSet = env.keySet();
it = propertiesSet.iterator();
Context ejbCtx = (Context) iniCtx.lookup("");
return (UsuariosRemote) ejbCtx.lookup("UsuariosBean");
} catch (NamingException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ex);
throw new RuntimeException(ex);
} catch (RuntimeException e) {
e.printStackTrace();
return null;
}
}
Server side code:
@Stateless
@RemoteBinding(jndiBinding="UsuariosBean")
public class UsuariosBean implements UsuariosRemote {
public UsuariosBean() {
conUsers = IControladorU.getInstance();
}
public Usuarios conectar(String nusuario, String clave)
{
return conUsers.conectar(nusuario, clave);
}
}
Stack trace error:
com.gui.funcionalidad.seguridad.controladorPUsuarios lookupUsuariosBean GRAVE: exception caught javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.lookup(Unknown Source) at com.gui.funcionalidad.seguridad.controladorPUsuarios.lookupUsuariosBean(controladorPUsuarios.java:78) at com.gui.funcionalidad.seguridad.controladorPUsuarios.<init>(controladorPUsuarios.java:61) at com.gui.funcionalidad.seguridad.controladorPUsuarios.<clinit>(controladorPUsuarios.java:43) at com.gui.pantalla.seguridad.LOGIN.btAceptarActionPerformed(LOGIN.java:102) at com.gui.pantalla.seguridad.LOGIN.access$000(LOGIN.java:17) at com.gui.pantalla.seguridad.LOGIN$1.actionPerformed(LOGIN.java:46) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at com.gui.pantalla.seguridad.LOGIN.btAceptarActionPerformed(LOGIN.java:102) at com.gui.pantalla.seguridad.LOGIN.access$000(LOGIN.java:17) at com.gui.pantalla.seguridad.LOGIN$1.actionPerformed(LOGIN.java:46) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.RuntimeException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at com.gui.funcionalidad.seguridad.controladorPUsuarios.lookupUsuariosBean(controladorPUsuarios.java:81) at com.gui.funcionalidad.seguridad.controladorPUsuarios.<init>(controladorPUsuarios.java:61) at com.gui.funcionalidad.seguridad.controladorPUsuarios.<clinit>(controladorPUsuarios.java:43) ... 28 more Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.lookup(Unknown Source) at com.gui.funcionalidad.seguridad.controladorPUsuarios.lookupUsuariosBean(controladorPUsuarios.java:78) ... 30 more
Please, can you help me??