JBoss EAP 7 - 对注入资源的错误跟踪

时间:2016-11-23 20:35:38

标签: web-services dependency-injection jboss jboss-eap-7

我遇到了一个问题,我认为如果有人知道答案,我可能会看到。由于资源实际被注入,这不是一个太大的问题 - 但是控制台正在显示资源无法解决的信息警告。

此问题在EAP 5.1.2中不会发生。我很好奇是否有其他人遇到过这个问题,而且可能我没有在EAP 7中做得正确,因此有一个解决方法。

背景:

  1. 打包在EAR中的EJB Web Service。 EAR没有application.xml或jboss-deployment-structure.xml
  2. 注意:虽然我尝试添加jboss-deployment-structure.xml只是为了看它是否有帮助。

    1. 无状态EJB是一种Web服务
    2. 以下是ejb-jar.xml文件的摘录:

              <env-entry>
                  <description>Variable to distinguish between prod, uat and qa environments</description>
                  <env-entry-name>net.mycompany.mypackage.mysubpackage.MyWSService.isUAT</env-entry-name>
                  <env-entry-type>java.lang.Boolean</env-entry-type>
                  <env-entry-value>false</env-entry-value>
              </env-entry>
      
              <env-entry>
                  <description>Variable to distinguish between prod, uat and qa environments</description>
                  <env-entry-name>isQA</env-entry-name>
                  <env-entry-type>java.lang.Boolean</env-entry-type>
                  <env-entry-value>false</env-entry-value>
              </env-entry>
      

      正如您所看到的,我尝试了两种方式,例如:在env-entry-name中包含完整的包和类名,以及普通的旧env条目名称

      以下是网络服务代码段:

      @SuppressWarnings("unused")
      @Stateless
      @Local(IMyWSService.class)
      @WebService
      public class MyWSService implements IMyWSService {
      
          @Resource(name = "isUAT")
          private boolean isUAT;
          @Resource
          private boolean isQA;
      
          @WebMethod
          @ResponseWrapper(localName="doSomethingResponse", className="Response", targetNamespace="http://model.mysubpackage.mypackage.net")
          public Response doSomething
          (@WebParam(name="param1", mode=Mode.IN) String param1
          , @WebParam(name="param2", mode=Mode.IN) String param2
          , @WebParam(name="param3", mode=Mode.IN) String param3) {
      
          //more and more code
          .
          .
          .
          //pertinent method
          initAndSetEnvEntrieVars();
          .
          .
          .
          //the method which actually utilizes the environment variables
          private void initAndSetEnvEntrieVars() {
          //setup env-entry related vars
                  if(isUAT){
                      System.out.println("We're in UAT");
      
                  }else if(isQA){
                      System.out.println("We're in QA");
                  }
          }
      

      注意:并且实际上正在注入这些值,为了简洁,我从代码中删除了大约15个。

      继承JBoss控制台中的输出

      12:43:34,919 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) WFLYDS0004: Found MyUseful.ear in deployment directory. To trigger deployment create a file called MyUseful.ear.dodeploy
      12:43:34,925 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "MyUseful.ear" (runtime-name: "MyUseful.ear")
      12:43:34,968 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0207: Starting subdeployment (runtime-name: "MyUsefulService.jar")
      12:43:35,017 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0003: Processing weld deployment MyUseful.ear
      12:43:35,030 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0003: Processing weld deployment MyUsefulService.jar
      12:43:35,032 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-3) WFLYEJB0473: JNDI bindings for session bean named 'MyWSService' in deployment unit 'subdeployment "MyUsefulService.jar" of deployment "MyUseful.ear"' are as follows:
      
      java:global/MyUseful/MyUsefulService/MyWSService!net.mycompany.mypackage.mysubpackage.IMyWSService 
      java:app/MyUsefulService/MyWSService!net.mycompany.mypackage.mysubpackage.IMyWSService 
      java:module/MyWSService!net.mycompany.mypackage.mysubpackage.IMyWSService 
      
      12:43:35,034 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0006: Starting Services for CDI deployment: MyUseful.ear
      12:43:35,036 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) WFLYWELD0009: Starting weld service for deployment MyUseful.ear
      12:43:35,056 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 71) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
      12:43:35,057 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 71) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
      12:43:35,057 INFO  [org.jboss.ws.cxf.metadata] (MSC service thread 1-7) JBWS024061: Adding service endpoint metadata: id=MyWSService
       address=http://localhost:8080/MyUsefulService/MyWSService
       implementor=net.mycompany.mypackage.mysubpackage.MyWSService
       serviceName={http://model.mysubpackage.mypackage.net/}MyWSServiceService
       portName={http://model.mysubpackage.mypackage.net/}MyWSServicePort
       annotationWsdlLocation=null
       wsdlLocationOverride=null
       mtomEnabled=false
      12:43:35,058 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 71) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
      12:43:35,058 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 71) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
      12:43:35,068 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 71) WFLYCLINF0002: Started client-mappings cache from ejb container
      12:43:35,080 INFO  [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-7) Creating Service {http://model.mysubpackage.mypackage.net/}MyWSServiceService from class net.mycompany.mypackage.mysubpackage..MyWSService
      12:43:35,144 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-7) Setting the server's publish address to be http://localhost:8080/MyUsefulService/MyWSService
      12:43:35,146 INFO  [org.apache.cxf.common.injection.ResourceInjector] (MSC service thread 1-7) failed to resolve resource isUAT
      12:43:35,147 INFO  [org.apache.cxf.common.injection.ResourceInjector] (MSC service thread 1-7) failed to resolve resource isQA
      12:43:35,183 INFO  [org.jboss.ws.cxf.deployment] (MSC service thread 1-7) JBWS024074: WSDL published to: file:/C:/jboss-eap-7.0/standalone/data/wsdl/MyUseful.ear/MyUsefulService.jar/MyWSServiceService.wsdl
      12:43:35,198 INFO  [org.jboss.as.webservices] (MSC service thread 1-4) WFLYWS0003: Starting service jboss.ws.endpoint."MyUseful.ear"."MyUsefulService.jar".MyWSService
      12:43:35,378 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 71) WFLYUT0021: Registered web context: /MyUsefulService
      12:43:35,403 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "MyUseful.ear" (runtime-name : "MyUseful.ear")
      

      再次,这更像是一件令人讨厌的事情,但我觉得我会帮助所有人来管理它,以防万一其他人被困在研究它几个小时。

      更新:抱歉,我没有意识到StackExchange和StackOverFlow之间的区别 - 总是想知道为什么不同的名字......但是太忙了,无法找出原因。

1 个答案:

答案 0 :(得分:0)

所以在得到好人的帮助/建议后,例如JBoss论坛Alessio的Alessio Soldano和jaikiran pai基本上说: &#34;您好, 我需要去检查代码以确认,但我认为那里发生的事情是WS层基本上通过不同的机制来注入值。首先,它尝试让Apache CXF层解析值,如果失败(这里显示的是日志)它使用内部JBoss机制,这实际上是从ejb-jar.xml描述符中获取值。&#34;

和...

&#34;只需在日志中忽略该消息即可完成。它基本上是一个内部的东西,日志来自apache cxf所以我们在这种情况下做的不多,以避免它。 你链接的线程与一个稍微不同的场景有关,这个场景是由一个错误引起的(好吧,当时缺少一个功能),但是这个问题已经解决了。&#34;

论坛帖子是: JBoss EAP 7 - erroneous trace on Injected Resources

如果有人想进一步跟进它 - 看起来我们现在只是坚持它