• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PortableRemoteObject exception

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

/////////HelloWorldBean.java////////////////
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";
}
}
/////////HelloWorldRemoteHome.java////////////////
package my.pkg;
public interface HelloWorldRemoteHome extends javax.ejb.EJBHome
{
HelloWorldRemote create() throws java.rmi.RemoteException,javax.ejb.CreateException;
}
/////////////////////////////////////////////////
////////HelloWorldRemote.java//////////////////
package my.pkg;
public interface HelloWorldRemote extends javax.ejb.EJBObject
{
String helloWorld() throws java.rmi.RemoteException;
}
//////////////////////////////////////////////
//////////test.jsp//////////////////////////
<!--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"%>
<html>
<head>
<title>
Web Application Page
</title>
</head>
<body>
<%
try
{

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

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

%>
New Web Application Page
</body>
</html>
///////////////////////////////////////////
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic