Exception coming: java.util.ServiceConfigurationError

前端 未结 2 1979
旧时难觅i
旧时难觅i 2021-01-07 04:16

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          


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-07 04:55

    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 provided to the JAX-WS dependencies. Something like:

    
        com.sun.xml.ws
        jaxws-rt
        2.2
        provided
    
    
        com.sun.istack
        istack-commons-runtime
        2.2
        provided
    
    

    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.(ServiceDelegateImpl.java:138)
    at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
    at javax.xml.ws.Service.(Service.java:79)
    at org.ortelius.UssdServiceImplementation.(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.

提交回复
热议问题