Ciao, sto provando a sviluppare un EJB 3 (SessioBean di tipo Stateful) con NetBeans 5.5 utilizzando JBoss 4.

Quando lo lancio mi da questo errore:

codice:
javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
        at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1150)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at pckEjbApplicationclient.Main.main(Main.java:40)
Caused by: java.lang.reflect.UndeclaredThrowableException
        at $Proxy0.createProxy(Unknown Source)
        at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
        at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
        ... 4 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.jboss.remoting.InvokerRegistry.createClientInvoker(InvokerRegistry.java:345)
        at org.jboss.remoting.Client.<init>(Client.java:178)
        at org.jboss.remoting.Client.<init>(Client.java:157)
        at org.jboss.remoting.Client.<init>(Client.java:139)
        at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:54)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
        at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
        ... 9 more
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
        at java.security.AccessController.checkPermission(AccessController.java:546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:594)
        at java.lang.ClassLoader.<init>(ClassLoader.java:201)
        at org.jboss.remoting.loading.ClassByteClassLoader.<init>(ClassByteClassLoader.java:61)
        at org.jboss.remoting.AbstractInvoker.<init>(AbstractInvoker.java:56)
        at org.jboss.remoting.RemoteClientInvoker.<init>(RemoteClientInvoker.java:69)
        at org.jboss.remoting.transport.socket.SocketClientInvoker.<init>(SocketClientInvoker.java:119)
        at org.jboss.remoting.transport.socket.SocketClientInvoker.<init>(SocketClientInvoker.java:113)
        ... 22 more
Riporto qui il codice del client

codice:
/*
 * Main.java
 *
 * Created on 7 maggio 2007, 11.18
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package pckEjbApplicationclient;

import java.rmi.RMISecurityManager;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import pckSessionBeanStateful.MySessionBeanStatefulRemote;

/**
 *
 * @author antonio
 */
public class Main {
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.setSecurityManager(new RMISecurityManager());
        Context ctx;   
        try {
            ctx = new InitialContext();
   
            //eseguo il lookup
            MySessionBeanStatefulRemote objSessionBeanStatefulBean = (MySessionBeanStatefulRemote) ctx.lookup("mysession/remote");
        
            //chiamo il metodo
            System.out.println(objSessionBeanStatefulBean.intBusSomma(1,1));
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
    }
}
Queste invece è il bean con le 2 intefaccie Local e Remote

Classe Bean: MySessionBeanStatefulBean

codice:
/*
 * MySessionBeanStatefulBean.java
 *
 * Created on 7 maggio 2007, 10.44
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package pckSessionBeanStateful;

import javax.ejb.Stateful;

/**
 *
 * @author antonio
 */
@Stateful(name="mysession")
public class MySessionBeanStatefulBean implements MySessionBeanStatefulRemote, MySessionBeanStatefulLocal {
    
    /** Creates a new instance of MySessionBeanStatefulBean */
    public MySessionBeanStatefulBean() {
    }

    // Mio metodo
    public int intBusSomma(int intNum1, int intNum2) {
        //TODO implement intBusSomma
        return intNum1 + intNum2;
    }
    
}
Interfaccia: MySessionBeanStatefulLocal

codice:
package pckSessionBeanStateful;

import javax.ejb.Local;


/**
 * This is the business interface for MySessionBeanStateful enterprise bean.
 */
@Local
public interface MySessionBeanStatefulLocal {
    // Mio metodo
    public int intBusSomma(int intNum1, int intNum2);
    
}
Interfaccia: MySessionBeanStatefulRemote

codice:
package pckSessionBeanStateful;

import javax.ejb.Remote;

/**
 * This is the business interface for MySessionBeanStateful enterprise bean.
 */
@Remote
public interface MySessionBeanStatefulRemote {
    // Mio metodo
    public int intBusSomma(int intNum1, int intNum2);
    
}
Grazie anticipatamente.