简体   繁体   中英

Upgrading from Glassfish 2 to Glassfish 3. Exceptions no longer roll back transactions

I'm trying to upgrade my ear from glassfish 2 to glassfish 3. We used to have our session beans and our entities all in one jar file. I've learned that I need to put these in separate jar files to be able to deploy to glassfish 3. The way I did this was by creating a new jar and moved the session beans, the ejb-jar.xml , persistence.xml and sun-ejb-jar.xml in them. The session bean lib has the old lib as a dependency. The old lib still contains the custom Exception classes we've used and entities and pretty much everything else that used to be there.

But what I've notice from an integration test is that when exceptions get thrown, the transactions don't get rolled back like they used to. I'm still deploying to GF2 right now. Other than this subtle problem, everything appears to be working. How do I fix this issue? Do I need to move these Exception classes into the session bean jar?

Here's an example of what one of these exceptions looks like:

@ApplicationException(rollback=true)
public class MessageOutOfOrderException extends ConditionException { //this is the one that gets thrown
//...
}

@ApplicationException(rollback=true)
public class ConditionException extends Exception { //this is the parent.  It also gets thrown directly sometimes
//...
}

This is a GF2 bug: https://java.net/jira/browse/GLASSFISH-5183

The workaround is to modify your ejb-jar.xml and add lines like this into it:

<assembly-descriptor>
    <application-exception>
        <exception-class>com.blah.EntityAccessException</exception-class>
        <rollback>true</rollback>
    </application-exception>

I'm hoping GF3 won't need to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM