简体   繁体   English

从Glassfish 2升级到Glassfish3。例外不再回滚事务

[英]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. 我正在尝试将我的耳朵从glassfish 2升级到glassfish3。我们以前将会话bean和实体都放在一个jar文件中。 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. 我了解到我需要将它们放在单独的jar文件中,以便能够部署到glassfish3。我这样做的方法是创建一个新的jar并移动会话bean ejb-jar.xmlpersistence.xml和其中的sun-ejb-jar.xml The session bean lib has the old lib as a dependency. 会话bean lib具有旧的lib作为依赖项。 The old lib still contains the custom Exception classes we've used and entities and pretty much everything else that used to be there. 旧的lib仍然包含我们使用过的自定义Exception类,实体以及几乎所有以前存在的所有内容。

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. 我现在仍在部署GF2。 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? 我是否需要将这些Exception类移动到会话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 这是一个GF2错误: https : //java.net/jira/browse/GLASSFISH-5183

The workaround is to modify your ejb-jar.xml and add lines like this into it: 解决方法是修改ejb-jar.xml并在其中添加如下代码:

<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. 我希望GF3不需要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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