cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCastException while accessing Java Object in JSP - Please help

Former Member
0 Kudos
96

Hi All,

We have a simple POJO (Plain old Java Object) that implements Serializable. The portal component invokes a Stateless Session Bean which returns a POJO (this is done using the "SharingReference" property in the portal-app.xml). The portal component then stores the POJO in the HttpSession. We are trying to access the POJO in the JSP using something like

<% Person person = (Person) session.getAttribute("person"); %>

This is where it fails. Since it can't reference the "Person" class (the JSP contains the import of the package). The Person class is in a Java Project that's JAR(red) and available to the EJB Project. When we put the same JAR in the /PORTAL-INF/lib folder and invoked the JSP, we get a ClassCastException (since the object in the session is different than the one being referenced in the JSP). So the question is how can we pass the POJO across the EJB, Portal and JSP containers?

Any reply to this message is highly appreciated.

Thank you for your time.

Best Regards,

Vasu

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Try to use bean concept to access the object rather than retriving from sesssion. State the scope of the bean to be sesssion. hope it works

Former Member
0 Kudos

Hi Vasu,

Remove that jara from /PORTAL-INF/lib and put into PORTAL-INF/private/lib

hope, this will solve your problem...

Rgds,

Raj

PS: Please consider rewarding points if the answer was helpful.

Former Member
0 Kudos

Hi Raj,

Thank you for taking time in answering the question.

Can you please tell me the difference between having jar file in /PORTAL-INF/lib and in PORTAL-INF/private/lib?

We are able to access the Java Object inside the Portal Component, we get the Classcastexception when we try to render it in the JSP.

Thank you

Som