7 Replies Latest reply on Aug 26, 2008 4:47 AM by aeternitas

    case: client and services on different servers

    aeternitas

      hello,

      I use JBossTS4.3 and JBossAS 4.2.3
      I have compiled JBossTS sample, and it works well... Next my step is to investigate how to make it working when I use different servers...
      What I did:
      in sample I changed localhost to 192.168.0.30 in configs for sample (files jboss.properties, BasicClient.java, web.xml and wsdls) and run two instances of JBossAS, one using localhost (just run), another one - for host 192.168.0.30 (run -b 192.168.0.30). xts-sa-demo.ear was deployed to both servers.
      Now, when I use the second JBoss (deployed demo is the same in both servers), it works.
      When I run "http://localhost:8080/xts-demo" and click "submit booking request" it should use web services deployed in the second JBossAS, but it does not... On console I see last line "CLIENT: starting the transaction...", my browser is waiting for respone, second JBoss does not write anything on the console...
      P.S. when I comment related to the transaction code in BasicClient (ut definition, ut.begin() and ut.commit() ) and do the same localhost used web services deployed to the 192.168.0.30, so it works

      What is wrong? Is it possible to use XTS when my application uses web services from another server?

      Thank for help, in advance :)
      Maxym

        • 1. Re: case: client and services on different servers
          adinn

           


          What is wrong? Is it possible to use XTS when my application uses web services from another server?


          Yes it is possible to use XTS when your application uses web services from another server -- it would not be much good if it could not do this as that is the whole point of having XTS.

          Your problem is that you need to set up two JBoss AS servers correctly. In particular, if you start a server with address localhost it will not talk via the network so you will not be able to be reach it from the one started using a proper network bind address (192.168.0.30). The easiest way is to start the JBoss AS instances on different machines. If you only have one machine then look at the JBoss Wiki to see how to start two servers both with the same bind address.

          http://wiki.jboss.org/wiki/ConfiguringMultipleJBossInstancesOnOneMachine

          In particular you will see that this requires you to use two different sets of ports. So, one of your servers will run a web service at 192.168.0.30:8080 and the other will be running a web service at 192.168.0.30:9090 (or maybe some other numbers for the ports). This means you will need to configure one of your demo apps to use host 192.168.0.30 and port 8080 and the other one to use host 192.168.0.30 and port 9090 (make sure you get this the right way round when you deploy them :-)

          Finally, there is one more thing you need to do. If you run the demo on the machine using port 8080 it will try to talk to the demo web services running on that machine. This is because the demo buld script substitutes the value of hostname defined in jboss.properties into the URLs used by the BasicClient code as well as into the configuration files used by the XTS services. So, if you want the client on the 8080 server to talk to the web apps on the 9090 server you need to modify the jboss properties file used to build the 8080 demo so that the RestaurantATURL, etc specify port 9090. You still need to leave localhost defined as 8080 but you must change the servcie URLs. If you just change one URL (e.g. TaxiATURL) then the demo will only use one remote service.

          Once you have got that to work there is a more interesting thing you can try. Your client and services normally talk to the XTS services running on the local JBoss server. If you use the setup I just described the client and XTS services will be on your 8080 machine and the web services (RestaurantAT/BA etc) will run on the 9090 machine. Edit file config.xml in xts-install/conf/wstx.xml and insert the following lines



          then rebuild the demo for your 8080 service. The client and servers should now talk to the XTS services on the 9090 machine.

          You can even go further than this. You can switch back to running the srervices on the 8080 machine but still leave the coordnatorURL setting in wstx.xml. Your client and services will run on the 8080 machine but the XTS coordination will be done remotely. This is called using a stand-alone coordinator.

          • 2. Re: case: client and services on different servers
            aeternitas

            a lot of thanks for helping :)
            my mistake was smaller than what you described, but your post helped to find it. Today I started everything from the beginning - JBossTS installation, demo configuration. I wrote 192.168.0.30 as host in the following files:
            BasicClient.java
            jboss.properties (only for lines after "<!-- JBoss services -->")
            wsdl's
            client-web-app.xml

            but in the line localhost I've leaved localhost.

            After build I run my servers as I described ("run" for first one, and "run -b 192.168.0.30" for the second). After that I pushed "submit" on localhost-server and my second JBoss started writing something on the console and opened AWT-windows. But it still didn't work :) Then I did the same with network servers - the situation was the same, but I got an exception on the server with web-services ("connection refused"). Remember this point please :)

            Next my step was the following - I thought about your words about coordinator

            Your client and services normally talk to the XTS services running on the local JBoss server

            (maybe words I thought about were another... but quoted are ok too :) )
            And I understood, that this localhost is related to the coordinator (at least it seems so; unfortunately this is not written in property file), and my second JBoss can't connect to it (it uses 192.168.0.30 host insteed of localhost). Then I've created two builds, first one with localhost abd it was used under localhost-server, second one with 192.168.0.30 for another server... and it works :) !!!
            I tried it also for network, works fine!

            Now agine about exception I got... I'm wondering why I got an exception about connection (connection refused, so as I understood it was connection to the coordinator) but... my localhost server wrote "Transaction finished OK.". I didn't try to make the same with DB (then I will see for sure if anything (but not everything) was commited), but it looks strange...
            Maybe there is explanation why it is so?

            thanks again!


            • 3. Re: case: client and services on different servers
              adinn

              When you are given help it is very important to say thank you, which you did. So you are welcome. It is just as important to read what you are told, think about it and check that you have followed all the advice you were given before asking for more help:


              you need to set up two JBoss AS servers correctly. In particular, if you start a server with address localhost it will not talk via the network so you will not be able to be reach it from the one started using a proper network bind address


              localhost is an alias for the loopback network i.e. the localhost server listens and talks via a fake network device. If it listens on a socket using this fake device then another process trying to talk to it must also use the fake device.

              192.168.0.30 is the address of a real network device. This is why the server started with -b 192.168.0.30 is able to talk to other machines .It is also able to talk to processes on the same machine which have opened sockets using the real network device. So, it can talk to itself as well as other machines. It iwll not try to open sockets using the fake network device even if you give it the address localhost.

              So, you have a problem here whichever server tries to open a connection.

              localhost is not a proper network address so the 192.168.0.30 server cannot use it to open a connection to the localhost server.

              The localhost server is not talking to a real network connection so it cannot open a connection to the 192.168.0.30 server.

              Both your servers need to bind to the network address i.e. you need to start them using run -b 192.168.0.30. This means they have to listen on different ports otherwise they will interfere with each other (only one process can listen on a port for a network device). Follow the link I posted earlier for instructions on how to start both servers and change the ports they use. When you have understood this and got it to work then read the rest of my post and see if you can follow the remaining instructions. If you are really stuck then come back and I may be willing to explain it in more detail.



              • 4. Re: case: client and services on different servers
                aeternitas

                sorry, adinn. Misunderstanding...
                when I said that I've tried it for networks servers, I meant that I had used two PC in one network, so should I reconfigure one of theirs JBoss servers (I mean ports), if they are located on different PC.
                All stuff I did I tried for both cases - two servers on my PC (I understood that it was not good idea to make it in the way I did), but also for two PC.
                And the problem is not, that some of servers can't open connection. The problem is that server with web services can't open connection and we get exception which means that transaction can't be completed, but another server says that transaction is finished ok - this is strange for me.
                If it is ok (so this behaviour is normal), so good, we just need to take into account that sometimes our transactions will be broken (e.g. because of wrong configuration) and we should test this cases befor real deploying - tha't all I wanted to say.
                About "two instances" - thanks for link, for sure I will configure servers this way (right way), but now it is easier for me to use two PC

                • 5. Re: case: client and services on different servers
                  aeternitas

                  btw.
                  in your first reply you wrote "insert the following lines", but I don't see which lines to insert because next string after "... following lines" is "then rebuild the demo"...

                  • 6. Re: case: client and services on different servers
                    adinn

                     


                    sorry, adinn. Misunderstanding...
                    when I said that I've tried it for networks servers, I meant that I had used two PC in one network, so should I reconfigure one of theirs JBoss servers (I mean ports), if they are located on different PC.


                    Ok, thank you for the clarification and apologies on my part for not understanding you. And yes, if you have two servers on separate PCs then you do not need to reconfigure the ports. What you need to do is start each of them with a bind address. You also need to build the XTS code to use the same bind address.

                    So, on machine 1 with network address 192.168.0.30

                    in jboss.properties

                    substitute JBOSS_HOSTNAME with 192.168.0.30

                    substitue JBOSS_PORT with 8080 and JBOSS_URLSTUB with xtsdemowebservices

                    build and install the demo on machine 1

                    start the server using run -b 192.168.0.30

                    on machine 2 with network address 192.168.0.40 (or whatever you use)

                    in jboss.properties

                    substitute the first occurence of JBOSS_HOSTNAME between the hostname tags with 192.168.0.40. substitute the rest of the occurences of JBOSS_HOSTNAME with 192.168.2.30

                    substitue JBOSS_PORT with 8080 and JBOSS_URLSTUB with xtsdemowebservices

                    build clean and rebuild the demo and install on machine 2

                    start the server using run -b 192.168.0.40

                    Now when you run the demo on machine 1 it will talk to the services on machine 1. Hoowever, when you run the demo on machine 2 it will use the address of machine 1 when it invokes the services.


                    All stuff I did I tried for both cases - two servers on my PC (I understood that it was not good idea to make it in the way I did), but also for two PC.
                    And the problem is not, that some of servers can't open connection. The problem is that server with web services can't open connection and we get exception which means that transaction can't be completed, but another server says that transaction is finished ok - this is strange for me.


                    This is strange for me too. The demo shoudl only say the transaction has completed if it gets no errors. As for the error, you said you were using localhost for one of the addresses. You must use a proper network address for both machines.


                    About "two instances" - thanks for link, for sure I will configure servers this way (right way), but now it is easier for me to use two PC


                    Ok, if you follow the steps I gave above then you should be able to get machine 2 to use the services on machine 1. Let me know if it works this time.


                    in your first reply you wrote "insert the following lines", but I don't see which lines to insert because next string after "... following lines" is "then rebuild the demo"...


                    Sorry, I posted some xml which the forum then decided to eat without printing it. I was suggesting that you add a property in file wstx.xml with name

                    com.arjuna.mw.wst.coordinatorURL

                    and value

                    http://hostname:port/ws-c/soap/ActivationCoordinator

                    where hostname is the address of the machine running the coordinator service and port is the web port used by the service.

                    Actually, there is an easier way to do what I was suggesting. When you start JBoss on machine 2 add an argument like this

                    run -b 192.168.0.40 -Dcom.arjuna.mw.wst.coordinatorURL=http://192.168.0.30:8080/ws-c/soap/ActivationCoordinator

                    This will make the client on machine 2 talk to the coordinator on machine 1. If the clientinvokes a web service on machine 1 the web service will also talk to the coordinator on machine 1. Without this command line argument then the client and web services would talk to the coordinator on machine 2.

                    So, you see, there are three different agents in this setup i) the client ii) the web services and iii) the coordination service provided by XTS. Obviously, if you specify a different host for the web service URL then the client and web service(s) can run on different machines. The coordinatorURL property allows you to pick which machine the coordinator runs on. It does not have to point to the client machine or the web service's machine. If you had a third PC to play with you could start a JBoss server on that machine and then get the client and web service use the XTS coordinator service on the third machine.


                    • 7. Re: case: client and services on different servers
                      aeternitas

                      Hi adinn,
                      after little pause I'm coming back.
                      So, at first - do not apology, it's from my part; English is not native for me, so sometimes it is difficult to understand what is written by me :) So that's ok.

                      about transactions - they work, I even wrote my own little sample (to show how to use XTS in our project). That's good :)

                      about exception I got - again it was my mistake, cause even using two PC's I run one server as localhost and another with it's ip. When I start both servers as I should do it - it works (so when some part can't find coordinator my transaction is not commited).

                      Seems there are no problem for now, thanks again for helping!
                      Maxym