Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PortableRemoteObject exception

Jait Thomas
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im using weblogic 8.1 as server, and currently in the process of creating a simple program - 'hello world'. Im new to EJB.I used weblogic workshop for the process of development. So, i didnt had to create any xml file, since it created that itself. I have got 3 java files in a package. The program is a bit modified version of u r helloworld program. I also have a jsp file, which invokes the bean. It has a file called HelloWorldRemoteHome, HelloWorldRemote and HelloWorldBean.

Problem: When im trying to run the jsp file in a browser, im getting a PortableRemoteException when used as a Remote interface and Classcastexception when used as a Local interface. Can u please tell me why this problem occurs?

package my.pkg;
import javax.naming.*;
import javax.ejb.*;
import weblogic.ejb.*;
import java.rmi.RemoteException;
* @ejbgen:session
* ejb-name = HelloWorld
* @ejbgen:jndi-name
* remote="HelloWorldBean.Hellor"
public class HelloWorldBean implements SessionBean
private HelloWorldRemoteHome Hellohome;
public void ejbCreate() {
try {
javax.naming.Context ic = new InitialContext();
Hellohome = (HelloWorldRemoteHome)ic.lookup("HelloWorldbean.Hellor");
} catch (NamingException ne) {
throw new EJBException(ne); }
System.out.println("EJB Create HelloWorldBean");
// Your code here }
public void ejbActivate(){}
public void ejbPassivate(){}
public void ejbRemove(){}
public void setSessionContext(SessionContext ctx){}
* @ejbgen:remote-method
public String helloWorld()
return "hello world";
package my.pkg;
public interface HelloWorldRemoteHome extends javax.ejb.EJBHome
HelloWorldRemote create() throws java.rmi.RemoteException,javax.ejb.CreateException;
package my.pkg;
public interface HelloWorldRemote extends javax.ejb.EJBObject
String helloWorld() throws java.rmi.RemoteException;
<!--Generated by Weblogic Workshop-->
<%@ page language="java" contentType="text/html;charset=UTF-8"%>

<%@ page import='my.pkg.*'%>
<%@ page import='javax.naming.InitialContext'%>
<%@ page import='javax.naming.*' %>
<%@ page import='javax.rmi.PortableRemoteObject' %>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
Web Application Page

InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("HelloWorldBean.Hellor");
HelloWorldRemoteHome home = (HelloWorldRemoteHome)PortableRemoteObject.narrow(obj,HelloWorldRemoteHome.class);
HelloWorldRemote library = home.create();

catch(javax.naming.NamingException ne)
System.out.println("Naming exception "+ne);

New Web Application Page
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic