-->
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.  [ 8 posts ] 
Author Message
 Post subject: Expected type: java.lang.Long actual value: java.lang.Long
PostPosted: Wed Nov 09, 2005 3:31 pm 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
Hibernate version:
3.1.rc2 on JBoss 4.0.3SP1
Mapping documents:
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>
    <class name="teste.Teste" table="teste">
        <id name="id" column="codigo">
            <generator class="increment" />
        </id>
        <property name="campo" type="string">
            <column name="campo" />
        </property>
    </class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Code:
Teste teste = new Teste();
teste.setCampo("campo");
session.save(teste);

Full stack trace of any exception that occurs:
Code:
17:08:10,687 INFO  [STDOUT] Hibernate: select max(codigo) from teste
17:08:10,734 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: teste.Teste, setter method of property: id
17:08:10,734 ERROR [BasicPropertyAccessor] expected type: java.lang.Long, actual value: java.lang.Long
17:08:10,734 INFO  [STDOUT] org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of teste.Teste.id
        at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPro
pertyAccessor.java:104)
        at org.hibernate.tuple.AbstractEntityTuplizer.setIdentifier(AbstractEnti
tyTuplizer.java:204)
        at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(
AbstractEntityPersister.java:3261)
        at org.hibernate.event.def.AbstractSaveEventListener.performSave(Abstrac
tSaveEventListener.java:157)
        at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:114)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGene
ratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
        at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrR
equestedId(DefaultSaveEventListener.java:33)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTran
sient(DefaultSaveOrUpdateEventListener.java:175)
        at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
DefaultSaveEventListener.java:27)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:70)
        at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:524)
        at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
        at org.hibernate.impl.SessionImpl.save(SessionImpl.java:510)
        at servlet.ServletTeste.doGet(ServletTeste.java:24)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: object is not an instance of decl
aring class
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPro
pertyAccessor.java:42)
        ... 34 more

Name and version of the database you are using:
HSQLDB 1.8.0
The generated SQL (show_sql=true):
select max(codigo) from teste

My class:
Code:
package teste;

public class Teste {
   private Long id;
   private String campo;
   
   public String getCampo() {
      return campo;
   }
   public void setCampo(String campo) {
      this.campo = campo;
   }
   public Long getId() {
      return id;
   }
   public void setId(Long id) {
      this.id = id;
   }
}


I have the same .jar (containing teste.Teste) file on .har and .war files, so that I can share the session factory among two web apps.

My deploy configuration:
- hibernate.har
->classes.jar
->META-INF
->jboss-service.xml

- webapp.war
->WEB-INF
->lib
->classes.jar

The expected type and the actual type are the same!

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 5:29 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
try set type in mapping file, for example

<id name="id" column="codigo" type="long">


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 11:29 am 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
Quote:
try set type in mapping file

didn´t work.

It seems like a Classloading issue:
Code:
java.lang.IllegalArgumentException: object is not an instance of declaring class
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


So, I´m thinking about other ways of doing data sharing among applications, do you think I´m gonna get the same classloading issues using JBossCache? Do you have some tips?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 12:02 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
what is column type in database ?

try hibernate standalone

I don't know jboss and jobss cache - i son't use it (yet)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 3:36 pm 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
Quote:
what is column type in database ?

Hibernate is configured to create the database on HSQLDB. (hbm2ddlauto = true).

Quote:
try hibernate standalone

I´m trying hibernate on JBoss because my application will be running on it. I´d like to use JBoss .har files to configure only one SessionFactory for many applications.

Quote:
I don't know jboss and jobss cache - i son't use it (yet)

I will be posting my discoveries about JBossCache.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 3:58 pm 
If you are using Eclipse or an IDE with similar capabilities, create a Java exception breakpoint for org.hibernate.PropertyAccessException and take a look at the actual objects and their types. You should be able to see the class of the object that Hibernate is trying to set.


Top
  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 6:30 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
I´m trying hibernate on JBoss because my application will be running on it. I´d like to use JBoss .har files to configure only one SessionFactory for many applications.


try standalone first - it is easier for testing

try see column type with debug or don't drop tables on end


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 11:50 am 
Newbie

Joined: Sat May 22, 2004 1:47 pm
Posts: 13
Quote:
try standalone first - it is easier for testing

Standalone works well.

Quote:
So, I´m thinking about other ways of doing data sharing among applications, do you think I´m gonna get the same classloading issues using JBossCache? Do you have some tips?

Cache does not get called... I think it is impossible. How do you fix this? I would expose Web Services in one different web application and other applications calls them. But I´d like suggestions.

Thanks


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