0 Replies Latest reply on May 31, 2017 3:35 PM by hadson

    Cannot inject SOAP WS through annotation @WebServiceRef

    hadson

      Hi i have little with wildfly and webservices. So let's start. I created WebService application (packaged as .war and deployed on wildfly) which contains:

       

       

      @WebService
      public interface HolidayCalculatorWS {
      
      
           @WebMethod
           @WebResult(name = "daysTillHoliday")
           Long getDaysTillHoliday();
      }
      

       

       

       

      @WebService(endpointInterface = "app.ws.HolidayCalculatorWS")
      public class DefaultHolidayCalculatorWS implements HolidayCalculatorWS{
      
      
          @Inject
          private HolidayCalculator holidayCalculator;
      
      
          public Long getDaysTillHoliday() {
              return holidayCalculator.getDaysToHoliday();
          }
      }
      

       

       

      Then i deployed thoose those files as .war. Service was created successfully:

       

      address=http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS

      implementor=app.ws.DefaultHolidayCalculatorWS

      serviceName={http://ws.app/}DefaultHolidayCalculatorWSService

      portName={http://ws.app/}DefaultHolidayCalculatorWSPort

      annotationWsdlLocation=null

      wsdlLocationOverride=null

      mtomEnabled=false

       

      Then i created second application (also .war and deployed on the same wildfly server) which contains:

      @WebService(targetNamespace = "http://ws.app/",serviceName = "DefaultHolidayCalculatorWSService")
      public interface HolidayCalculatorWS {
      
      
          @WebMethod
          @WebResult(name = "daysTillHoliday")
          Long getDaysTillHoliday();
      }
      

       

      @WebServlet(value = "/soaptest")
      public class SOAPTest extends HttpServlet {
      
          @WebServiceRef(wsdlLocation = "http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS?wsdl")
          private HolidayCalculatorWS holidayCalculatorWS;
      
          protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
          }
      
      
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                holidayCalculatorWS.getDaysTillHoliday();
           }
      }
      

       

      When i deploy the second application and open servlet i am getting error:

       

      21:21:21,793 ERROR [io.undertow.request] (default task-15) UT005023: Exception handling request to /clientSOAP/soaptest: javax.servlet.ServletException: UT010013: Could not instantiate app.SOAPTest

        at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:247)

        at io.undertow.servlet.core.ManagedServlet.getServlet(ManagedServlet.java:171)

        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:84)

        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)

        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)

        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

      Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance

        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)

        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)

        at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)

        at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:149)

        at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$6.createInstance(UndertowDeploymentInfoService.java:1379)

        at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:245)

        ... 38 more

      Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/app.SOAPTest/holidayCalculatorWS

        at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:319)

        at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:97)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)

        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)

        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)

        ... 43 more

      Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/app.SOAPTest/holidayCalculatorWS [Root exception is org.jboss.wsf.spi.WSFException: Cannot create service]

        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:159)

        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)

        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)

        at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:316)

        ... 60 more

      Caused by: org.jboss.wsf.spi.WSFException: Cannot create service

        at org.jboss.wsf.spi.WSFException.rethrow(WSFException.java:55)

        at org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceObjectFactoryJAXWS.getObjectInstance(CXFServiceObjectFactoryJAXWS.java:119)

        at org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceRefFactoryImpl.newServiceRef(CXFServiceRefFactoryImpl.java:35)

        at org.jboss.as.webservices.webserviceref.WebServiceManagedReferenceFactory.getReference(WebServiceManagedReferenceFactory.java:37)

        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)

        ... 65 more

      Caused by: javax.xml.ws.WebServiceException: Could not find service named null in wsdl http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS?wsdl

        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:173)

        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)

        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)

        at org.jboss.wsf.stack.cxf.client.ProviderImpl$JBossWSServiceImpl.<init>(ProviderImpl.java:572)

        at org.jboss.wsf.stack.cxf.client.ProviderImpl.createServiceDelegate(ProviderImpl.java:290)

        at javax.xml.ws.Service.<init>(Service.java:63)

        at javax.xml.ws.Service.create(Service.java:710)

        at org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceObjectFactoryJAXWS.instantiateService(CXFServiceObjectFactoryJAXWS.java:256)

        at org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceObjectFactoryJAXWS.getObjectInstance(CXFServiceObjectFactoryJAXWS.java:86)

        ... 68 more

       

      What is the reason of this problem? When i call service from standalone java aplication using QName and Service.getPort(...) everything works fine.
      Full question is available also on stack (with wsdl ) :

      https://stackoverflow.com/questions/44268860/cannot-consume-webservice-in-javaee?noredirect=1#comment75545867_44268860