java.lang.IllegalArgumentException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • using java constants as attribute value
    via freemarker by *anonymous
    ,
  • org.springframework.beans.TypeMismatchExcepti
    via springframework by bitiboy
    ,
  • string to List mapping
    via dozer by pmdrafeeq
    ,
  • As I use integer-type primary keys in the db I wanted to use the increment-generator to keep them unique. While trying to dump a test-object to the db, I got the following error: 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: IllegalArgumentException in class: de.fzi.dbs.cwb.Customer, setter method of property: cid 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: expected type: int, actual value: java.lang.Long net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid java.lang.IllegalArgumentException: argument type mismatch 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) (...) rethrown as net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:71) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) at de.fzi.dbs.cwb.test.test.main(test.java:56) Caused by: java.lang.IllegalArgumentException: argument type mismatch 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) ... 4 more While debugging, I figured out, that the class' generator method returns "new Long(next++)" in any case - which causes the type-mismatch while trying to set the cid (customer id in my example). My solution to this is adding the following to generate-method in net.sf.hibernate.id.IncrementGenerator: public synchronized Serializable generate(SessionImplementor session, Object object) throws SQLException, HibernateException { if (sql!=null) { getNext( session.connection() ); } // added code: // determine the return type via SessionImplementor Type identifierType = session.getPersister(object).getIdentifierType(); if (identifierType instanceof net.sf.hibernate.type.IntegerType) { return new Integer((int)next++); } else if (identifierType instanceof net.sf.hibernate.type.ShortType) { return new Short((short)next++); } else { return new Long(next++); } }
    via by Florian Hübner,
  • Re: IllegalAccess When Setting Field
    via by Chris Worley,
    • java.lang.IllegalArgumentException: argument type mismatch 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:324) at freemarker.ext.jsp.TagTransformModel.setupTag(TagTransformModel.java:199) at freemarker.ext.jsp.TagTransformModel.getWriter(TagTransformModel.java:135) at freemarker.template.Environment.visit(Environment.java:203) at freemarker.template.UnifiedCall.accept(UnifiedCall.java:112) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.MixedContent.accept(MixedContent.java:91) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.Environment.visit(Environment.java:216) at freemarker.template.UnifiedCall.accept(UnifiedCall.java:112) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.MixedContent.accept(MixedContent.java:91) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.Environment.visit(Environment.java:216) at freemarker.template.UnifiedCall.accept(UnifiedCall.java:112) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.MixedContent.accept(MixedContent.java:91) at freemarker.template.Environment.visit(Environment.java:179) at freemarker.template.Environment.process(Environment.java:165) at freemarker.template.Template.process(Template.java:238) at freemarker.ext.servlet.FreemarkerServlet.process(FreemarkerServlet.java:413) at freemarker.ext.servlet.FreemarkerServlet.doGet(FreemarkerServlet.java:359) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:822)

    Users with the same issue

    tvrmsmith
    2 times, last one,
    Unknown User
    2 times, last one,
    bernardpaulus
    1 times, last one,
    Unknown visitor1 times, last one,
    johnxfly
    2 times, last one,
    94 more bugmates