on 05-11-2005 6:46 PM
Hi,
We have implemented EJB's in our Portal. We are having problems in accessing the EJB Object inside JSP. When we do a response.write in the Portal Component,we are able to get the values of the Object in JSP but when we access the EJB Object in JSP and try to get the values with the get methods, it fails, getting Unable to render JSP error.
Did anyone come across this kind of situation.
Any help is highly appreciate,
Thank you for your time.
Regards
Som
I think I mis-stated the problem. What we have is 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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
I am able to access the EJb object in JSP and deployed JSP as a portal components also.
For this I have followed the following steps:
1. created the EJB component(MyEJB)deployed it in the WAS.
2. created a Portal Application(MyEJBPar.par file).
3. created a Portal Component ie. Abstract Portal Component.
4. copy the MyEJB.jar file to the MyEJBPar\dist\PORTAL-INF\lib folder.
5. created a JSP file(MYJSP.jsp) in the MyEJBPar\dist\PORTAL-INF\jsp folder.
in the JSP I have added the following code:
<%
try{
javax.naming.InitialContext ie=new javax.naming.InitialContext();
Object obj=ie.lookup("sap.com/MyEJBEar/HelloBean");
com.wipro.hello.HelloHome home=
(com.wipro.hello.HelloHome)javax.rmi.PortableRemoteObject
.narrow(obj,com.wipro.hello.HelloHome.class);
com.wipro.hello.Hello h=home.create();
out.println(h.sayHello());
}
catch(Exception e)
{
out.println("Error "+e);
}
%>
and finally edited the portalapp.xml file(found in the path MyEJBPar\dist\PORTAL-INF.
and add the following tag:
<component name="MyJSP">
<component-config>
<property name="ComponentType" value="jspnative">
</property>
<property name="JSP" value="jsp/MyJSP.jsp">
</property>
</component-config>
<component-profile/>
</component>
Then I deployed the par file and when I created a iView for my MyJSP component , it is able to access my MyEJB component and return the output.
Hope this will solve your problem.
Thanks
Hari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
have you created a EJB Local reference in web.xml file ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
could u pls explain more abt your problem.. may be with some code...
Rgds,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.