Exception coming: java.util.ServiceConfigurationError

时光总嘲笑我的痴心妄想 提交于 2019-11-30 19:31:31

问题


Getting below exception while running my application :

I am using jboss : 5.1.1 and jdk 1.6.

01:50:04,828 ERROR [[HelloWorld]] Servlet.service() for servlet HelloWorld threw exception
java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.jboss.ws.core.jaxws.spi.ProviderImpl not a subtype
    at java.util.ServiceLoader.fail(Unknown Source)
    at java.util.ServiceLoader.access$300(Unknown Source)
    at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
    at java.util.ServiceLoader$1.next(Unknown Source)
    at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:146)
    at javax.xml.ws.spi.Provider.provider(Provider.java:106)
    at javax.xml.ws.Service.<init>(Service.java:57)
    at com.service_instance.ServiceInstance.<init>(ServiceInstance.java:50)
    at com.getBusinessApp(CMDB.java:239)
    at com.test.HelloWorld.doGet(HelloWorld.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)

Let m know. How to resolve this. It seems like some lib issue.


回答1:


I had the same problem deploying a USSD gateway with Mobicents Jain Slee, that runs on top of a JBoss AS 5.1.0 GA. The gateway has to connect to a server via SOAP, so I chose JAX-WS and generated the source code from a WSDL with wsimport. By the way, I used a similar procedure to this one to create a child Maven project and generate the java files for JAX-WS.


Failed deploy with dependencies embedded on .war file

My first approach was to include all the dependencies in the .war file that is deployed in JBoss. I think this is achieved by default in Maven, and mvn install will do it. In the long run, this approach failed, but at least I needed to know the list of jar files that were included in the .war file, to copy them later in a JBoss directory.

I made a lot of troubleshooting with this approach, and had many different log errors, though the main one was this:

java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.jboss.ws.core.jaxws.spi.ProviderImpl not a subtype

Deploy without dependencies

Maven tweak

So insted, I added <scope>provided</scope> to the JAX-WS dependencies. Something like:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>com.sun.istack</groupId>
    <artifactId>istack-commons-runtime</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
</dependency>

This produced a much lighter .war file.

Copy & remove jars in JBoss AS

Now, after deploying the .war file, when my SOAP client tried to connect to the Web Service, and it throwed the exception:

org.jboss.ws.metadata.wsdl.WSDLException: Invalid default namespace: null
at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:134)
at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:293)
at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:84)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:138)
at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
at javax.xml.ws.Service.<init>(Service.java:79)
at org.ortelius.UssdServiceImplementation.<init>(UssdServiceImplementation.java:42)
at org.ortelius.OrteliusClient.sendUssdRequestToWs(OrteliusClient.java:28)

It seems that javax.xml.ws.Service calls org.jboss.ws.core.jaxws.spi.ProviderImpl, but it should be calling com.sun.xml.ws.spi.ProviderImpl, so it seems there is a conflict with jar dependencies.

To avoid this problem, it was necessary to:

  1. Move or delete all JBoss jar files found in $JBOSS_HOME/lib/endorsed/ directory.
  2. Copy the jars bundled in my initial .war file (the one of the failed deploy) to $JBOSS_HOME/lib/endorsed/ directory. all the jars bundled in my .war file.

That basically made it.


Final notes

I have to confess that to find this out was a real pain, and it took me about four days to get this up & running. I made a lot of troubleshooting with the jar dependencies, checking JBoss logs, remote debugging, comparing Java packages & classes versions, searching for jars online and reading many articles from JBoss manuals, blogs, StackOverflow, JavaRanch, etc...

The SOAP client was really simple, but the deployment in JBoss was pretty problematic. My solution is not very orthodox, since it depends greatly on the jar files dependencies. So I'm not sure if it will work for everyone.

Regards.



来源:https://stackoverflow.com/questions/24624719/exception-coming-java-util-serviceconfigurationerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!