• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.IllegalArgumentException: Cannot convert error occurred.  RSS feed

 
Julius Adek
Greenhorn
Posts: 26
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please when ever I run this application i got the following message:

java.lang.IllegalArgumentException: Cannot convert 4801 of type class java.lang.String to class com.smartshop.entity.category.Category


The files are:


Category.java






Item.class






persistence.xml






create_item.xhtml

             


  
//The html file has been reduced to preserve space.



ItemBean.java


   
}



The issue is that if remove "categoryId" from Item.java, this app will work fine but anytime I include it back it will issue the above error. Please, what can I do to resolve this? Thanking you for your quick response.
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you provide mapping class tag for Category class ? Just confirm.
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

   We've Category_Id to be mapped by OneToMany association but why do we specify and mark the whole Category class as a Category_ID. I would suggest to try the category_id to be fetched using a getter from CATEGORY class and above the Category_ID getter method specify the annotation then it should work as intended. Try.

   *Just for trouble shooting pass a hard coded string/int  as a category_id then it should work fine then we can proceed further.

Regards

 
 
Julius Adek
Greenhorn
Posts: 26
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thanks Mohammed, I have long resolve this issue, just forget to post feedback message concerning it. Well, I resolved it by removing ManyToOne annotation since the CRUD of both tables in the database would done manually and not by JPA framework. Thanks for your response.
 
Julius Adek
Greenhorn
Posts: 26
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moreover, I later detected that it was converter issue so I searched net. But later came across omnifaces Converter, so I used it and everything working perfectly now.
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Good to hear that has been resolved. It would be really helpful if shared about what converter that helped to resolve.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!