[EJB 3.0] - Deploy Problem
by jokim1979
Hello,
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??
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127706#4127706
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127706
18 years, 2 months
[EJB 3.0] - Deploy Problem
by jokim1979
Hello,
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 lookup UsuariosBean
| 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.lookupUsuariosBe
| an(controladorPUsuarios.java:78)
| at com.gui.funcionalidad.seguridad.controladorPUsuarios.<init>(controlad
| orPUsuarios.java:61)
| at com.gui.funcionalidad.seguridad.controladorPUsuarios.<clinit>(control
| adorPUsuarios.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 Sour
| ce)
| 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 Sour
| ce)
| 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.lookupUsuariosBe
| an(controladorPUsuarios.java:78)
| ... 30 more
Please, can you help me??
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127702#4127702
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127702
18 years, 2 months
[Security & JAAS/JBoss] - Cannot update the DB from an EJB MDB, help!!
by beherenow
Hello,
I have a web application which must recive messages from TWINCAT and, depend on message, update the database.
I am working with Hibernate, and I never had any problem to read, insert or update from the controller. Now, from the EJB, the class Message driven Bean reads okay but itâs impossible to update the DB. Cannot execute the update method and there arenât any exceptions or errors⦠simply not update.
I tried 2 possible but no good solutions:
1. Adding a file âserver.policyâ at {jboss.home}/server/default/conf with the code:
<!-- â¦.. ï
//Permisos requeridos para Hibernate
grant codeBase "file:/C:/jboss/server/default/deploy/my_application.ear"{
permission java.util.PropertyPermission "*", "read,write";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "getProtectionDomain";
};
grant codeBase "file:/C:/jboss/server/default/deploy/ my_application.ear/-"{
permission java.util.PropertyPermission "*", "read,write";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "getProtectionDomain";
};
2. Adding an ejb-jar.xml file in the meta-inf of application ear (built) and in the folder src and at classes (when built) of the ejb.jar. The code:
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<ejb-name>MyBean</ejb-name>
<!-- ... -->
<security-identity>
<run-as>
A private internal role
<role-name>Manager</role-name>
</run-as>
</security-identity>
<ejb-name>My2Bean</ejb-name>
<!-- ... -->
<security-identity>
<run-as>
A private internal role
<role-name>Manager</role-name>
</run-as>
</security-identity>
</enterprise-beans>
<!-- ... -->
<assembly-descriptor>
<method-permission>
<role-name>Manager</role-name>
<ejb-name>MyBean</ejb-name>
<method-name>*</method-name>
</method-permission>
</assembly-descriptor>
</ejb-jar>
The result of this itâs the same, impossible to update the database.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127697#4127697
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127697
18 years, 2 months