English 中文(简体)
采用EJB 通知进行扶养注射
原标题:Dependency injection using EJB annotation

Simple WebSevice

@WebService
@Stateless
public class HistoryFormatterWebService implements IHistoryFormatterWebService
{
   @EJB
   private IHistoryFormatter historyFormatter;

   public byte[] formatHistory(final byte[] data)
   {
      System.err.println("hello from service");

      return null;
   }
}  

IHistory 格式

@Local
public interface IHistoryFormatter
{  
// ..  
}  

IHistoryFormatter is bean from another project (query-ear.ear) but he is also deployed on jBoss.
My WebService deploy on jBoss normally. And jBoss wrote

11:17:09,506 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=wsformatter-ear-1.0-SNAPSHOT.ear,jar=wsformatter-ejb-1.0-SNAPSHOT.jar,name=HistoryFormatterWebService,service=EJB3 with dependencies:
11:17:09,568 INFO  [JmxKernelAbstraction]   jboss.j2ee:ear=query-ear.ear,jar=query-services.jar,name=HistoryFormatter,service=EJB3
11:17:09,568 INFO  [EJBContainer] STARTED EJB: com.wsformatter.HistoryFormatterWebService ejbName: HistoryFormatterWebService

但是,当我向它提出要求时(利用SapUI),我会例外。

java.lang.RuntimeException: Non matching type for inject of field: private com.softcomputer.softlab.lquery.service.IHistoryFormatter com.softcomputer.wsformatter.HistoryFormatterWebService.historyFormatter for type: $Proxy250 of jndiName env/com.softcomputer.wsformatter.HistoryFormatterWebService/historyFormatter
intfs: , com.softcomputer.softlab.lquery.service.IHistoryFormatter, org.jboss.ejb3.JBossProxy
    at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:128)
    at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:106)
    at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:63)
    at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
    at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
    at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
    at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
    at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
    at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)
    at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:221)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:466)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:284)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:201)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:134)
    at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException
    at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
    at java.lang.reflect.Field.set(Field.java:656)
    at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:116)
    ... 41 more 

谁能帮助我?

最佳回答

只是一个野心:

java.lang.RuntimeException: Non matching type for inject of field: 
[...] com.softcomputer.softlab.lquery.service.IHistoryFormatter [...] for type: 
[...] of [...] com.softcomputer.softlab.lquery.service.IHistoryFormatter[...]

对我来说,有2<>>>> /em> 栏目,由2个班轮装载。 即使这些班级的名称相同,如果他们被不同班轮载体装载,他们也会被认为不同。

因此,检查您的交接班组合,最好是在博览会的一个地点提供。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签