• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic