Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.