[EJB/JBoss] - @ApplicationException(rollback=false) does roll back @PreUpd
by skeyewalk
I have encountered a very unfortunate and strange difference in the way JBoss application server 4.2.2 treats exceptions raised from inside EJB callback methods marked with @PrePersist and @PreUpdate.
My exception is a RuntimeException, and is marked for rollback=false. I use it to report back validation errors. The validation is triggered in the @PrePersist and @PreUpdate callback methods. However, while this behaves very nicely for the persist method, the update does not appear to take the @ApplicationException annotation into account. So the transaction is rolled back and my exception is wrapped inside a javax.persistence.PersistenceException and then inside a javax.transaction.RollbackException, blowing up my whole concept.
I have also tried configuring the ApplicationException in the ejb-jar.xml, but the result was identical.
Here's the exception class:
@ApplicationException(rollback=false)
| public class ValidationExceptionRuntimeWrapper extends RuntimeException
| {
| private static final long serialVersionUID = 1L;
|
| private ValidationException validationException;
|
|
| public ValidationExceptionRuntimeWrapper(ValidationException validationException)
| {
| this.validationException = validationException;
| }
|
| public ValidationException getValidationException()
| {
| return validationException;
| }
|
| public void setValidationException(ValidationException validationException)
| {
| this.validationException = validationException;
| }
|
| }
|
Has anyone seen this before or knows how to explain this?
I would be so grateful for any help!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118553#4118553
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118553
18 years, 3 months
[Persistence, JBoss/CMP, Hibernate, Database] - configuration of hiberante events
by mars1412
I am trying to create some eventlisteners for hibernate:
http://www.hibernate.org/hib_docs/reference/en/html/events.html#objectsta...
but my listeners seem not to fire.
I think, it's just a configuration issue.
I created a simple listener, by overriding the default hibernate update event listener:
public class HibernateUpdateEventListener extends DefaultUpdateEventListener {
| @Override
| public void onSaveOrUpdate(SaveOrUpdateEvent event) {
| System.err.println("update-event listener fired");
|
| super.onSaveOrUpdate(event);
| }
| }
|
the configuration in my hibernate.cfg.xml file:
| <event type="update">
| <listener class="com.twentyfouract.web.session.util.HibernateUpdateEventListener"/>
| </event>
this file will be located in my.ear/my.jar/hibernate.cfg.xml (in the same direcotry, as the seam.properties file)
* is this the correct place fo the hibernate.cfg.xml file?
| * do I need some other configuration?
| * might this intefere with some other configuration files, like persistence.xml, ejb-jar.xml?
|
When I now call update() the entity, I expect the message to be written to stderr, which does not happen.
the entity values in the database have changed, but the logmessage does not show up
I also tried the same with DefaultSaveEventListener and calling em.persist() which creates a new entity in the database, but does not show my events logmessage
maybe it's just some configuration problem - I am using SEAM: see also my original post in the SEAM forum:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118460#4118460
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118548#4118548
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118548
18 years, 3 months
[Installation, Configuration & DEPLOYMENT] - LDAP-binding via ExternalContext: how to auto-reconnect ?
by axismundi
We are binding an LDAP-server into the JNDI-context.
It works properly until redeployment.
After redeployment the connection is lost and no new connection is being established.
How to specify to auto-reconnect after connection was lost??
<!-- Bind remote LDAP server -->
| <mbean code="org.jboss.naming.ExternalContext"
| name="jboss.jndi:service=ExternalContext,jndiName=external/ldap/acme">
| <attribute name="JndiName">external/ldap/acme</attribute>
| <attribute name="Properties">
| java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
| java.naming.provider.url=ldap://server:389/o=acme
| java.naming.security.principal=cn=ReadOnlyAdmin,o=swm
| java.naming.security.authentication=simple
| java.naming.security.credentials=password
| com.sun.jndi.ldap.connect.pool=true
| com.sun.jndi.ldap.connect.timeout=5000
| </attribute>
| <attribute name="InitialContext">javax.naming.ldap.InitialLdapContext</attribute>
| <attribute name="RemoteAccess">false</attribute>
| </mbean>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118542#4118542
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118542
18 years, 3 months