Skip to Content
avatar image
Former Member

Access J2EE From Portal - ClassCastException

HI,

I have deployed a EJB in SAP J2EE Engine EP6.0Sp2. I have a portal component also deployed.when i access the EJB from portal component i get Class Cast Exception.I'm able to perform lookup,but when i try to narrow the object to my HomeClass i get this exception.

<b>MY Portal Component</b>

package com.sap.demo;

import javax.naming.Context;

import javax.naming.InitialContext;

import com.inqmy.services.rmi_p4.P4ObjectBroker;

import com.sapportals.portal.prt.component.AbstractPortalComponent;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.tetrapak.ejb.UserHome;

import com.tetrapak.ejb.UserRemote;

public class MyFirstPortalComponent extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

String key = "UserBean";

try

{

Context context = new InitialContext();

Object obj = context.lookup(key);

response.write("After lookup: " + obj + "<br>");

UserHome home =(UserHome) P4ObjectBroker.init().narrow(obj,UserHome.class);

UserRemote hello = home.create();

response.write("Bean message: " + hello.hello());

}

catch(Exception e)

{

response.write("Error :" + e.fillInStackTrace());

}

}

}

Any help is welcome

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 16, 2004 at 11:45 AM

    hi,

    try to put your client.jar and your ejb-interfaces in the directorey C:\usr\sap\EP60\j2ee\j2ee_01\cluster\server\services\servlet_jsp\work\jspTemp\irj\root\WEB-INF\lib

    in my case, it works

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 16, 2004 at 01:12 PM

    Hi,

    as far as I know, in case the lookup went wrong, the object you get from the lookup is some kind of j2ee engine class object, which then might create a ClassCastException upon narrowing - check the obj.getClass().getName() from your lookup.

    Regards,

    Armin

    Add comment
    10|10000 characters needed characters exceeded