I've been trying to get one of our applications that runs perfectly happily under the Sun 1.4 JVM (Tomcat) to IBM's JVM. Under the IBM 1.4 JVM (Websphere 5), I experience the following exception with proxies and .equals:
Code:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at cirrus.hibernate.proxy.LazyInitializer.invoke(LazyInitializer.java:106)
at cirrus.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:46)
at java.lang.Object$$EnhancedByCGLIB$$1.equals(<generated>)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getAttribute(SRTServletRequest.java:1101)
at com.cgc.WebUtils.moveAttributeFromSession(WebUtils.java:28)
at com.cgc.collaborator.modules.directory.actions.LocationListAction.displayLocationsFrame(LocationListAction.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:506)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
This object being proxied does not override the equals method. I can workaround the problem simply enough by adding a trivial equals method. Clearly though, I don't want to have to do this, since the docs state:
Code:
Certain operations do not require proxy initialization
equals(), if the persistent class does not override equals()
Hibernate version: 1.2.5 (slightly customized to use CGLIB1.1 - 1.0 does not work with IBM JVM)
mapping for the class in question (abbreviated):
Code:
<class name="com.cgc.collaborator.directory.company.CompanyDirectoryEntryImpl" table="company_directory" proxy="com.cgc.collaborator.directory.company.CompanyDirectoryEntry">
<id name="id" type="long" column="ID" unsaved-value="0">
<generator class="hilo.long">
<param>company_directory_id_gen</param>
<param>next_hi</param>
</generator>
</id>
<timestamp column="TIMESTAMP" name="modificationTime"/>
<property name="name" column="name" type="string"/>
<property name="type" column="type" type="string"/>
<property name="womanOwned" column="woman_own" type="boolean"/>
<property name="minorityOwned" column="minority_own" type="boolean"/>
<property name="smallBusiness" column="small_bus" type="boolean"/>
<property name="openShop" column="open_shop" type="boolean"/>
<property name="distributeFax" column="dist_fax" type="boolean"/>
<property name="distributePrint" column="dist_print" type="boolean"/>
<property name="distributeEmail" column="dist_email" type="boolean"/>
<bag role="contacts" cascade="all" lazy="true" readonly="true">
<key column="company_directory_id"/>
<one-to-many class="com.cgc.collaborator.directory.company.CompanyDirectoryEntryContact"/>
</bag>
<bag role="locations" cascade="all" lazy="true" readonly="true">
<key column="company_directory_id"/>
<one-to-many class="com.cgc.collaborator.directory.company.CompanyDirectoryEntryLocation"/>
</bag>
<!--<many-to-one name="defaultLocation" class="com.cgc.collaborator.directory.company.CompanyDirectoryEntryLocation" column="default_loc_id"/>
<many-to-one name="defaultContact" class="com.cgc.collaborator.directory.company.CompanyDirectoryEntryContact" column="default_contact_id"/> -->
<many-to-one name="company" class="com.cgc.collaborator.Company" column="company_id"/>
</class>
Any thoughts and suggestions are appreciated.
Ken