4 Replies Latest reply on Jun 5, 2014 7:54 AM by Keith Babo

    System property not written from Service Bean

    ovidiu.firicel Newbie



      I'm using Fuse Service Works 6.0.0GA.

      I have implemented a Switchyard Service Bean in which I'm trying to write a System Property with a value and then read it later. But the property is not written and when trying to read it I get the old value.

      The system property is preconfigured in the standalone.xml like this:

      <property name="SO_ROUTE_ENDPOINT" value="http://localhost:8080/"/>

      And I'm trying to overwrite it from Service Bean with the command:

       System.setProperty("SO_ROUTE_ENDPOINT", endpoint);

      And read it later using the System.getProperty... but the old value is returned instead of the new value.


      But there is a catch, if I redeploy the application in the running server, then the above will work. The error appears only when I start the server fresh and the application gets deployed during startup.


      Is there something I'm doing wrong?


      Thanks in advance,



        • 1. Re: System property not written from Service Bean
          David Ward Master

          Sounds like some sort of lifecycle/ordering issue. Can you share your code of where you're writing it and where you're reading it?

          • 2. Re: Re: System property not written from Service Bean
            ovidiu.firicel Newbie

            Hello David,


            I'm attaching a sample ServiceBean which function similar to my application (I will try the next day to come back with a full functional application)...

            In the method setEndpoint() I'm deciding based on a System property which system to invoke and I set another System property with the final endpoint

            System.setProperty("SO_ROUTE_ENDPOINT", endpoint);

            And this System property is used in Switchyard SOAP Reference (invoked from the ServiceBean with sampleRemote.process(request); ). The reference is using this property as an endpoint for the WebService which is invoked:


            And at this point the property is not read correctly when the server is just started (while a redeploy of the application will make it work).

            Also I have observed something else, the System property is actually set correctly by the method setEndpoint() (I used a logging to check its value after setting), but apparently the SOAP Reference is reading the initial value . And even if I set manually the System property using JBoss CLI, the value is not read correctly.

            After the application is redeployed, the endpoint is set/read correctly by Switchyard and is set correctly even if I change the system to which will send the request.


            As a workaround, I can create two distinct SOAP References (one for each endpoint) and in the Service Bean to call one or the other, but I would have prefered to use only one and change the endpoint only when needed.



            • 3. Re: Re: System property not written from Service Bean
              Keith Babo Master

              Property tokens in switchyard.xml are replaced once at application deployment-time; they are not dynamic.  The best way to support this would likely be a context property which allows you to set the SOAP endpoint address on a per-invocation basis.  Using a System property can be dangerous if you have concurrent invocations (multiple threads overwriting the property value during invocation).

              • 4. Re: Re: System property not written from Service Bean
                Keith Babo Master

                I should mention that we don't currently support dynamic assignment of the SOAP address via context property, but there is a JIRA you can vote for here:

                [SWITCHYARD-1997] Dynamic "per message" endpoint - JBoss Issue Tracker