0 Replies Latest reply on Aug 14, 2009 12:41 PM by Radoslaw Chmielarz

    Deploying a webservice with isolated namespace

    Radoslaw Chmielarz Newbie

      Hello everyone,

      What I need to get done:
      - deploy several webservices on one jboss server
      - all of them have to provide a wsdl description file
      - every one of them is using one class pt.iscte.fenix.util.PropertiesManager for getting configuration information from build.properties in the runtime

      Problem description (short):
      Every webservice uses the same instance of PropertiesManager (the one that was first loaded in the memory) which points to the wrong build.properties file (and every webservice has it's own build.properties files with different keys)

      What I want to achieve:
      I want to isolate webservices so that each of them is in their own sandbox.

      Problem description(longer):
      When I deploy one webservice packed as jar into jboss/server/deploy everything works as expected - the properties from build.properties are read properly. But when I deploy another webservice instead of using properties from its own build.properties it uses the ones that were used by the first webservice. So it obviously means that it has to use the PropertiesManager instance created by the first service.

      A temporary solution would be to use different class names for PropertiesManager for every webservice (I've tried, it works), but that doesn't solve the main problem, which is namespace conflict. So I would like to put every jar into their own sanbox, so that I'm assured it only uses its own classes.

      I've came across solution to put the jar file into ear and provide ear with META-INF/jboss-app.xml:

      <jboss-app>
       <loader-repository>
       test1.agent:archive=testagent1.jar
       </loader-repository>
      </jboss-app>

      But since I'm counting on jbossws and annotations to create my wsdl, when I use a jar inside a ear jboss ejbdeployer doesn't generate a wsdl file for me.

      I'm using jboss-4.2.3. Every webservice is zipped into jar and compose of at least 3 source files:

      ##Test1Agent.java:
      package agent1.test;
      
      import javax.jws.WebService;
      
      @WebService
      public interface TestAgent1 {
       public String executeTest();
      }


      ##Test1AgentBean.java:
      package agent1.test;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import agent1.PropertiesManager;
      
      @WebService(name="testagent1", endpointInterface="agent1.test.TestAgent1")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      @Remote(TestAgent1.class)
      @Stateless
      public class TestAgent1Bean implements TestAgent1 {
       public String executeTest()
       {
       String text = PropertiesManager.getProperty("test.sign");
       return text;
       }
      }


      ##PropertiesManager.java:
      package agent1;
      
      import java.io.IOException;
      import java.util.Properties;
      
      /**
       * @author Luis Cruz
       *
       */
      public class PropertiesManager extends pt.utl.ist.fenix.tools.util.PropertiesManager {
      
       private static final Properties properties = new Properties();
      
       static {
       try {
       loadProperties(properties, "/configuration.properties");
       loadProperties(properties, "/build.properties");
       loadProperties(properties, "/dictionary.properties");
       } catch (IOException e) {
       throw new RuntimeException("Unable to load properties files.", e);
       }
       }
      
       public static String getProperty(final String key) {
       return properties.getProperty(key);
       }
      
       public static boolean getBooleanProperty(final String key) {
       return Boolean.parseBoolean(properties.getProperty(key));
       }
      
       public static Integer getIntegerProperty(final String key) {
       return Integer.valueOf(properties.getProperty(key));
       }
      
       public static void setProperty(final String key, final String value) {
       properties.setProperty(key, value);
       }
      
       public static boolean containsKey(final String key) {
       return properties.containsKey(key);
       }
      }


      If I made anything unclear feel free to point it out. Thanks in advance.