-->
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.  [ 2 posts ] 
Author Message
 Post subject: Object is not an instance of declaring class
PostPosted: Wed Dec 15, 2010 8:36 am 
Newbie

Joined: Wed Dec 15, 2010 8:24 am
Posts: 4
Hi,

I am getting following exception in JBoss 4.2.2 server:

Code:

2010-12-15 08:23:39,183 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 1044, using strategy: org.hibernate.id.SequenceGenerator
2010-12-15 08:23:39,185 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [com.adp.ebs.admin.crs.dvo.CRSAuditInfo#1044]
2010-12-15 08:23:39,188 ERROR [org.hibernate.property.BasicPropertyAccessor] IllegalArgumentException in class: com.adp.ebs.admin.crs.dvo.CRSAuditInfo, setter method of property: auditId
2010-12-15 08:23:39,188 ERROR [org.hibernate.property.BasicPropertyAccessor] expected type: java.lang.Integer, actual value: java.lang.Integer
2010-12-15 08:23:39,194 DEBUG [com.adp.sbs.struts.action.EBSExceptionHandler] **** EXCEPTION THROWN : org.hibernate.PropertyAccessException
2010-12-15 08:23:39,195 ERROR [com.adp.sbs.struts.action.EBSExceptionHandler] IllegalArgumentException occurred while calling setter of com.adp.ebs.admin.crs.dvo.CRSAuditInfo.auditId
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.adp.ebs.admin.crs.dvo.CRSAuditInfo.auditId
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211)
   at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3596)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:171)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
   at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
   at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
   at com.adp.ebs.admin.services.crs.AuditServiceImpl.auditCRSMethod(AuditServiceImpl.java:26)
   at com.adp.ebs.admin.services.crs.CRSServiceImpl.getQuestions(CRSServiceImpl.java:102)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
   at com.adp.ebs.admin.interceptors.MethodTimer.profile(MethodTimer.java:19)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
   at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy63.getQuestions(Unknown Source)
   at com.adp.ebs.admin.struts.action.login.POTDLogonAction.getChallengeQuestions(POTDLogonAction.java:1307)
   at com.adp.ebs.admin.struts.action.login.POTDLogonAction.handleRegUser(POTDLogonAction.java:752)
   at com.adp.ebs.admin.struts.action.login.POTDLogonAction.execute(POTDLogonAction.java:122)
   at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:113)
   at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:53)
   at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:64)
   at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:48)
   at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
   at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
   at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
   at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:280)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.adp.ebs.sso.filter.XSSFilter.doFilter(XSSFilter.java:103)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at com.adp.sbs.filters.gzip.GZIPFilter.doFilter(GZIPFilter.java:73)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
   at java.lang.Thread.run(Thread.java:595)
Caused by: 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:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
   ... 75 more



Following is code and config files:

Code:
package com.adp.ebs.admin.crs.dvo;

public class CRSAuditInfo {
   
   //private java.lang.Integer auditId;
   private java.lang.Integer auditId = -1;
   
      
   
   private java.sql.Timestamp createdDate;
   private String crsMethod;
   private String userId;
   private String errorDesc;
   private int statusCode;
   
   /**
    * No arg Constructor
    */
   public CRSAuditInfo() {
      
   }
   /**
    * @return the auditId
      */
   public java.lang.Integer getAuditId() {
      return auditId;
   }

   /**
    * @param auditId the auditId to set
    */
   public void setAuditId(java.lang.Integer auditId) {
      this.auditId = auditId;
   }

   
   /**
    * @return the createdDate
    */
   public java.sql.Timestamp getCreatedDate() {
      return createdDate;
   }
   /**
    * @param createdDate the createdDate to set
    */
   public void setCreatedDate(java.sql.Timestamp createdDate) {
      this.createdDate = createdDate;
   }
   /**
    * @return the crsMethod
    */
   public String getCrsMethod() {
      return crsMethod;
   }
   /**
    * @param crsMethod the crsMethod to set
    */
   public void setCrsMethod(String crsMethod) {
      this.crsMethod = crsMethod;
   }
   /**
    * @return the userId
    */
   public String getUserId() {
      return userId;
   }
   /**
    * @param userId the userId to set
    */
   public void setUserId(String userId) {
      this.userId = userId;
   }
   /**
    * @return the errorDesc
    */
   public String getErrorDesc() {
      return errorDesc;
   }
   /**
    * @param errorDesc the errorDesc to set
    */
   public void setErrorDesc(String errorDesc) {
      this.errorDesc = errorDesc;
   }
   /**
    * @return the statusCode
    */
   public int getStatusCode() {
      return statusCode;
   }
   /**
    * @param statusCode the statusCode to set
    */
   public void setStatusCode(int statusCode) {
      this.statusCode = statusCode;
   }
   

}



Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.adp.ebs.admin.crs.dvo">
<class name="CRSAuditInfo" table="CRS_AUDIT_INFO">
   
   <id name="auditId" type="java.lang.Integer" >
      <column name="AUDIT_ID"/>
         <generator class="sequence">
         <param name="sequence">crs_audit_id</param>
      </generator>
   </id>
 
       
   <property name="createdDate" type="java.sql.Timestamp" column="CREATED_DATE"/>
   <property name="crsMethod" type="java.lang.String" column="CRS_METHOD"/>
   <property name="errorDesc" type="java.lang.String" column="ERROR_DESC"/>
   <property name="statusCode" type="int" column="STATUS_CODE"/>
   <property name="userId" type="java.lang.String" column="USER_ID"/>
    </class>
</hibernate-mapping>


Code:

      session.beginTransaction();
      CRSAuditInfo crsAudit = new CRSAuditInfo();
      crsAudit.setCrsMethod(method);
      crsAudit.setErrorDesc(message);
      crsAudit.setUserId(userId);
      crsAudit.setStatusCode(SUCCESS_STATUS_CODE);
      session.save(crsAudit);
      session.getTransaction().commit();


I tested same classes/config using stand alone test program and they are working fine. But when i deploy same in jboss server, i am getting this problem.

I searched a lot in google and found lot of similar issues but somehow did not get solution.

Please help me.

Thanks


Top
 Profile  
 
 Post subject: Re: Object is not an instance of declaring class
PostPosted: Thu Dec 16, 2010 5:20 am 
Newbie

Joined: Wed Dec 15, 2010 8:24 am
Posts: 4
This issue is happening because session factory was created through jboss and used with spring services. Some class loader issue. I am not very sure about root cause. I got it working by setting up hibernate session factory through Spring's org.springframework.orm.hibernate3.LocalSessionFactoryBean.

Code:
   <jee:jndi-lookup id="myDS" jndi-name="java:/MYDS"/>
      
   <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource" ref="myDS"/>
      
      <property name="mappingResources">
         <list>
            <value>com/adp/ebs/admin/crs/dvo/CRSAuditInfo.hbm.xml</value>
         </list>
      </property>
      <property name="hibernateProperties">
         <value>
            hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
            hibernate.show_sql=true
            hibernate.current_session_context_class=thread
         </value>
      </property>

   </bean>
      
   <bean id="AuditService" class="com.adp.ebs.admin.services.crs.AuditServiceImpl">
         <property name="sessionFactory">
            <ref bean="hibernateSessionFactory"/>
         </property>
    </bean>



Thanks
Chetan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.