cancel
Showing results for 
Search instead for 
Did you mean: 

Access J2EE From Portal - ClassCastException

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Armin,

Thanks for ur reply,After the lookup i tried to print the name of the class,it gives com.tetrapak.ejb.UserHomeImpl10.I have even put the client.jar file which i got from visual administrator get client jar for that EJB.will try once again clearing all files and start with new project and test.

BR

Srinivas.p

Former Member
0 Kudos

I had to create a reference from the IRJ to my EJB application. See - https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https://

Former Member
0 Kudos

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