Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJB - Everything works except persist()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, this is my first application using openEJB and I'm trying to develop a simple Blog.
I have four entities : User, Comment, Post and Categories (a post can have multiple categories)
Here is the code of my Category Entity :


And in my JpaCategoryDao (where I have the @stateless), I have :


When I try to call the JpaCategoryDao.addCategory(), I have an exception :

exception

javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization
org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:341)
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:287)
$Proxy72.addCategory(Unknown Source)
com.supinfo.sun.supinblog.servlet.AddCategoryServlet.doPost(AddCategoryServlet.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.supinfo.sun.supinblog.filter.AuthenticateFilter.doFilter(AuthenticateFilter.java:56)



I've been searching about this exception, but I can't find a solution, I don't even understand what I do wrong. Especially because in my Dao where I have em.merge(), it works, I didin't tried the em.delete() but all other functions works (em.find, queries, etc)
So I've been thinking that I probably did something wrong when i declared my entities, or when I create my tables and fields in my database... But I've been searching for hours now, and I can't find what is wrong...

My Entities : (I don't write all my setters and getters)






And Finally, this is the structure of my Mysql Database :


If someone can help me, it would be great... Because I don't see what's wrong...

(And also, I'm sorry for my expression, but I'm french, so...)

Thank You very much !!
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the exception log before "Transaction was rolled back" log, the rollback will happen only after there is any database exception, can you post your client code that is invoking addCategory ? are you passing unique value for Id? this is general error during trial and error for first time...
 
Julie Lo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's okay, I solved my problem.
I've been looking into Mysql Queries log, and my problem was that the table OPENJPA_SEQUENCE_TABLE didn't exist, so I had to create it manually and now it works perfectly
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic