我正在尝试子类化LocalStatelessSessionProxyFactoryBean
以覆盖invoke
方法。
有一个客户端通过http调用器机制访问服务,我需要解开所有EJBExceptions,因为客户端没有类。 我也没有用弹簧AOP试过。
我有一些约束,即向客户端提出的所有异常都是运行时,我无法使用@ApplicationException注释所有异常。 (如果这个注释是继承的,那对我来说这将是一个很好的解决方案)
我的春季配置看起来是:
<bean name="/TestService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter" >
<property name="service" ref="testServiceEJB" />
<property name="serviceInterface" value="package.shared.services.ITestService" />
</bean>
<bean name="testServiceEJB" class="package.framework.server.spring.LocalStatelessSessionProxyFactoryBean" >
<property name="jndiName" value="framework/TestServiceImpl/local"/>
<property name="businessInterface" value="package.shared.services.ITestService"/>
</bean>
我的问题是在启动jboss时,它告诉我
[org.springframework.web.context.ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/TestService' defined in ServletContext resource [/WEB-INF/service-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Service interface [package.framework.shared.services.ITestService] needs to be implemented by service [package.framework.server.spring.LocalStatelessSessionProxyFactoryBean@133c8e5] of class [package.framework.server.spring.LocalStatelessSessionProxyFactoryBean]
使用标记jee:local-slsb
或使用类LocalStatelessSessionProxyFactoryBean
声明bean时,我没有此错误。
调试时,代理不会发生在应有的位置,检查失败:
at org.springframework.remoting.support.RemoteExporter.checkServiceInterface(RemoteExporter.java:136)
at org.springframework.remoting.support.RemoteExporter.getProxyForService(RemoteExporter.java:155)
at org.springframework.remoting.rmi.RemoteInvocationSerializingExporter.prepare(RemoteInvocationSerializingExporter.java:88)
at org.springframework.remoting.rmi.RemoteInvocationSerializingExporter.afterPropertiesSet(RemoteInvocationSerializingExporter.java:81)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
感谢您的帮助
答案 0 :(得分:0)
我将spring的HttpInvokerServiceExporter子类化为在handleRequest()中解包EJBExceptions。