-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: cglib + WebLogic 8.1 JSP-EL returns nulls with Hibernate 3.1
PostPosted: Wed Nov 09, 2005 10:05 am 
Newbie

Joined: Mon Oct 18, 2004 1:42 pm
Posts: 10
Location: Ottawa, Canada
Hibernate version: 3.1
Weblogic 8.1

Some cglib and Hibernate 3.1 behaviour is causing the Weblogic 8.1 JSP
expression language to fail in retrieving values that are indirectly
referenced. For example if ClassA with the following structure

Code:
  public ClassA {
      private String str = null;
      private ClassB classB = null;
   
      public String getStr () {
        return str;
      }

      public ClassB getClassB () {
        return classB;
      }
   }


And ClassB as
Code:
   public ClassB {
      private Integer id = null;
   
      public Integer getId () {
         return id;
      }

      public String toString() {
         return getId().toString();
      }
   }

The JSP-EL pageflow variables behave as shown below
Code:
{pageFlow.classA.str}            displays correctly
{pageFlow.classA.classB.id}   returns a null.
{pageFlow.classA.classB}       returns the corresponding toString()


When debugging the persistent object is displayed as
var= OffenderDetail$$EnhancerByCGLIB$$c831f4bb (id=37)

All other objects are displayed in the debugger as
session= SessionImpl (id=37)

The same code works with Hibernate 2.1.7 but fails with Hibernate 3.1.

What are the implications of the new cglib changes in Hibernate 3.1?

Thanks.

Josh


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 10:19 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Default is "lazy=true" since Hibernate 3.
Try to access this property in scriptlet, it looks like JSP displays exception as null (probably it is a popular "session was closed" exception).


Top
 Profile  
 
 Post subject: cglib + WebLogic 8.1 JSP-EL returns nulls with Hibernate 3.1
PostPosted: Wed Nov 09, 2005 10:50 am 
Newbie

Joined: Mon Oct 18, 2004 1:42 pm
Posts: 10
Location: Ottawa, Canada
baliukas wrote:
Default is "lazy=true" since Hibernate 3.
Try to access this property in scriptlet, it looks like JSP displays exception as null (probably it is a popular "session was closed" exception).


I have a "long" (application) session where the Hibernate session is not closed for the duration of the HttpSession. We do this to enable auditing so we can get the "before" and "after" values. There is no "session was closed" exception and Java code in the .jpf file can access the properties.

The scriplet below

Code:
        <%
           Session tmpSession = HibernateUtil.getSession();
           OffenderDetail od = (OffenderDetail)
                              tmpSession.load(OffenderDetail.class,new Integer(11522));
           GeneralCode gc = od.getGender();
           Integer tempInt = gc.getId();
       
        %>
       
        <B>JSP-EL:</B> <%=gc.id%>  <B>Integer Value:</B> <%=tempInt%>


Will print out
JSP-EL: null Integer Value: 60

This reassures me that the session is not closed.

Thanks.

Josh.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 11:38 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
You must access "id" as property (<%=gc.getId() %>) not as public field (<%=gc.id%>) to get correct value from proxy.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 11:49 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
I thought that most EL parsers are supposed to (as per the JSP spec) use accessor methods even if you reference by property name. I know this is correctly implemented in Tomcat (which uses Apache PropertyUtils as part of its EL interpreter).

Josh -- can you hook up a debugger or add debug code to determine whether the accessor methods are being used for other property values?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:00 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
As I understand JSP code "<B>JSP-EL:</B> <%=gc.id%>" is not a JSP-EL, it is scriptlet and this scriptlet reads public field.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:56 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
baliukas wrote:
As I understand JSP code "<B>JSP-EL:</B> <%=gc.id%>" is not a JSP-EL, it is scriptlet and this scriptlet reads public field.

Ah - silly me, I misread. Of course you're right :)


Top
 Profile  
 
 Post subject: BEA JSP-EL implementation problem with cglib proxies
PostPosted: Wed Nov 09, 2005 2:45 pm 
Newbie

Joined: Mon Oct 18, 2004 1:42 pm
Posts: 10
Location: Ottawa, Canada
Hi pmularien, baliukas,

Thanks for your helpful proposals. I have so far concluded
a. The session is not being closed.
b. There MIGHT be a problem with the BEA Weblogic
Quote:
com.bea.wlw.netui.tag.AbstractBaseTag.evaluateExpression(String, String)

method. This method does not seem to call the property accessor
methods and hence would not correctly retrieve the proxy values.

I am going to be pursuing b. further and any more suggestions will greatly be appreciated.

Thanks.

Josh.


pmularien wrote:
I thought that most EL parsers are supposed to (as per the JSP spec) use accessor methods even if you reference by property name. I know this is correctly implemented in Tomcat (which uses Apache PropertyUtils as part of its EL interpreter).

Josh -- can you hook up a debugger or add debug code to determine whether the accessor methods are being used for other property values?




baliukas wrote:
As I understand JSP code "<B>JSP-EL:</B> <%=gc.id%>" is not a JSP-EL, it is scriptlet and this scriptlet reads public field.


Top
 Profile  
 
 Post subject: cglib + WebLogic 8.1 JSP-EL nulls with public declarations
PostPosted: Wed Nov 09, 2005 4:13 pm 
Newbie

Joined: Mon Oct 18, 2004 1:42 pm
Posts: 10
Location: Ottawa, Canada
Hi pmularien, baliukas,

Thanks for your help in tracking this one down.

I found the problem in the property that was being displayed in the
JSP-EL. If the class had the property declared public, the Weblogic
evaluation of the JSP-EL will not use the accessor method. Changing the
field declarations to be private solved the problem as they should have been
in the first place. (one through the cracks....)

Thanks.

Josh.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.