-
1. Re: setParameter() IllegalArgumentException
dgeraskov Dec 1, 2008 4:43 AM (in response to nschweig)Please, first of all check this cases(most of all 3 and 4, may be you need to use int instead of long):
A problem occurred accessing a property of an instance of a persistent class by reflection, or via CGLIB. There are a number of possible underlying causes, including
* failure of a security check
* an exception occurring inside the getter or setter method
* a nullable database column was mapped to a primitive-type property
* the Hibernate type was not castable to the property type (or vice-versa)
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/PropertyAccessException.html -
2. Re: setParameter() IllegalArgumentException
nschweig Dec 6, 2008 7:18 AM (in response to nschweig)Hi,
I tried to understand your hints but it is difficult as beginner in ejb. This is all I can say:
failure of a security check
I think with security it has nothing to do because the only thing I do with security is authentification with UserRolesLoginModule in the webapplication.
an exception occurring inside the getter or setter method
Which getter or setter is meant here?
a nullable database column was mapped to a primitive-type property
The table "course" in my db has an id(Long in Java) (in db bigint)
The "instructor" is mapped here with his foreign key(Long id in Java, in db bigint) The field "instructor" is nullable.
The instructor is from tpye "CmtUser".@Entity public class Course implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String title; private String abbreviation; private String description; private String semester; @Column(columnDefinition="BOOL") private boolean active = false; @ManyToOne @JoinColumn(name="instructor") private CmtUser instructor; public Course(){} public Course(String title, String abbreviation, String description, String semester,boolean active,CmtUser instructor){ this.title = title; this.abbreviation = abbreviation; this.description = description; this.semester = semester; this.active = active; this.instructor = instructor; } ...getter and setter
@Entity @Table(name="CmtUser", uniqueConstraints=@UniqueConstraint(columnNames={"userName","passWord","email"})) public class CmtUser implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String userName; private String firstName; private String lastName; private String passWord; private String email; @Embedded private UserSettings settings = new UserSettings(); @ManyToMany(fetch=FetchType.EAGER) private List <Role> roles = new ArrayList<Role>(); public CmtUser(){} public CmtUser(String userName, String firstName, String lastName, String passWord, String email){ this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.passWord = passWord; this.email = email; } ...getter and setter
the Hibernate type was not castable to the property type (or vice-versa)
..mmmh? I do not really understand:-( -
3. Re: setParameter() IllegalArgumentException
jaikiran Dec 6, 2008 7:31 AM (in response to nschweig)Please post the entire exception stacktrace and also the entire code of CmtUser (I am mainly interested in the getId method there)
-
4. Re: setParameter() IllegalArgumentException
nschweig Dec 6, 2008 3:36 PM (in response to nschweig)CmtUser:
package de.cmt.model; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.hibernate.annotations.IndexColumn; @Entity @Table(name="CmtUser", uniqueConstraints=@UniqueConstraint(columnNames={"userName","passWord","email"})) public class CmtUser implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String userName; private String firstName; private String lastName; private String passWord; private String email; @Embedded private UserSettings settings = new UserSettings(); @ManyToMany(mappedBy="participants", fetch=FetchType.EAGER) @IndexColumn(name="INDEX_COL") private List <Course> courses = new ArrayList<Course>(); @ManyToMany(fetch=FetchType.EAGER) private List <Role> roles = new ArrayList<Role>(); public CmtUser(){} public CmtUser(String userName, String firstName, String lastName, String passWord, String email){ this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.passWord = passWord; this.email = email; } public void addRole(Role role){ ... } public void removeRole(Role role){ ... } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassWord() { return passWord; } public void setPassWord(String passWord) { this.passWord = passWord; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public List<Role> getRoles() { return roles; } public void setRoles(List<Role> roles) { this.roles = roles; } public UserSettings getSettings() { return settings; } public void setSettings(UserSettings settings) { this.settings = settings; } }
from my server.log:2008-12-06 21:25:26,375 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] (http-localhost%2F127.0.0.1-8080-1) parse() - HQL: SELECT c FROM de.cmt.model.Course c WHERE c.instructor = :instrId 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.AST] (http-localhost%2F127.0.0.1-8080-1) --- HQL AST --- \-[QUERY] 'query' +-[SELECT_FROM] 'SELECT_FROM' | +-[FROM] 'FROM' | | \-[RANGE] 'RANGE' | | +-[DOT] '.' | | | +-[DOT] '.' | | | | +-[DOT] '.' | | | | | +-[IDENT] 'de' | | | | | \-[IDENT] 'cmt' | | | | \-[IDENT] 'model' | | | \-[IDENT] 'Course' | | \-[ALIAS] 'c' | \-[SELECT] 'SELECT' | \-[IDENT] 'c' \-[WHERE] 'WHERE' \-[EQ] '=' +-[DOT] '.' | +-[IDENT] 'c' | \-[IDENT] 'instructor' \-[COLON] ':' \-[IDENT] 'instrId' 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.ErrorCounter] (http-localhost%2F127.0.0.1-8080-1) throwQueryException() : no errors 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] (http-localhost%2F127.0.0.1-8080-1) select << begin [level=1, statement=select] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.FromElement] (http-localhost%2F127.0.0.1-8080-1) FromClause{level=1} : de.cmt.model.Course (c) -> course0_ 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode] (http-localhost%2F127.0.0.1-8080-1) Resolved : c -> course0_.id 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode] (http-localhost%2F127.0.0.1-8080-1) Resolved : c -> course0_.id 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-localhost%2F127.0.0.1-8080-1) getDataType() : instructor -> org.hibernate.type.ManyToOneType(de.cmt.model.CmtUser) 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-localhost%2F127.0.0.1-8080-1) dereferenceShortcut() : property instructor in de.cmt.model.Course does not require a join. 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.DotNode] (http-localhost%2F127.0.0.1-8080-1) terminal propertyPath = [instructor] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.tree.FromReferenceNode] (http-localhost%2F127.0.0.1-8080-1) Resolved : c.instructor -> course0_.instructor 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] (http-localhost%2F127.0.0.1-8080-1) select : finishing up [level=1, statement=select] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.HqlSqlWalker] (http-localhost%2F127.0.0.1-8080-1) processQuery() : ( SELECT ( {select clause} course0_.id ) ( FromClause{level=1} Course course0_ ) ( WHERE ( = ( course0_.instructor course0_.id instructor ) ? ) ) ) 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.util.JoinProcessor] (http-localhost%2F127.0.0.1-8080-1) Using FROM fragment [Course course0_] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.antlr.HqlSqlBaseWalker] (http-localhost%2F127.0.0.1-8080-1) select >> end [level=1, statement=select] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.AST] (http-localhost%2F127.0.0.1-8080-1) --- SQL AST --- \-[SELECT] QueryNode: 'SELECT' querySpaces (Course) +-[SELECT_CLAUSE] SelectClause: '{select clause}' | +-[ALIAS_REF] IdentNode: 'course0_.id as id0_' {alias=c, className=de.cmt.model.Course, tableAlias=course0_} | \-[SQL_TOKEN] SqlFragment: 'course0_.abbreviation as abbrevia2_0_, course0_.active as active0_, course0_.description as descript4_0_, course0_.instructor as instructor0_, course0_.semester as semester0_, course0_.title as title0_' +-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[c], fromElementByTableAlias=[course0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]} | \-[FROM_FRAGMENT] FromElement: 'Course course0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=c,role=null,tableName=Course,tableAlias=course0_,origin=null,colums={,className=de.cmt.model.Course}} \-[WHERE] SqlNode: 'WHERE' \-[EQ] BinaryLogicOperatorNode: '=' +-[DOT] DotNode: 'course0_.instructor' {propertyName=instructor,dereferenceType=ROOT_LEVEL,propertyPath=instructor,path=c.instructor,tableAlias=course0_,className=de.cmt.model.Course,classAlias=c} | +-[ALIAS_REF] IdentNode: 'course0_.id' {alias=c, className=de.cmt.model.Course, tableAlias=course0_} | \-[IDENT] IdentNode: 'instructor' {originalText=instructor} \-[NAMED_PARAM] ParameterNode: '?' {name=instrId, expectedType=org.hibernate.type.ManyToOneType(de.cmt.model.CmtUser)} 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.ErrorCounter] (http-localhost%2F127.0.0.1-8080-1) throwQueryException() : no errors 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] (http-localhost%2F127.0.0.1-8080-1) HQL: SELECT c FROM de.cmt.model.Course c WHERE c.instructor = :instrId 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] (http-localhost%2F127.0.0.1-8080-1) SQL: select course0_.id as id0_, course0_.abbreviation as abbrevia2_0_, course0_.active as active0_, course0_.description as descript4_0_, course0_.instructor as instructor0_, course0_.semester as semester0_, course0_.title as title0_ from Course course0_ where course0_.instructor=? 2008-12-06 21:25:26,453 DEBUG [org.hibernate.hql.ast.ErrorCounter] (http-localhost%2F127.0.0.1-8080-1) throwQueryException() : no errors 2008-12-06 21:25:26,453 DEBUG [org.hibernate.jdbc.AbstractBatcher] (http-localhost%2F127.0.0.1-8080-1) about to open PreparedStatement (open PreparedStatements: 0, globally: 0) 2008-12-06 21:25:26,453 DEBUG [org.hibernate.jdbc.ConnectionManager] (http-localhost%2F127.0.0.1-8080-1) opening JDBC connection 2008-12-06 21:25:26,453 DEBUG [org.hibernate.SQL] (http-localhost%2F127.0.0.1-8080-1) select course0_.id as id0_, course0_.abbreviation as abbrevia2_0_, course0_.active as active0_, course0_.description as descript4_0_, course0_.instructor as instructor0_, course0_.semester as semester0_, course0_.title as title0_ from Course course0_ where course0_.instructor=? 2008-12-06 21:25:26,453 DEBUG [org.hibernate.jdbc.AbstractBatcher] (http-localhost%2F127.0.0.1-8080-1) about to close PreparedStatement (open PreparedStatements: 1, globally: 1) 2008-12-06 21:25:26,453 DEBUG [org.hibernate.jdbc.ConnectionManager] (http-localhost%2F127.0.0.1-8080-1) aggressively releasing JDBC connection 2008-12-06 21:25:26,453 DEBUG [org.hibernate.jdbc.ConnectionManager] (http-localhost%2F127.0.0.1-8080-1) releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)] 2008-12-06 21:25:26,453 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] (http-localhost%2F127.0.0.1-8080-1) mark transaction for rollback 2008-12-06 21:25:26,500 DEBUG [org.jboss.jpa.deployment.ManagedEntityManagerFactory] (http-localhost%2F127.0.0.1-8080-1) ************** closing entity managersession ************** 2008-12-06 21:25:26,718 ERROR [facelets.viewhandler] (http-localhost%2F127.0.0.1-8080-1) Error Rendering View[/app/course/show_courses.xhtml] javax.faces.FacesException: javax.el.ELException: /app/course/show_courses.xhtml @20,90 rendered="#{!empty courseBean.coursesForInstructor}": Error reading 'coursesForInstructor' on type de.cmt.managedBeans.CourseBean at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:393) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930) at javax.faces.render.Renderer.encodeChildren(Renderer.java:148) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942) at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592) at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108) at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177) at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267) at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380) at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507) 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:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:189) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:91) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:92) 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.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:325) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:595) Caused by: javax.el.ELException: /app/course/show_courses.xhtml @20,90 rendered="#{!empty courseBean.coursesForInstructor}": Error reading 'coursesForInstructor' on type de.cmt.managedBeans.CourseBean at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76) at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390) ... 38 more Caused by: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.cmt.model.CmtUser.id at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:157) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:462) at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:97) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62) at $Proxy199.invoke(Unknown Source) at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:125) at $Proxy198.getCoursesForInstructor(Unknown Source) at de.cmt.managedBeans.CourseBean.getCoursesForInstructor(CourseBean.java:45) 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 javax.el.BeanELResolver.getValue(BeanELResolver.java:62) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at org.apache.el.parser.AstValue.getValue(AstValue.java:118) at org.apache.el.parser.AstEmpty.getValue(AstEmpty.java:45) at org.apache.el.parser.AstNot.getValue(AstNot.java:42) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71) ... 39 more Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.cmt.model.CmtUser.id at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76) at de.cmt.beans.courseAdministration.CourseHandler.getCoursesForInstructor(CourseHandler.java:56) 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.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69) at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73) at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59) 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.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72) at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_30456965.invoke(InvocationContextInterceptor_z_fillMethod_30456965.java) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88) at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_30456965.invoke(InvocationContextInterceptor_z_setup_30456965.java) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) ... 76 more Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of de.cmt.model.CmtUser.id at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:206) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3619) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3335) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:241) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110) at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:61) at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589) at org.hibernate.loader.Loader.doQuery(Loader.java:696) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67) ... 107 more Caused by: java.lang.IllegalArgumentException at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37) at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) at java.lang.reflect.Field.get(Field.java:357) at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55) ... 128 more
[/url]
Thanks! -
5. Re: setParameter() IllegalArgumentException
jaikiran Dec 7, 2008 10:30 AM (in response to nschweig)Does the id column in the User table has any row(s) with null ids? If yes, then try deleting those rows manually and then run the application.
-
6. Re: setParameter() IllegalArgumentException
nschweig Dec 8, 2008 5:04 AM (in response to nschweig)Thank you for your hints.
I do not know what happened. Since this morning it works.
In the way I described it above. I did NOTHING in a different way!
I do not understand but I am happy :-)
Thanks and greetings
Nicki -
7. Re: setParameter() IllegalArgumentException
nschweig Dec 8, 2008 5:54 AM (in response to nschweig)Hi
forget my post; I invoked another method....
The problem is still the same.
The id column in the User table is never null because the id is generated automatically.
... CMTUSER@Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; ...
Any more ideas? I hope so!
Nicki -
8. Re: setParameter() IllegalArgumentException
nschweig Dec 15, 2008 5:25 AM (in response to nschweig)I did not find a solution yet...
can anybody help me please?
Thanks
Nicki -
9. Re: setParameter() IllegalArgumentException
nschweig Dec 24, 2008 6:08 AM (in response to nschweig)Solution:
CourseHandler:public List<Course> getCoursesForInstructor(CmtUser instructor){ try{ Query q = em.createQuery( "SELECT c FROM Course c" + " WHERE c.instructor = :instructor"); q.setParameter("instructor",instructor); List<Course> courses = (List<Course>) q.getResultList(); return courses ; } catch(EntityNotFoundException ex){ System.out.println("FEHLER!!!!"+ex); } return null; }
Course:@Entity public class Course implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String title; private String abbreviation; private String description; private String semester; @Column(columnDefinition="BOOL") private boolean active = false; //unidirektional @ManyToOne @JoinColumn(name="instructor") private CmtUser instructor; ...