ClassCastException EJB3.0 JBOSS 5

0

Witam,co zrobić z takim fantem??
Stworzyłem prostego bean'a wrzuciłem go na JBOSS'a ale przy odpaleniu go z poziomu klienta(zwykla aplikacja desktopowa) dostaje taki bład??

Exception in thread "main" java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at testcalc.main(testcalc.java:13)
Caused by: java.lang.ClassCastException: javax.naming.Reference
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
... 2 more
Java Result: 1

/////kod bean'a
package calc;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless
@Remote(CalculatorbeanRemote.class)
public class CalculatorbeanBean implements CalculatorbeanRemote {

    public double add(double a, double b) {
       return a+b;
    }
    

}
//////
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package calc;

import javax.ejb.Remote;

@Remote
public interface CalculatorbeanRemote {
    public double add(double a,double b);
}
/////klient aplikacja desktopowa
import calc.CalculatorbeanRemote;
import java.util.Properties;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;

public class testcalc {

    public static void main(String[] args) throws NamingException {
       Context con = getInitialContext();
       Object ref = con.lookup("CalculatorbeanBean/remote");
       System.out.println(ref);
       CalculatorbeanRemote calc = (calc.CalculatorbeanRemote) PortableRemoteObject.narrow(ref,calc.CalculatorbeanRemote.class);
       System.out.println(calc.add(13.0, 1.0));
    }

    public static Context getInitialContext() throws NamingException{
        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
        props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
        props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
        return new InitialContext(props);
    }
}

dodatkowo po tej linijce: System.out.println(ref); wyswietla mi

Reference Class Name: Proxy for: calc.CalculatorbeanRemote
Type: ProxyFactoryKey
Content: ProxyFactory/Calculator/CalculatorbeanBean/CalculatorbeanBean/remote
Type: EJB Container Name
Content: jboss.j2ee:jar=Calculator.jar,name=CalculatorbeanBean,service=EJB3
Type: Proxy Factory is Local
Content: false
Type: Remote Business Interface
Content: calc.CalculatorbeanRemote
Type: Remoting Host URL
Content: socket://127.0.0.1:3873/

Co robie źle lub czego nie robie :)??

0

Nie wiem w jaki sposób działa w Twoim programie konstrukcja calc.CalculatorbeanRemote (w ogóle pierszy raz spotykam się z czymś takim; u mnie eclipse podkreśla to jako błąd). Może spróbuj zamienić to na samo CalculatorbeanRemote.

0

przepisałem wszystko od nowa i działa

1 użytkowników online, w tym zalogowanych: 0, gości: 1