• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

javax.ejb.EJBException when trying to inject data into database on form input

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again!

I'm trying to inject data into database based on form input but i'm facing a nasty exception and I can't seem to be able to wrap my head around a scalable solution and I have tried many... Maybe you can help? How can I find the needle in this haystack?
It's very hard to pinpoint with so many attributes! I tried to remove @NotNull from every class but the exception remains no matter what I try... I also changed persistence.xml to value="None" to turn it off but it was a bad idea as expected and it didn't help.

at controller.ControllerServlet.doPost(ControllerServlet.java:409) refers to code:
at session.OrderManager.addCustomer(OrderManager.java:55) refers to code:
at session.OrderManager.placeOrder(OrderManager.java:34) refers to code:





 
Sheriff
Posts: 21760
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrap the code in OrderManager.addCustomer in a try-catch block, catch any ConstraintViolationException, log it and its violation, and rethrow:
If that still doesn't give you enough information, log each separate constraint violation, especially the message and property path.
 
Benji Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my case the error meant:

I had a constraint violated on my model that was detected before persisting to the datastore. This meant that my Customer or related entities had a Validation (eg. @NotNull, @Size) that was not honored.

The solution:

Removing every @NotNull annotation in my database and making sure the length of the form input did respect the database columns @Size or increasing it. Hope it can help you as well if you are seeing this!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!