Problemas acessando remotamente EJB 2.0 com IIOP

0 respostas
Marcos_Chibly

Pessoal, me ajudem please.

Tenho um Sun app 8.2 com JDK1.4
Estou com um exemplo HelloWorld . O exemplo esta abaixo. !
Faz Deploy no App 100%.

Mas não consigo acessar via CLIENT o EJB via IIOP.

O erro que aparece é :

[color=red]

java.lang.ClassCastException

at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)

at javax.rmi.PortableRemoteObject.narrow(Unknown Source)

at com.examples.HelloClient.main(HelloClient.java:22)

Exception in thread “main” [/color]

[color=green]<?xml version="1.0" encoding="UTF-8"?>




Hello

Hello
Hello


[/color]

[color=green]



Hello
com.examples.HelloHome
com.examples.Hello
com.examples.HelloBean
Stateless
Container


[/color]


package com.examples;

import javax.ejb.;
import java.rmi.
;

public interface Hello extends EJBObject {

public String sayHello() throws RemoteException;

}

package com.examples;

import javax.ejb.;
import java.rmi.
;

public interface HelloHome extends EJBHome {

public Hello create() throws CreateException, RemoteException;

}

package com.examples;

import javax.ejb.*;

public class HelloBean implements SessionBean {

/**
 * 
 */
private static final long serialVersionUID = 413786221542661850L;

public void ejbCreate() {
}

public void ejbActivate() {
}

public void ejbPassivate() {
}

public void ejbRemove() {
}

public void setSessionContext(SessionContext sc) {
}

public String sayHello() {
	System.out.println("Someone called sayHello()");
	return "Hello! World";
}

}


package com.examples;

import java.util.Properties;

import javax.naming.*;

import javax.rmi.PortableRemoteObject;

public class HelloClient {
public static void main(String[] args) throws Exception {

String url = "iiop://wadumas309959:3700";
	
	Properties h = new Properties();
	h.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
	h.put(Context.PROVIDER_URL, url);
	
	Context c = new InitialContext(h); 
	Object o = c.lookup("Hello");
	
	System.out.println(o.getClass());
	
	HelloHome home = (HelloHome) PortableRemoteObject.narrow(o,HelloHome.class);
	Hello hello = home.create();
	System.out.println(hello.sayHello());
	hello.remove();
	
}

}

Alguém consegue identificar o que está ocorrendo de errado nesse exemplo… ?

Obrigado.

Criado 24 de outubro de 2007
Respostas 0
Participantes 1