3 Replies Latest reply on May 13, 2013 5:17 PM by jewellgm

    Determining web service ports at runtime




      A few weeks ago, I posted a question in the AS 7.1.1 forum about dynamically determine web server ports at runtime.  We had code deployed in AS 6.1 that used SPI to get this information.  The code still compiles using 7.1.1, but the call always throws an exception.  That discussion is here:




      Basically, making this call:


      int port = SPIProviderResolver.getInstance().getProvider().getSPI(ServerConfigFactory.class).getServerConfig().getWebServicePort();


      causes this:


      org.jboss.wsf.spi.WSFException: Failed to provide SPI:class org.jboss.wsf.spi.management.ServerConfigFactory

          at org.jboss.ws.common.spi.DefaultSPIProvider.getSPI(DefaultSPIProvider.java:102) [jbossws-common-2.0.2.GA.jar:2.0.2.GA]

          at org.jboss.wsf.spi.SPIProvider.getSPI(SPIProvider.java:41) [jbossws-spi-2.0.3.GA.jar:2.0.3.GA]


      I have added the following dependencies to the manifest of the jar containing this code:

      org.jboss.ws.common, org.jboss.ws.spi, org.jboss.as.webservices, org.jboss.msc, org.jboss.as.server


      Does anybody know whether this works in EAP 6.1?  My company is very strict about downloading software, and the procedure to getting something approved is intensive.  If somebody can tell me whether this works in EAP 6.1, I can start the process to get this approved.  Or, if there is a better way to do this, I would appreciate that as well.




      Greg Jewell

        • 1. Re: Determining web service ports at runtime

          Hi there,


          This looks like your compiling against an old JBossWS jar, and including it in your deployment.


          These classes are available in package org.jboss.wsf.spi in the JBossAS7/EAP6.1 module "org.jboss.ws.spi".


          You should try compiling against this and then importing the module as described in AS72 Class Loading in AS7.

          1 of 1 people found this helpful
          • 2. Re: Determining web service ports at runtime



            Thank you for the reply.  I don't see anywhere that I'm including older JBossWS components in the compilation or deployment.  I do have a few jars in the ear lib folder that jboss also provides, but only to remove the necessity to add dependencies to the manifest.  These modules are "private", and display warnings if I add them as dependencies.  I have listed them below:


            wss4j-1.6.5.jar (module org.apache.ws.security)

            commons-codec-1.3.jar (jboss provides 1.4 in module org.apache.commons.codec)


            For the sake of completeness, I also add a newer version of commons-lang (3.1) than jboss provides.  These classes are in different packages than jboss provides, though, so I don't think they should cause any problems.


            To be thorough, though, I removed the wss4j and commons-codec jars, and added them as dependencies in the manifest of the ear (exporting each module).  My dependencies now look like this:


            org.jboss.ws.common export, org.jboss.ws.spi export, org.jboss.as.webservices export, org.jboss.msc export, org.jboss.as.server export, org.apache.commons.codec export, org.apache.ws.security export


            I included ws.common because not including it causes a NoClassDefFoundException.  I included as.webservices because the ws.spi only apparently has interfaces while as.webservices has implementations.  The msc and as.server are in there only because the the implementation classes in as.webservices import classes from those modules.  Regardless, I still get the same exception I listed above.  Out of desparation, I also added the "services" parameter to each of the dependencies, but nothing changed.

            • 3. Re: Determining web service ports at runtime

              I finally got it.  The magic dependency list is as follow:


              org.jboss.as.webservices export services, org.jboss.ws.common export, org.jboss.ws.spi export



              Thanks for the help!