3 Replies Latest reply on Jul 12, 2007 8:23 AM by Patrick Madden

    Seam 2.0 Beta + JBossas 4.2.1.GA + JBossWS-2.0.0.GA + WebSta

    Patrick Madden Newbie

      This is just a quick note to say that I'm successfully runing Seam 2.0 Beta with the JBoss 4.2.1.GA from SVN and JBossWS-2.0.0.GA also from SVN.

      I was having real problems running web services on client side java applications and Java Web Start applications connecting to my Seam Web Application. (we have multiple views into the data)

      I mainly followed the instructions found here:

      http://jbws.dyndns.org/mediawiki/index.php?title=Building_From_Source


      On July 7, I downloaded the Branch_4_2 of the JBoss Application server and built it with JDK 1.5_12 (it fails to build on JDK 1.6). I then checked out the JBossWS 2.0 and built it with jdk1.6u2.

      When building jbossws you cd into the build directory and set two properties in ant.properties. Mine are as follows:


      jboss42.home=c:/apps/jboss/jboss-4.2.1.GA
      jbossws.integration.target=jboss42


      Inside the build directory there is also a build.conf file where you can tell it to use JDK 6

      ##
      ## Build configuration
      ##

      # Uncomment when using JDK 6
      USE_JDK6=true


      Then you use the build.bat file to build everything. Once its built you CD into the jbossws-core directory and type:

      ant deploy-jboss42


      This deploys everything to the JBoss-4.2.1 directory and most importantly adds important jar files to the JBoss-4.2.1\lib\endorsed directory

      To get everything working on the client side you also need the endorsed jar files to be properly set using the system property -Djava.endorsed.dirs

      For me and my Java Web Start Applications I created a jar file called endorsed.jars (jar'd all files in jboss endorsed directory) and download and unzip this jar file during runtime into the java.home/lib/endorsed directory if they don't exist already. If the don't exists already I notify the user that I did some first time client side setup and then shutdown my application and automatically relaunch it using the java.lang.ProcessBuilder class. This is because the endorsed jar files must be there before your JRE starts up. If they do exist my app just continues normally and I can call all my web services on the backend.

      Not all code is shown but its goes something like this:

       // Setup the Endorsed Directories
      
       String currentEndorsedDirs = System.getProperty("java.endorsed.dirs");
       File endorsedJRELibDir = new File(currentEndorsedDirs);
       boolean unzipEndorsedJars;
      
       if (!endorsedJRELibDir.exists())
       {
       endorsedJRELibDir.mkdirs();
       unzipEndorsedJars = true;
       }
       else
       {
       // check to see if it has the proper jar files in it
       unzipEndorsedJars = true;
       File[] files = endorsedJRELibDir.listFiles();
      
       if (files != null)
       {
       for (File file : files)
       {
       if (file.getName().equals("jboss-jaxws.jar"))
       {
       // ok we are fine
       unzipEndorsedJars = false;
       break;
       }
       }
       }
      
       }
      
       if (unzipEndorsedJars)
       {
       URL endorsedJarURL = new URL(System.getProperty("ContextRoot") + "desktop/lib/endorsed.jar");
       JarInputStream jarIn = new JarInputStream(endorsedJarURL.openStream());
      
       // unzip the file into jre's lib/endorsed directory - unzip closes the input stream.
       ZipUtils.unzip(endorsedJRELibDir, jarIn);
       }
      
       boolean addSubDirs = false;
       ClassPathModifier.addFiles(endorsedJRELibDir, addSubDirs);
      
       if (unzipEndorsedJars)
       {
       JOptionPane.showMessageDialog(null,
       "We have detected that this is the first time you\n" +
       "have run the Clooster Desktop application with the\n"+
       "current Java Runtime environment.\n\n" +
       "As such, we have performed some initial client side\n"+
       "setup and the application needs to restart.",
       "Clooster, Inc",
       JOptionPane.PLAIN_MESSAGE);
      
      
       ProcessBuilder pb = new ProcessBuilder("javaws",
       System.getProperty("ContextRoot") + "cloosterDesktop.jnlp");
       pb.start();
      
       System.exit(0);
       }
      


      This way even if the JRE is updated, my endorsed directories will be just fine.

      I'm just posting this because I was pulling my hair out trying to get the webservices running on JRE 1.6 on the client. JRE 1.6 adds extra code that conflicts with the JBoss Web Services and thankfully using endorsed mechanism there is a workaround.

      Hope this helps anyone else who is pulling their hair out right now. BTW, have not had any seam related issues at all using the new web services and 4.2.1.GA build from SVN.

      In case anyone is curious the ContextRoot property comes from the JNLP file as follows:

      <property name="ContextRoot" value="$$codebase"/>


      One other thing - when compiling your web services client side code with jdk 1.6u2 you need to tell javac ant task about the jboss endorsed jar files. This can be done using a little trick as follows:

       <target depends="init" name="build-project">
       <echo message="${ant.project.name}: ${ant.file}"/>
       <property name="jbEndorsed" value="-endorseddirs ${jboss.endorsed}"/>
       <javac debuglevel="${javac.debuglevel}" debug="${javac.debug}" destdir="bin" source="${source}" target="${target}">
       <src path="src"/>
       <classpath refid="JBossClient.classpath"/>
       <compilerarg line="${jbEndorsed}" />
       </javac>
       </target>
      


      where jboss.endorsed in my case equals c:\apps\jboss\jboss-4.2.1.GA\lib\endorsed. Otherwise you get build errors.



      Thanks,

      PVM