I have picked an example from jboss ‘helloworld-ws’. I created a client spring based web application helloworld-ws-test. Then I created a webservice client through jboss webservice client (it also create one sample client with main method).
I deploy both applications in jboss 6.1-eap server. So if I try to access the webservice through sample client I am getting the output without any problem but when I copy the same code into helloworld-ws-test web application controller and try to access webservice I am getting the following exception.
11:51:55,025 DEBUG [org.springframework.web.servlet.DispatcherServlet] (http-localhost/127.0.0.1:8080-1) Could not complete request: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.jboss.wsf.stack.cxf.client.ProviderImpl$JBossWSServiceImpl.<init>(ProviderImpl.java:479)
at org.jboss.wsf.stack.cxf.client.ProviderImpl.createServiceDelegate(ProviderImpl.java:165)
at javax.xml.ws.Service.<init>(Service.java:57) [jboss-jaxws-api_2.2_spec-2.0.1.Final-redhat-2.jar:2.0.1.Final-redhat-2]
at org.jboss.jbossas.quickstarts.wshelloworld.helloworld.HelloWorldService_Service.<init>(HelloWorldService_Service.java:47) [classes:]
at org.jboss.as.quickstarts.mvc.MemberController.displaySortedMembers(MemberController.java:20) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_09]
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
... 36 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <HTML>
at [row,col,system-id]: [4,0,"http://localhost:8080/helloworld-ws/HelloWorldService?wsdl"]
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:243)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:192)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
... 38 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <HTML>
at [row,col,system-id]: [4,0,"http://localhost:8080/helloworld-ws/HelloWorldService?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5532)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2720)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1072)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1250)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1144)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1071)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:234)
... 40 more
11:51:55,037 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/helloworld-ws-test].[jboss-as-kitchensink]] (http-localhost/127.0.0.1:8080-1) JBWEB000236: Servlet.service() for servlet jboss-as-kitchensink threw exception: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <HTML>
at [row,col,system-id]: [4,0,"http://localhost:8080/helloworld-ws/HelloWorldService?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5532)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2720)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1072)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1250)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1144)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1071)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:234)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:192)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
at org.jboss.wsf.stack.cxf.client.ProviderImpl$JBossWSServiceImpl.<init>(ProviderImpl.java:479)
at org.jboss.wsf.stack.cxf.client.ProviderImpl.createServiceDelegate(ProviderImpl.java:165)
at javax.xml.ws.Service.<init>(Service.java:57) [jboss-jaxws-api_2.2_spec-2.0.1.Final-redhat-2.jar:2.0.1.Final-redhat-2]
at org.jboss.jbossas.quickstarts.wshelloworld.helloworld.HelloWorldService_Service.<init>(HelloWorldService_Service.java:47) [classes:]
at org.jboss.as.quickstarts.mvc.MemberController.displaySortedMembers(MemberController.java:20) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_09]
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) [spring-webmvc-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
WSDL
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWorldService" targetNamespace="http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld" elementFormDefault="unqualified" targetNamespace="http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld" version="1.0">
<xs:element name="sayHello" type="tns:sayHello"/>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
<xs:element name="sayHelloToName" type="tns:sayHelloToName"/>
<xs:element name="sayHelloToNameResponse" type="tns:sayHelloToNameResponse"/>
<xs:element name="sayHelloToNames" type="tns:sayHelloToNames"/>
<xs:element name="sayHelloToNamesResponse" type="tns:sayHelloToNamesResponse"/>
<xs:complexType name="sayHello">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloToNames">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloToNamesResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloToName">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloToNameResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHelloToNameResponse">
<wsdl:part element="tns:sayHelloToNameResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHelloToNamesResponse">
<wsdl:part element="tns:sayHelloToNamesResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHelloToName">
<wsdl:part element="tns:sayHelloToName" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHelloToNames">
<wsdl:part element="tns:sayHelloToNames" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part element="tns:sayHelloResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloWorldService">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:sayHello" name="sayHello"></wsdl:input>
<wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayHelloToNames">
<wsdl:input message="tns:sayHelloToNames" name="sayHelloToNames"></wsdl:input>
<wsdl:output message="tns:sayHelloToNamesResponse" name="sayHelloToNamesResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayHelloToName">
<wsdl:input message="tns:sayHelloToName" name="sayHelloToName"></wsdl:input>
<wsdl:output message="tns:sayHelloToNameResponse" name="sayHelloToNameResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldServiceSoapBinding" type="tns:HelloWorldService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayHelloToNames">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHelloToNames">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloToNamesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayHelloToName">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHelloToName">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloToNameResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldService">
<wsdl:port binding="tns:HelloWorldServiceSoapBinding" name="HelloWorld">
<soap:address location="http://localhost:8080/helloworld-ws/HelloWorldService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
HelloWorldService.java
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the #authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.wshelloworld;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
* A simple example of how to setup a JAX-WS Web Service. It can say hello to everyone or to someone in particular.
*
* #author lnewson#redhat.com
*/
#WebService(targetNamespace = "http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld")
public interface HelloWorldService {
/**
* Say hello as a response
*
* #return A simple hello world message
*/
#WebMethod
public String sayHello();
/**
* Say hello to someone precisely
*
* #param name The name of the person to say hello to
* #return the number of current bookings
*/
#WebMethod
public String sayHelloToName(String name);
/**
* Say hello to a list of people
*
* #param names The list of names to say hello to
* #return the number of current bookings
*/
#WebMethod
public String sayHelloToNames(List<String> names);
}
HelloWorldServiceImpl.java
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the #authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.wshelloworld;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
/**
* The implementation of the HelloWorld JAX-WS Web Service.
*
* #author lnewson#redhat.com
*/
#WebService(serviceName = "HelloWorldService", portName = "HelloWorld", name = "HelloWorld", endpointInterface = "org.jboss.as.quickstarts.wshelloworld.HelloWorldService", targetNamespace = "http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld")
public class HelloWorldServiceImpl implements HelloWorldService {
#Override
public String sayHello() {
return "Hello World!";
}
#Override
public String sayHelloToName(final String name) {
/* Create a list with just the one value */
final List<String> names = new ArrayList<String>();
names.add(name);
return sayHelloToNames(names);
}
#Override
public String sayHelloToNames(final List<String> names) {
return "Hello " + createNameListString(names);
}
/**
* Creates a list of names separated by commas or an and symbol if its the last separation. This is then used to say hello to
* the list of names.
*
* i.e. if the input was {John, Mary, Luke} the output would be John, Mary & Luke
*
* #param names A list of names
* #return The list of names separated as described above.
*/
private String createNameListString(final List<String> names) {
/*
* If the list is null or empty then assume the call was anonymous.
*/
if (names == null || names.isEmpty()) {
return "Anonymous!";
}
final StringBuilder nameBuilder = new StringBuilder();
for (int i = 0; i < names.size(); i++) {
/*
* Add the separator if its not the first string or the last separator since that should be an and (&) symbol.
*/
if (i != 0 && i != names.size() - 1)
nameBuilder.append(", ");
else if (i != 0 && i == names.size() - 1)
nameBuilder.append(" & ");
nameBuilder.append(names.get(i));
}
nameBuilder.append("!");
return nameBuilder.toString();
}
}
ClientSample.java
package org.jboss.jbossas.quickstarts.wshelloworld.helloworld.clientsample;
import org.jboss.jbossas.quickstarts.wshelloworld.helloworld.*;
public class ClientSample {
public static void main(String[] args) {
System.out.println("***********************");
System.out.println("Create Web Service Client...");
HelloWorldService_Service service1 = new HelloWorldService_Service();
System.out.println("Create Web Service...");
HelloWorldService port1 = service1.getHelloWorld();
System.out.println("Call Web Service Operation...");
System.out.println("Server said: " + port1.sayHello());
System.out.println("Server said: " + port1.sayHelloToNames(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Server said: " + port1.sayHelloToName(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Create Web Service...");
HelloWorldService port2 = service1.getHelloWorld();
System.out.println("Call Web Service Operation...");
System.out.println("Server said: " + port2.sayHello());
System.out.println("Server said: " + port2.sayHelloToNames(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Server said: " + port2.sayHelloToName(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("***********************");
System.out.println("Call Over!");
}
}
MemberController.java
package org.jboss.as.quickstarts.mvc;
import org.jboss.jbossas.quickstarts.wshelloworld.helloworld.HelloWorldService;
import org.jboss.jbossas.quickstarts.wshelloworld.helloworld.HelloWorldService_Service;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
#RequestMapping(value = "/")
public class MemberController {
#RequestMapping(method=RequestMethod.GET)
public String displaySortedMembers(Model model) {
System.out.println("***********************");
System.out.println("Create Web Service Client...");
HelloWorldService_Service service1 = new HelloWorldService_Service();
System.out.println("Create Web Service...");
HelloWorldService port1 = service1.getHelloWorld();
System.out.println("Call Web Service Operation...");
System.out.println("Server said: " + port1.sayHello());
System.out.println("Server said: " + port1.sayHelloToNames(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Server said: " + port1.sayHelloToName(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Create Web Service...");
HelloWorldService port2 = service1.getHelloWorld();
System.out.println("Call Web Service Operation...");
System.out.println("Server said: " + port2.sayHello());
System.out.println("Server said: " + port2.sayHelloToNames(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("Server said: " + port2.sayHelloToName(null));
//Please input the parameters instead of 'null' for the upper method!
System.out.println("***********************");
System.out.println("Call Over!");
return "index";
}
}
Did you put all the necessary jar files in your client. Please check out first and then check out your cxf jar file version for comfortable. Make sure you have defined the correct wsdl name (e.g "http: //something:7101/TestWSA/WsaWebServiceTest?WSDL") in your client class. Note, Check out your jar files version first. I think, it will work. Thanks!
Related
I was testing transaction roll back feature using Spring Data MongoDB(2.2.5) and MongoDB 4.2.5 Community Version. As mentioned in Spring Data official documentation I have configured MongoTransactionManager in the configuration class, and have created a replica set with 3 members in the back end.
Also, have used repository for mongo db transactions. Have annotated my Dao method using #Transactional. Even I have implemented the transaction scope in the method, my data is still getting saved in the collections(Person as well Address) and no rollback happening at the Databse layer on a Run time exception in the application. I have provided the required source code and trace from my application. Kindly help to troubleshoot the true and pleas let me if i miss anything from my end.
#Slf4j
#Configuration
#EnableMongoRepositories
#EnableTransactionManagement(proxyTargetClass=true)
class ApplicationConfig extends AbstractMongoClientConfiguration {
#Bean
MongoTransactionManager transactionManager(MongoDbFactory dbFactory) {
log.info("Creating dbFactory {}", dbFactory);
MongoTransactionManager manager=new MongoTransactionManager(dbFactory);
log.info("Creating manager {}",manager);
return manager;
}
#Override
public MongoClient mongoClient() {
return MongoClients.create("mongodb://localhost:27020,localhost:27021,localhost:27022/?replicaSet=rs0");
}
#Override
protected String getDatabaseName() {
return "testDB";
}
public #Bean MongoTemplate mongoTemplate() {
return new MongoTemplate(mongoClient(), "testDB");
}
}
#Slf4j
#Service("TestDao")
public class TestDaoImpl implements TestDao{
#Autowired
PersonRepository repository;
#Autowired
MongoOperations ops;
#Autowired
AddressRepository addressRepo;
#Transactional
public void save(List<PersonVO> personList) {
//if(!p.getNationaliy().equalsIgnoreCase("AU"))
AddressVO addVo=new AddressVO();
addVo.setCity("COCHIN");
addVo.setCountry("IN");
addVo.setHouseNo("Rose Villa 123");
Address addr=AddressMapper.INSTANCE.ToAddress(addVo);
addressRepo.save(addr);
//ops.insert(addr);
log.info("Saving....");
for(PersonVO vo:personList) {
log.info("Saving person");
Person p=PersonMapper.INSTANCE.ToPerson(vo);
repository.save(p);
}
throw new RuntimeException();
}
}
Here's the log, the exception and the stack trace.
2020-04-01 01:21:24.106 INFO 7696 --- [nio-7092-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-04-01 01:21:24.106 INFO 7696 --- [nio-7092-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-04-01 01:21:24.127 INFO 7696 --- [nio-7092-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 21 ms
2020-04-01 01:21:24.189 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : Creating new transaction with name [com.example.mongo.demo.service.TestServiceImpl.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2020-04-01 01:21:24.227 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : About to start transaction for session [ClientSessionImpl#3e82b37d id = {"id": {"$binary": "zw5ZFyfdRPSSOgZ/pW/D3A==", "$type": "04"}}, causallyConsistent = true, txActive = false, txNumber = 0, error = d != java.lang.Boolean].
2020-04-01 01:21:24.228 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : Started transaction for session [ClientSessionImpl#3e82b37d id = {"id": {"$binary": "zw5ZFyfdRPSSOgZ/pW/D3A==", "$type": "04"}}, causallyConsistent = true, txActive = true, txNumber = 1, error = d != java.lang.Boolean].
2020-04-01 01:21:24.238 INFO 7696 --- [nio-7092-exec-2] c.e.mongo.demo.service.TestServiceImpl : Saving
2020-04-01 01:21:24.239 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : Participating in existing transaction
2020-04-01 01:21:24.285 DEBUG 7696 --- [nio-7092-exec-2] o.s.data.mongodb.core.MongoTemplate : Inserting Document containing fields: [houseNo, city, country, _class] in collection: address
2020-04-01 01:21:24.334 INFO 7696 --- [nio-7092-exec-2] org.mongodb.driver.connection : Opened connection [connectionId{localValue:7, serverValue:37}] to localhost:27021
2020-04-01 01:21:24.501 INFO 7696 --- [nio-7092-exec-2] com.example.mongo.demo.dao.TestDaoImpl : Saving....
2020-04-01 01:21:24.501 INFO 7696 --- [nio-7092-exec-2] com.example.mongo.demo.dao.TestDaoImpl : Saving person
2020-04-01 01:21:24.530 DEBUG 7696 --- [nio-7092-exec-2] o.s.data.mongodb.core.MongoTemplate : Inserting Document containing fields: [name, age, gender, nationaliy, _class] in collection: person
2020-04-01 01:21:24.532 INFO 7696 --- [nio-7092-exec-2] com.example.mongo.demo.dao.TestDaoImpl : Saving person
2020-04-01 01:21:24.533 DEBUG 7696 --- [nio-7092-exec-2] o.s.data.mongodb.core.MongoTemplate : Inserting Document containing fields: [name, age, gender, nationaliy, _class] in collection: person
2020-04-01 01:21:24.536 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : Participating transaction failed - marking existing transaction as rollback-only
2020-04-01 01:21:24.536 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : Initiating transaction rollback
2020-04-01 01:21:24.537 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : About to abort transaction for session [ClientSessionImpl#3e82b37d id = {"id": {"$binary": "zw5ZFyfdRPSSOgZ/pW/D3A==", "$type": "04"}}, causallyConsistent = true, txActive = true, txNumber = 1, error = d != java.lang.Boolean].
2020-04-01 01:21:24.538 DEBUG 7696 --- [nio-7092-exec-2] o.s.d.mongodb.MongoTransactionManager : About to release Session [ClientSessionImpl#3e82b37d id = {"id": {"$binary": "zw5ZFyfdRPSSOgZ/pW/D3A==", "$type": "04"}}, causallyConsistent = true, txActive = false, txNumber = 1, error = d != java.lang.Boolean] after transaction.
2020-04-01 01:21:24.554 ERROR 7696 --- [nio-7092-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException] with root cause
java.lang.RuntimeException: null
at com.example.mongo.demo.dao.TestDaoImpl.save(TestDaoImpl.java:57) ~[classes/:na]
at com.example.mongo.demo.dao.TestDaoImpl$$FastClassBySpringCGLIB$$8c1970a4.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.mongo.demo.dao.TestDaoImpl$$EnhancerBySpringCGLIB$$8ea2a8.save(<generated>) ~[classes/:na]
at com.example.mongo.demo.service.TestServiceImpl.save(TestServiceImpl.java:46) ~[classes/:na]
at com.example.mongo.demo.service.TestServiceImpl$$FastClassBySpringCGLIB$$949c2e6a.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.mongo.demo.service.TestServiceImpl$$EnhancerBySpringCGLIB$$7980a7ba.save(<generated>) ~[classes/:na]
at com.example.mongo.demo.controller.TestController.savePersons(TestController.java:33) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109) ~[spring-boot-actuator-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
I applied boundary timer event on user task, I added java class on service task class attribute but when a timer expired and triggered list of exceptions throws i.e class assigned to service task cannot found. although class exist on the class path. asyncExecutorActivate property is also enabled in activiti configuration
here is a code
BPMN
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
<process id="timertest" name="timertest" isExecutable="true">
<startEvent id="startEvent1"></startEvent>
<userTask id="sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA"></userTask>
<sequenceFlow id="sid-08270597-3D34-4CFD-BACF-CB95036CBC48" sourceRef="startEvent1" targetRef="sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA"></sequenceFlow>
<boundaryEvent id="sid-5AC91A08-17CC-4F6E-ABC2-2B8AF63EAB66" attachedToRef="sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA" cancelActivity="true">
<timerEventDefinition>
<timeDate>${expiresOn}</timeDate>
</timerEventDefinition>
</boundaryEvent>
<endEvent id="sid-1D6E7697-6ECA-42BA-98E5-BE089A78DCF2"></endEvent>
<sequenceFlow id="sid-A4C68C9C-38C3-43A9-BB3F-83FABACA65F9" sourceRef="sid-CE624FA0-9F7E-4FF9-BF3E-C016D046A3BF" targetRef="sid-1D6E7697-6ECA-42BA-98E5-BE089A78DCF2"></sequenceFlow>
<serviceTask id="sid-CE624FA0-9F7E-4FF9-BF3E-C016D046A3BF" activiti:class="com.softech.workflowengine.workflow.policyack.servicetask.TimerClass"></serviceTask>
<sequenceFlow id="sid-799456B9-F667-4E98-A856-E1AA7B79F680" sourceRef="sid-5AC91A08-17CC-4F6E-ABC2-2B8AF63EAB66" targetRef="sid-CE624FA0-9F7E-4FF9-BF3E-C016D046A3BF"></sequenceFlow>
<endEvent id="sid-705703CA-B642-435C-8393-B236EC3E964B"></endEvent>
<sequenceFlow id="sid-010B8977-34F9-40F4-B694-D56D5BA34257" sourceRef="sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA" targetRef="sid-705703CA-B642-435C-8393-B236EC3E964B"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_timertest">
<bpmndi:BPMNPlane bpmnElement="timertest" id="BPMNPlane_timertest">
<bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
<omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA" id="BPMNShape_sid-9F95F9B8-6C5C-4221-B3A7-3BD2BAEC22CA">
<omgdc:Bounds height="80.0" width="100.0" x="175.0" y="138.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-5AC91A08-17CC-4F6E-ABC2-2B8AF63EAB66" id="BPMNShape_sid-5AC91A08-17CC-4F6E-ABC2-2B8AF63EAB66">
<omgdc:Bounds height="31.0" width="31.0" x="253.59371010330312" y="202.75947444214634"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-1D6E7697-6ECA-42BA-98E5-BE089A78DCF2" id="BPMNShape_sid-1D6E7697-6ECA-42BA-98E5-BE089A78DCF2">
<omgdc:Bounds height="28.0" width="28.0" x="405.0" y="311.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-CE624FA0-9F7E-4FF9-BF3E-C016D046A3BF" id="BPMNShape_sid-CE624FA0-9F7E-4FF9-BF3E-C016D046A3BF">
<omgdc:Bounds height="80.0" width="100.0" x="210.0" y="285.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-705703CA-B642-435C-8393-B236EC3E964B" id="BPMNShape_sid-705703CA-B642-435C-8393-B236EC3E964B">
<omgdc:Bounds height="28.0" width="28.0" x="320.0" y="164.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-A4C68C9C-38C3-43A9-BB3F-83FABACA65F9" id="BPMNEdge_sid-A4C68C9C-38C3-43A9-BB3F-83FABACA65F9">
<omgdi:waypoint x="310.0" y="325.0"></omgdi:waypoint>
<omgdi:waypoint x="405.0" y="325.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-799456B9-F667-4E98-A856-E1AA7B79F680" id="BPMNEdge_sid-799456B9-F667-4E98-A856-E1AA7B79F680">
<omgdi:waypoint x="269.5937101033031" y="234.75947444214634"></omgdi:waypoint>
<omgdi:waypoint x="269.5937101033031" y="259.3797372210732"></omgdi:waypoint>
<omgdi:waypoint x="260.0" y="259.3797372210732"></omgdi:waypoint>
<omgdi:waypoint x="260.0" y="285.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-08270597-3D34-4CFD-BACF-CB95036CBC48" id="BPMNEdge_sid-08270597-3D34-4CFD-BACF-CB95036CBC48">
<omgdi:waypoint x="130.0" y="178.0"></omgdi:waypoint>
<omgdi:waypoint x="175.0" y="178.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-010B8977-34F9-40F4-B694-D56D5BA34257" id="BPMNEdge_sid-010B8977-34F9-40F4-B694-D56D5BA34257">
<omgdi:waypoint x="275.0" y="178.0"></omgdi:waypoint>
<omgdi:waypoint x="320.0" y="178.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Java Delegate
package com.softech.workflowengine.workflow.policyack.servicetask;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
public class TimerClass implements JavaDelegate{
#Override
public void execute(DelegateExecution execution) {
System.out.println(">> in TimerClass ");
}
}
Exception
07:56:03,977 [activiti-async-job-executor-thread-2] ERROR org.activiti.engine.impl.interceptor.CommandContext - Error while closing command context
org.activiti.engine.ActivitiException: couldn't instantiate class com.softech.workflowengine.workflow.policyack.servicetask.TimerClass
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:137)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.defaultInstantiateDelegate(ClassDelegate.java:306)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:295)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:273)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:217)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:180)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:131)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:89)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:55)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:73)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:57)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:42)
at org.activiti.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:48)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:63)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:29)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:44)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:39)
at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:97)
at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.activiti.engine.ActivitiClassLoadingException: Class not found: com.softech.workflowengine.workflow.policyack.servicetask.TimerClass
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:87)
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:134)
... 24 more
Caused by: java.lang.ClassNotFoundException: com.softech.workflowengine.workflow.policyack.servicetask.TimerClass
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:288)
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:68)
... 25 more
07:56:04,000 [activiti-async-job-executor-thread-2] ERROR org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable - Job 130011 failed
org.activiti.engine.ActivitiException: couldn't instantiate class com.softech.workflowengine.workflow.policyack.servicetask.TimerClass
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:137)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.defaultInstantiateDelegate(ClassDelegate.java:306)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:295)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:273)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:217)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:180)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:131)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:89)
at org.activiti.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:55)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:73)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:57)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:42)
at org.activiti.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:48)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:63)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:29)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:44)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:39)
at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:97)
at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Bean Initialization
#Bean
public SpringProcessEngineConfiguration processEngineConfiguration() throws Exception {
SpringProcessEngineConfiguration engineConfiguration = new SpringProcessEngineConfiguration();
engineConfiguration.setDataSource(dataSource);
engineConfiguration.setTransactionManager(transactionManager);
engineConfiguration.setDatabaseSchemaUpdate(Boolean.TRUE.toString());
engineConfiguration.setAsyncExecutorActivate(true);
return engineConfiguration;
}
Notice that the thread that requires the class in the classpath is activiti-async-job-executor-thread-2], which leads to the question where are you running the job executor? How are you making sure that the class is in the classpath?
The classes need to be executed after the timer expired must be on tomcat's classpath (in tomcat's lib folder). For more reference please see article
https://dzone.com/articles/tutorial-devoxx-activiti-bpmn
While running my API test via jenkins(linux machine), its generating Junit report xml with some invalid character in properties tags.
<property name="LESS_TERMCAP_us" value="[04;38;5;111m"/>
Due to which jenkins throws error for invalid xml.
How can I remove properties from the generated xml.
Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Sanity" tests="3" failures="3" errors="0" time="5.354">
<properties><property name="JOB_NAME" value="QA-API-Automation-Sanity"/>
<property name="java.vendor" value="Oracle Corporation"/><property name="PWD" value="/var/lib/jenkins"/><property name="sun.java.launcher" value="SUN_STANDARD"/><property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/><property name="PATH" value="/var/lib/jenkins/tools/chromedriver:/usr/local/bin:/bin:/usr/bin:/opt/aws/bin:/usr/lib/apache-maven-3.3.9/bin/"/><property name="JENKINS_HOME" value="/var/lib/jenkins"/><property name="AWS_SDK_LOAD_CONFIG" value="true"/><property name="HUDSON_SERVER_COOKIE" value="2567307d622fab24"/><property name="POM_ARTIFACTID" value="apitest"/><property name="os.name" value="Linux"/><property name="EXECUTOR_NUMBER" value="3"/><property name="sun.boot.class.path" value="/usr/java/jdk1.8.0_60/jre/lib/resources.jar:/usr/java/jdk1.8.0_60/jre/lib/rt.jar:/usr/java/jdk1.8.0_60/jre/lib/sunrsasign.jar:/usr/java/jdk1.8.0_60/jre/lib/jsse.jar:/usr/java/jdk1.8.0_60/jre/lib/jce.jar:/usr/java/jdk1.8.0_60/jre/lib/charsets.jar:/usr/java/jdk1.8.0_60/jre/lib/jfr.jar:/usr/java/jdk1.8.0_60/jre/classes"/><property name="POM_DISPLAYNAME" value="APITest"/><property name="java.vm.specification.vendor" value="Oracle Corporation"/><property name="ROOT_BUILD_CAUSE" value="MANUALTRIGGER"/><property name="NODE_LABELS" value="QA-Slave qa-slave"/><property name="java.runtime.version" value="1.8.0_60-b27"/><property name="user.name" value="jenkins"/><property name="SSH_CONNECTION" value="52.14.5.155 42186 10.0.0.142 22"/><property name="guice.disable.misplaced.annotation.check" value="true"/><property name="SSH_CLIENT" value="52.14.5.155 42186 22"/><property name="PYTHON_INSTALL_LAYOUT" value="amzn"/><property name="user.language" value="en"/><property name="RUN_CHANGES_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/display/redirect?page=changes"/><property name="JOB_BASE_NAME" value="QA-API-Automation-Sanity"/><property name="BUILD_DISPLAY_NAME" value="#22"/><property name="sun.boot.library.path" value="/usr/java/jdk1.8.0_60/jre/lib/amd64"/><property name="AWS_AUTO_SCALING_HOME" value="/opt/aws/apitools/as"/><property name="java.version" value="1.8.0_60"/><property name="user.timezone" value="Etc/UTC"/><property name="sun.arch.data.model" value="64"/><property name="NODE_NAME" value="QA-Slave"/><property name="NLSPATH" value="/usr/dt/lib/nls/msg/%L/%N.cat"/><property name="java.endorsed.dirs" value="/usr/java/jdk1.8.0_60/jre/lib/endorsed"/><property name="BUILD_ID" value="22"/><property name="sun.cpu.isalist" value=""/><property name="sun.jnu.encoding" value="UTF-8"/><property name="file.encoding.pkg" value="sun.io"/><property name="SHELL" value="/bin/bash"/><property name="file.separator" value="/"/><property name="java.specification.name" value="Java Platform API Specification"/>
<property name="LESS_TERMCAP_us" value="[04;38;5;111m"/>
<property name="java.class.version" value="52.0"/><property name="org.slf4j.simpleLogger.defaultLogLevel" value="info"/><property name="user.country" value="US"/><property name="securerandom.source" value="file:/dev/./urandom"/><property name="java.home" value="/usr/java/jdk1.8.0_60/jre"/><property name="java.vm.info" value="mixed mode"/><property name="LESSOPEN" value="||/usr/bin/lesspipe.sh %s"/><property name="os.version" value="4.4.41-36.55.amzn1.x86_64"/><property name="EC2_AMITOOL_HOME" value="/opt/aws/amitools/ec2"/><property name="RUN_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/display/redirect"/>
<property name="LESS_TERMCAP_ue" value="[0m"/><property name="POM_VERSION" value="1.0-SNAPSHOT"/><property name="sun.font.fontmanager" value="sun.awt.X11FontManager"/><property name="path.separator" value=":"/><property name="java.vm.version" value="25.60-b23"/><property name="GIT_PREVIOUS_COMMIT" value="c20674b0f57ce7beb1a881f19bdfeae2a5b602e7"/><property name="JOB_DISPLAY_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/display/redirect"/><property name="SHLVL" value="1"/><property name="_" value="/usr/bin/java"/><property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/><property name="JAVA_HOME" value="/usr/java/jdk1.8.0_60"/><property name="sun.io.unicode.encoding" value="UnicodeLittle"/><property name="awt.toolkit" value="sun.awt.X11.XToolkit"/><property name="LOGNAME" value="jenkins"/><property name="POM_PACKAGING" value="jar"/><property name="HOME" value="/home/jenkins"/><property name="POM_GROUPID" value="com.api"/><property name="user.home" value="/home/jenkins"/><property name="JENKINS_SERVER_COOKIE" value="2567307d622fab24"/><property name="BUILD_TAG" value="jenkins-QA-API-Automation-Sanity-22"/><property name="HUDSON_URL" value="https://jenkins.gl-poc.com/"/><property name="java.specification.vendor" value="Oracle Corporation"/><property name="CLASSPATH" value=""/><property name="java.library.path" value="/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib"/><property name="java.vendor.url" value="http://java.oracle.com/"/><property name="ROOT_BUILD_CAUSE_MANUALTRIGGER" value="true"/><property name="java.vm.vendor" value="Oracle Corporation"/><property name="maven.home" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/><property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/><property name="sun.java.command" value="jenkins.maven3.agent.Maven33Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9 /var/lib/jenkins/slave.jar /var/lib/jenkins/maven33-interceptor.jar /var/lib/jenkins/maven3-interceptor-commons.jar 44390"/><property name="java.class.path" value="/var/lib/jenkins/maven33-agent.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/boot/plexus-classworlds-2.5.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/conf/logging"/><property name="EC2_HOME" value="/opt/aws/apitools/ec2"/><property name="java.vm.specification.name" value="Java Virtual Machine Specification"/><property name="java.vm.specification.version" value="1.8"/><property name="MAIL" value="/var/mail/jenkins"/><property name="M2_HOME" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/>
<property name="LESS_TERMCAP_me" value="[0m"/><property name="sun.cpu.endian" value="little"/><property name="sun.os.patch.level" value="unknown"/>
<property name="LESS_TERMCAP_md" value="[01;38;5;208m"/>
<property name="LESS_TERMCAP_mb" value="[01;31m"/>
<property name="java.io.tmpdir" value="/tmp"/><property name="PATH+MAVEN" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9/bin"/><property name="HUDSON_HOME" value="/var/lib/jenkins"/>
<property name="LESS_TERMCAP_se" value="[0m"/><property name="OLDPWD" value="/home/jenkins"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="BUILD_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/22/"/>
<property name="os.arch" value="amd64"/><property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/><property name="java.ext.dirs" value="/usr/java/jdk1.8.0_60/jre/lib/ext:/usr/java/packages/lib/ext"/><property name="JOB_URL" value="https://jenkins.gl-poc.com/job/QA-API-Automation-Sanity/"/><property name="_JAVA_OPTIONS" value="-Xmx2048m"/><property name="user.dir" value="/var/lib/jenkins/workspace/QA-API-Automation-Sanity"/><property name="MAVEN_HOME" value="/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven3.3.9"/><property name="line.separator" value="
"/>
<property name="BUILD_NUMBER" value="22"/><property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/><property name="JENKINS_URL" value="https://jenkins.gl-poc.com/"/>
<property name="GIT_BRANCH" value="origin/develop"/><property name="PATH+CHROMEDRIVER" value="/var/lib/jenkins/tools/chromedriver"/><property name="BUILD_CAUSE_MANUALTRIGGER" value="true"/><property name="GIT_COMMIT" value="ad5e9221a4f489a8a60e60bed86061be514bccda"/><property name="LANG" value="en_US.UTF-8"/><property name="file.encoding" value="UTF-8"/><property name="maven3.interceptor" value="/var/lib/jenkins/maven33-interceptor.jar"/><property name="WORKSPACE" value="/var/lib/jenkins/workspace/QA-API-Automation-Sanity"/><property name="maven3.interceptor.common" value="/var/lib/jenkins/maven3-interceptor-commons.jar"/><property name="AWS_PATH" value="/opt/aws"/><property name="AWS_ELB_HOME" value="/opt/aws/apitools/elb"/><property name="AWS_CLOUDWATCH_HOME" value="/opt/aws/apitools/mon"/><property name="java.specification.version" value="1.8"/><property name="BUILD_CAUSE" value="MANUALTRIGGER"/><property name="USER" value="jenkins"/><property name="XFILESEARCHPATH" value="/usr/dt/app-defaults/%L/Dt"/><property name="GIT_URL" value="ssh://git#bitbucket.pearson.com/glpnfr/glp-api-automation-qa.git"/></properties>
<testcase name="Login" time="1.595">
<failure type="Failing due to failed test step" message="Failing due to failed test step">
<![CDATA[<h3><b>claimTokenIdTransfer Failed</b></h3><pre>Error performing transfer [claimTokenRetrieval] - Missing target property
</pre><hr/><h3><b>retrievalClaim Failed</b></h3><pre>[Valid HTTP Status Codes] Response status code:401 is not in acceptable list of status codes
</pre><hr/>]]>
</failure>
</testcase>
</testsuite>
Here you go, comments in-line:
Pass the xml as string to parseText method.
//Pass xml string
def pxml = new XmlSlurper().parseText(xml)
//Get the suites
def suites = pxml.'**'.findAll{ it.name() == 'testsuite' }
//Remove properties node
suites.each{ it.properties.replaceNode {} }
//This gives the new xml without properties element
def output = groovy.xml.XmlUtil.serialize(pxml)
//Below would unescape the xml
def map = ['<' : '<', '>' : '>', '"' : '"', ''':'\'', '&':'&']
map.collect {k,v -> output = output.replaceAll(k,v)}
println output
You can quickly try this online Demo
I am trying to use ATU Reports for my project. The suite has around 25 #Test methods. After the completion of execution, a null pointer exception is got.
Exception in thread "main" java.lang.IllegalStateException:
java.lang.NullPointe rException
at atu.testng.reports.listeners.ATUReportsListener.onFinish(Unknown Sour
ce)
at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:204)
at org.testng.SuiteRunner.run(SuiteRunner.java:264)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.TestNG.privateMain(TestNG.java:1355)
at org.testng.TestNG.main(TestNG.java:1324) Caused by: java.lang.NullPointerException
at atu.testng.reports.writers.CurrentRunPageWriter.getTestCaseHTMLPath(U
nknown Source)
at atu.testng.reports.writers.CurrentRunPageWriter.writeFailedData(Unkno
wn Source)
at atu.testng.reports.writers.CurrentRunPageWriter.content(Unknown Sourc
e)
at atu.testng.reports.listeners.ATUReportsListener.generateCurrentRunPag
e(Unknown Source)
... 10 more
Another observation is that the ATU report is generated successfully when the #Test methods is around 5. Could it be that a particular #Test method is causing this NullPointerException?
testng.xml file is as below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<groups>
<run>
<include name="A1" />
<include name="A2" />
<include name="B1" />
</run>
</groups>
<classes>
<class name="com.test.testcases.Class1"/>
<class name="com.test.testcases.Class2"/>
<class name="com.test.testcases.Class3"/>
</classes>
</test> <!-- Test -->
<listeners>
<listener class-name="atu.testng.reports.listeners.ATUReportsListener"></listener>
<listener class-name="atu.testng.reports.listeners.ConfigurationListener"></listener>
<listener class-name="atu.testng.reports.listeners.MethodListener"></listener>
</listeners>
</suite> <!-- Suite -->
Something is null in this code (decompiled from ATU 5.1.1):
public void onFinish(ISuite paramISuite)
{
try
{
this.iSuite = paramISuite;
String str1 = SettingsFile.get("passedList") + this.passedTests.size() + ';';
String str2 = SettingsFile.get("failedList") + this.failedTests.size() + ';';
String str3 = SettingsFile.get("skippedList") + this.skippedTests.size() + ';';
SettingsFile.set("passedList", str1);
SettingsFile.set("failedList", str2);
SettingsFile.set("skippedList", str3);
HTMLDesignFilesJSWriter.lineChartJS(str1, str2, str3, this.runCount);
HTMLDesignFilesJSWriter.barChartJS(str1, str2, str3, this.runCount);
HTMLDesignFilesJSWriter.pieChartJS(this.passedTests.size(), this.failedTests.size(), this.skippedTests.size(), this.runCount);
generateIndexPage();
paramISuite.setAttribute("endExecution", Long.valueOf(System.currentTimeMillis()));
long l = ((Long)paramISuite.getAttribute("startExecution")).longValue();
generateConsolidatedPage();
generateCurrentRunPage(l, System.currentTimeMillis());
startReportingForPassed(this.passedTests);
startReportingForFailed(this.failedTests);
startReportingForSkipped(this.skippedTests);
if (Directory.generateExcelReports) {
ExcelReports.generateExcelReport(Directory.RUNDir + Directory.SEP + "(" + Directory.REPORTSDIRName + ") " + Directory.RUNName + this.runCount + ".xlsx", this.passedTests, this.failedTests, this.skippedTests);
}
if (Directory.generateConfigReports) {
ConfigurationListener.startConfigurationMethodsReporting(this.runCount);
}
if (Directory.recordSuiteExecution) {
try
{
this.recorder.stop();
}
catch (Throwable localThrowable) {}
}
}
catch (Exception localException)
{
throw new IllegalStateException(localException);
}
}
I suspect the issue comes from long l = ((Long)paramISuite.getAttribute("startExecution")).longValue(); because TestNG has some issues with listeners.
What you should do is installing a java decompiler in your IDE (for example http://jd.benow.ca/). Then, in debug mode, you'll be able to find where exactly is the issue.
You should try the latest TestNG version (6.9.12) too which is supposed to fix the previous listener issues.
While debugging manually and running the classes individually I found out that one of the class was throwing a nullpointer exception as there was a mismatch in the number of parameters passed.
I have xml that looks like
<MeasureSet>
<MeasureSetType val_type="name">Variant</MeasureSetType>
<Measure>
<MeasureType val_type="name">single nucleotide variant</MeasureType>
<AttributeSet>
<MeasureAttributeType val_type="name">HGVS</MeasureAttributeType>
<Attribute>NM_000054.4:c.838dupT</Attribute>
</AttributeSet>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">10820168</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed" />
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">9773787</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed">18726898</ID>
</Citation>
<Citation>
<CitationType val_type="name">general</CitationType>
<ID Source="PubMed" />
</Citation>
</Measure>
</MeasureSet>
I want to delete the Citation element nodes that have Citation/ID/#Source = "PubMed" and Citation/ID is empty
This deletes only the ID element, but the correct ones
SET #myBlob.modify('delete //Citation/ID[#Source = ''PubMed''
and string-length(string(number(.))) = 0]')
and this deletes all Citation elements
SET #myBlob.modify('delete //Citation[ID/#Source = ''PubMed''
and string-length(string(number(.))) = 0]')
Seems there should be an easy solution I'm not hitting on. Any suggestions? Thanks
Your second one is checking the length of the wrong element - it's looking at (.), which is here the Citation element (because it's in a predicate on the Citation element). Use instead
SET #myBlob.modify('
delete //Citation[ID/#Source = ''PubMed''
and string-length(string(number(ID[1]))) = 0]')
where I have changed . to ID[1]. The [1] is needed because "'number()' requires a singleton (or empty sequence)".