Weblogic在javax.ejb.EJBException中包装应用程序异常

时间:2022-05-07 10:45:06

My ear application was working fine. But suddenly it started to throw javax.ejb.EJBException in some method calls, instead of returning the original Application Exception (annotated with @ApplicationException(rollback=true). Now the original application exception is wrapped in the EJBException. the Currently the other developer who was working in the project is on leave. Therefore I have no idea what he has done to the code for happening this. This application exception and ejb remote interfaces are in a separate jar file which is deployed as a shared library in the weblogic.

我的耳朵应用工作正常。但是突然它开始在一些方法调用中抛出javax.ejb.EJBException,而不是返回原始的Application Exception(用@ApplicationException注释(rollback = true)。现在原始的应用程序异常包含在EJBException中。目前是其他的开发人员那个在项目中工作的人正在休假。所以我不知道他对代码发生了什么。这个应用程序异常和ejb远程接口是在一个单独的jar文件中,它被部署为weblogic中的共享库。

I would like to know what can be responsible for throwing this EJBException instead of throwing the application exception. I think may be @ApplicationException annotation is not correctly detected by the weblogic. Could anyone give me a help to resolve this issue?

我想知道什么可以负责抛出这个EJBException而不是抛出应用程序异常。我想可能是weblogic没有正确检测到@ApplicationException注释。任何人都可以帮我解决这个问题吗?

1 个解决方案

#1


5  

I was able to solve the issue by adding the application exception in the "throw" clause of ejb method signature.

我能够通过在ejb方法签名的“throw”子句中添加应用程序异常来解决问题。

Previously all ejb classes and application exception class was in the same jar file. But later the application exception class and ejb remote interfaces were put to another jar file called "api" jar file and the relevant ejb files were kept in the previous jar file.

以前所有的ejb类和应用程序异常类都在同一个jar文件中。但后来应用程序异常类和ejb远程接口被放到另一个名为“api”jar文件的jar文件中,相关的ejb文件保存在之前的jar文件中。

It seems it is enough to declare an application exception with @ApplicationException, if we need it to treat as an application excpetion when all classes are in the same jar file. But if the application exception class is in a separate jar file, we need to add this application exception in the "throw" clause of the ejb method signature to interpret it as an application exception by the weblogic server.

使用@ApplicationException声明应用程序异常似乎已经足够了,如果我们需要它在所有类都在同一个jar文件中时将其视为应用程序激活。但是,如果应用程序异常类位于单独的jar文件中,我们需要在ejb方法签名的“throw”子句中添加此应用程序异常,以将其解释为weblogic服务器的应用程序异常。

#1


5  

I was able to solve the issue by adding the application exception in the "throw" clause of ejb method signature.

我能够通过在ejb方法签名的“throw”子句中添加应用程序异常来解决问题。

Previously all ejb classes and application exception class was in the same jar file. But later the application exception class and ejb remote interfaces were put to another jar file called "api" jar file and the relevant ejb files were kept in the previous jar file.

以前所有的ejb类和应用程序异常类都在同一个jar文件中。但后来应用程序异常类和ejb远程接口被放到另一个名为“api”jar文件的jar文件中,相关的ejb文件保存在之前的jar文件中。

It seems it is enough to declare an application exception with @ApplicationException, if we need it to treat as an application excpetion when all classes are in the same jar file. But if the application exception class is in a separate jar file, we need to add this application exception in the "throw" clause of the ejb method signature to interpret it as an application exception by the weblogic server.

使用@ApplicationException声明应用程序异常似乎已经足够了,如果我们需要它在所有类都在同一个jar文件中时将其视为应用程序激活。但是,如果应用程序异常类位于单独的jar文件中,我们需要在ejb方法签名的“throw”子句中添加此应用程序异常,以将其解释为weblogic服务器的应用程序异常。