1 Reply Latest reply on Aug 8, 2007 6:11 AM by Gary Ratcliffe

    Starting Thread on Deploy

    Mark Cloutier Newbie

      Hello -

      I am currently working on a portlet in a web app that contains a java applet in the client's browser that communicates over a Socket with a ServerSocket in a Thread running on the jboss server .

      What I am trying to figure out is how to start up this java program on the server when the deployment of the WAR file occurs. How would I go about this? I am thinking I need to add something to the **-object.xml or the web.xml. The java file I want to invoke is in the org.jboss.server.applet package and is called AppletServer.java.

      I am kind of a newbie with all of this, so any help is very much appreciated.

        • 1. Re: Starting Thread on Deploy
          Gary Ratcliffe Newbie

          Hi,

          A solution to this kind of problem, but not involving applets, that we've used is to implement the server as an MBean service. This allows it to be deployed as a .sar archive within the JBoss server. This is getting JBoss specific but I guess from your package names this is not really an issue. If you look in the JBoss user guide at
          http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch2.chapter.html#ch2.writembean.sect
          It explains how to write an MBean service. You would implement the startService method to start your server. You can also provide configuration attributes to your server this way. For example the port number.

          To ensure the service is started before the war is deployed I think you can add a jboss-web.xml file into the war WEB-INF folder that contains the name of the mbean in a element. It may not be needed because in JBoss 4 I don't think the Tomcat connectors pass on any requests to a servlet until everything as started.

          Gary