-->
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.  [ 10 posts ] 
Author Message
 Post subject: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Fri Jun 26, 2009 2:36 pm 
Newbie

Joined: Thu Jun 11, 2009 1:44 pm
Posts: 3
Location: Montréal
I tried to upgrade from hibernate 3.3.1 to 3.3.2, and some working code stopped to work.

The following criteria search is still working as expected:

Code:
List<DonneeDynamique> list = mySession.createCriteria(DonneeDynamique.class).add(
    Restrictions.eq("clefScada", new ClefScada("s", "d", "d","a"))).list();


However, as soon as I add a setCacheable(true) instruction, there is an IllegalArgumentException exception:

Code:
List<DonneeDynamique> list = mySession.createCriteria(DonneeDynamique.class).add(
    Restrictions.eq("clefScada", new ClefScada("s", "d", "d","a"))).setCacheable(true).list();


The simplified class relations is as follow:

Code:
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DonneeDynamique {
    private ClefScada clefScada;

    @Embedded
    public ClefScada getClefScada() {
        return clefScada;
    }

    private String otherField;
    //... other things
}

@Embeddable
public class ClefScada {
    private String substation;
    private String deviceType;
    private String device;
    private String analog;
    //... getters, setters, etc
}


Please note that if I try a criteria search using an attribute that is not an @Embeddable, (such as the string "otherField" in the class DonneeDynamique, there is no problem adding the setCacheable(true) statement.

The complete stack trace is as follow:

14:10:29,599ERROR BasicPropertyAccessor:191 - IllegalArgumentException in class: ca.qc.xxx.jcommun.domaine.ClefScada, getter method of property: analog
14:10:29,599ERROR DonneeDynamiqueHibernateTest:65 - IllegalArgumentException occurred calling getter of ca.qc.xxx.jcommun.domaine.ClefScada.analog
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of ca.qc.xxx.jcommun.domaine.ClefScada.analog
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:87)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:93)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:109)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:376)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:194)
at org.hibernate.cache.QueryKey.generateHashCode(QueryKey.java:194)
at org.hibernate.cache.QueryKey.<init>(QueryKey.java:173)
at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:128)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2144)
at org.hibernate.loader.Loader.list(Loader.java:2121)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at ca.qc.xxx.jdshe.dao.DonneeDynamiqueHibernateTest.testTest(DonneeDynamiqueHibernateTest.java:60)
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:597)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
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:597)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
... 34 more

Any help would be appreciated,
Thanks,

_________________
Louis-Félix


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Mon Jun 29, 2009 10:42 am 
Newbie

Joined: Mon Jun 29, 2009 10:33 am
Posts: 2
Facing the same problem under the same conditions: after upgrade from 3.3.1 to 3.3.2 cached queries related to @Embedded became broken. Debugging has shown that "at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)" hibernate tries to call getter method via reflection, but instead of using instance of the @Embeddable object it tries to make a call on Object[] array containing string value.


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Wed Jul 08, 2009 8:01 am 
Newbie

Joined: Mon Aug 28, 2006 12:01 pm
Posts: 11
Same here after upgrade to 3.3.2.

Has anyone found a workaround or posted a bug on the Hibernate Issue Tracker ?

I've tried to disable query caching and now I get:

Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@321b7ed0
at sun.reflect.GeneratedMethodAccessor432.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
... 60 more


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Thu Jul 09, 2009 2:32 pm 
Newbie

Joined: Thu Jun 11, 2009 1:44 pm
Posts: 3
Location: Montréal
I did not post a bug on the Jira Hibernate Issue Tracker. I was waiting confirmation from other users. Also, the Hibernate JIRA page say: "Report your issue to JIRA if someone tells you to do so on the user forum".

Now that we have confirmation from other users, should we expect a confirmation from an Hibernate team member before posting the bug on JIRA?

_________________
Louis-Félix


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Wed Jul 15, 2009 10:52 am 
Newbie

Joined: Thu Aug 25, 2005 10:24 am
Posts: 6
Hi,

Facing the same problem under JBoss 5.1 GA. It only occurs sometimes and I have no use case to reproduce this.
I have a clustered EJB3 application in JBoss 5.1. And the problem does not occurs when the application is properly deployed, but after some time I see the described problem. (There is a fat client using HA JNDI to access some SFSB to work with the data.)
Does the Embedded class also need to be annotated as @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL, region = "myNS") as the entities ???

Do you have any hint ?

Georges


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Fri Jul 31, 2009 10:06 am 
Newbie

Joined: Mon Jun 29, 2009 10:33 am
Posts: 2
Any news about this issue?


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Wed Dec 23, 2009 8:22 am 
Newbie

Joined: Wed Dec 23, 2009 8:19 am
Posts: 1
Still no news?


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Thu Jan 14, 2010 6:14 pm 
Newbie

Joined: Thu Jan 14, 2010 5:29 pm
Posts: 2
I have also encountered this error when upgrading from 3.3.1 to 3.3.2.

Here's a fairly simple example, which works in 3.3.1, but not in 3.3.2:

Code:
@Embeddable
public class AgentCode {
    private String code;

    /**
     * Default constructor for hibernate
     */
    public AgentCode() {
    }

    /**
     * Create a new agent id
     *
     * @param code must be alphanumeric only
     */
    public AgentCode(String code) {
        this.code = code;
    }

    @Column(name = "AGENT_CODE")
    public String getCode() {
        return code;
    }

    public void setCode(String id) {
        this.code = id;
    }
}


AgentCode is a component of class Agent:

Code:
@Entity
@Table(name = Agent.TABLE)
@SequenceGenerator(name = Agent.SEQUENCE, sequenceName = Agent.SEQUENCE)
public class Agent extends PersistentBase<Integer> {
    protected static final String TABLE = "AGENT";
    protected static final String SEQUENCE = Agent.TABLE + "_SEQ";
    private Integer id;
    private AgentCode agentCode;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = SEQUENCE)
    @Column(name = "AGENT_ID", nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Embedded
    public AgentCode getAgentCode() {
        return agentCode;
    }

    public void setAgentCode(AgentCode agentCode) {
        this.agentCode = agentCode;
    }
}


And, finally, Agent is referenced as an Instance Variable in class CommandImpl:

Code:
@Entity
@Table(name = "AGENT_COMMAND")
@SequenceGenerator(name = CommandImpl.AGENT_COMMAND_SEQ, sequenceName = CommandImpl.AGENT_COMMAND_SEQ)
public class CommandImpl
        extends AbstractCommand
{
    private Integer id;
    private Agent agent;

    ... various other instance variables ...

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = AGENT_COMMAND_SEQ)
    @Column(name = AGENT_COMMAND_ID, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "AGENT_ID")
    @ForeignKey(name = "AGENT_COMMAND_AGENT_FK")
    public Agent getAgent() {
        return agent;
    }

    public void setAgent(Agent agent) {
        this.agent = agent;
    }
}


and, I have a query set up like this, which queries against the CommandImpl class, which uses AgentCode as a component:

Code:
    public List<CommandImpl> findByAgent(AgentCode agentCode) {
        Criteria query = getSession().createCriteria(cls).setResultTransformer(getResultTransformer());
        criteria.setCacheable(true);
        criteria.setCacheRegion("com.sirsidynix.discovery.agent.dao.CommandDao.queries");
        query.createCriteria("agent").add(Restrictions.eq("agentCode", agentCode));
        @SuppressWarnings("unchecked")
        List<CommandImpl> commands = query.list();
        return commands;
    }


I debugged it far enough to find that the problem occurs in QueryKey.java, in method generateQueryKey. It takes the 'positionalParameters' and turns them into 'values[]', dissasembling each one - but the types[] are set as the original positionalParameter type. So, if the original positionalParameter type is ComponentType, and the corresponding positionalParameter is an AgentCode, then the types[] entry is still ComponentType, but the values[] entry is an Object[1] containing a String value (i.e. the disassembled value from the AgentCode component).

Eventually, QueryKey.generateQueryKey calls QueryKey's constructor, passing the types and values arrays, which invokes QueryKey.getHashCode(), which gets the hash codes based on the contents of the passed in types[] and values[], and throws the following exception since the type indicates it should be a ComponentType, but the value isn't....

The applicable part of the Stack Trace looks like this:
Code:
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.sirsidynix.discovery.agent.lib.AgentCode.code
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
        at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:87)
        at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:93)
        at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:109)
        at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:376)
        at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:194)
        at org.hibernate.cache.QueryKey.generateHashCode(QueryKey.java:194)
        at org.hibernate.cache.QueryKey.<init>(QueryKey.java:173)
        at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:128)
        at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2144)
        at org.hibernate.loader.Loader.list(Loader.java:2121)
        at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
        at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
        at com.sirsidynix.discovery.agent.dao.impl.AgentDaoImpl.findByAgentCode(AgentDaoImpl.java:39)
        at com.sirsidynix.discovery.agent.bus.api.impl.AgentServiceImpl.getAgent(AgentServiceImpl.java:444)
        at com.sirsidynix.discovery.agent.bus.api.impl.AgentServiceImpl.loadAgent(AgentServiceImpl.java:457)
        at com.sirsidynix.discovery.agent.bus.api.impl.AgentServiceImpl.pollForWork(AgentServiceImpl.java:130)
        at com.sirsidynix.discovery.agent.bus.api.impl.RemoteAgentServiceImpl.pollForWork(RemoteAgentServiceImpl.java:52)
        at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:111)
        ... 61 more
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@d3276d
        at sun.reflect.GeneratedMethodAccessor478.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
        ... 89 more


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Fri Feb 19, 2010 6:29 am 
Newbie

Joined: Tue Jun 14, 2005 4:50 am
Posts: 1
Location: Sweden
Hi, any news on this bug?
I have the same problem. Has anybody submitted it to the Hibernate team?

This means that it will be hard to migrate to JBoss 5.x whit out downgrading to hibernate 3.3.1

best regards / Niklas

_________________
Niklas Antoncic


Top
 Profile  
 
 Post subject: Re: Error upgrading to hibernate 3.3.2 :IllegalArgumentException
PostPosted: Fri Feb 19, 2010 11:13 am 
Newbie

Joined: Thu Jan 14, 2010 5:29 pm
Posts: 2
Appears to be logged as http://opensource.atlassian.com/project ... e/HHH-4459. No updates on it lately, though.


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