IIS

Java platform is extremely successful in building robust and high performance web applications. Platform independence is one of the strength of Java engine and Helicon Zoo now provides a convenient way to deploy and run Java web applications on Windows platform with Microsoft IIS. To deploy Java Servlet application on IIS 7 you will only need to follow this simple instruction:

Platfrom installation

  1. Download and install Web Platform Installer.
  2. Run Web Platform Installer and click “Options”.
  3. Add Helicon Zoo feed into Display additional scenarios box:  http://www.helicontech.com/zoo/feed. New “Zoo” tab will appear.
  4. Go to the Zoo, Packages and install Java Hosting Package.
  5. Accept licenses to start installation process.

Alternatively, instead of installing Java Hosting Package you can install Modules –> Helicon Zoo Module and Engines –> Jetty separately. This is minimal requirement to run Java Servlet applications under Microsoft IIS web server. If you want to run Java Servlets under IIS Express and WebMatrix in your development environment, then you will also need to install Helicon Zoo Module for IIS Express form Engines section.

This is enough configuration to run most of Java Servlet applications directly form IIS.

Installing application

Launch IIS Manager and create new web-site or an application within a web-site. Copy your Java application into the root folder of this IIS application. Java application could be either a single .war file or set of unpacked files with directory structure, including web-inf folder. Then just create the following web.config:

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <heliconZoo>
      <application name="jetty.project" >
        <environmentVariables>
          <!-- Uncomment line below if you want to set contexts directory -->
          <!--  <add name="CONTEXTS_DIR" value="%APPL_VIRTUAL_PATH%" /> -->

          <!-- Optional variables: -->
          <!-- <add name="CONTEXT_PATH" value="%APPL_VIRTUAL_PATH%" /> -->
          <!-- <add name="WAR_EXTRACT_PATH" value="%APPL_PHYSICAL_PATH%" /> -->

          <!-- A WAR file or start directory to run -->
          <add name="WAR_FILE" value="my_application.war" />
        </environmentVariables>
        </application>
    </heliconZoo>

        <handlers>
          <add name="jetty.project#x86" scriptProcessor="java.jetty"
            path="*" verb="*" modules="HeliconZoo_x86"
            preCondition="bitness32" resourceType="Unspecified"
            requireAccess="Script" />
          <add name="jetty.project#x64" scriptProcessor="java.jetty"
            path="*" verb="*" modules="HeliconZoo_x64"
            preCondition="bitness64" resourceType="Unspecified"
            requireAccess="Script" />
        </handlers>
  </system.webServer>
</configuration>

Please take a look at <environmentVariables> section.

  • CONTEXTS_DIR — optional path to directory with .xml files which describe Jetty contexts. If this variable isn’t set, Zoo looks for “contexts” folder in the root of application. If no such folder found, Zoo presumes the application has single context and uses variables described below.
  • CONTEXT_PATH — optional virtual path of the application. Default value is taken from APPL_VIRTUAL_PATH variable.
  • WAR_FILE — optional path to a .war file or directory with extracted application.
  • WAR_EXTRACT_PATH — optional .war file extraction path. Is set to application’s root folder by default.

Here is an example of context.xml file that you may use instead of setting WAR file name explicitly. This allows to run multiple applications and contexts in a single IIS web site.

contexts/context.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

   <Set name="contextPath">/application</Set>
   <Set name="war">my_application.war</Set>
   <Set name="tempDirectory">application_dir</Set>

</Configure>

WARNING: Since WAR files need to be extracted before execution you will need to have a folder with write permissions.  In default IIS installation all application pools are executed with permissions of IIS_IUSRS group which does not have write permissions to the web application folders. You will need to provide write permissions to the user running Application Pool or IIS_IUSRS group to the folder containing Java application or specify other folder using WAR_EXTRACT_PATH variable with write permissions provided.Now you can open IIS web site in the browser and see your Java web application running.

That’s it! Installation process is clear and automatic and will only take several minutes.

5 Responses to Deploying Java Servlet applications on Windows with IIS

  1. Peter says:

    Downloaded and installed as described in the article (http://www.helicontech.com/articles/deploying-java-servlet-applications-on-windows-with-iis/).

    However for some weird reason I can successfully view the Java app via IIS when using http://localhost/appname but if I do the same thing http:///appname on another machine I get a a 404 from IIS and if I do it on the server itself I get a 404 from Jetty instead.

    This is running on a 64bit Win2008R2 Std server VM with an IIS app set up to use a ASP.NET 4.0 integrated app pool.
    The folder the IIS app points to contains the contents of the WAR file, i.e. \web-inf and \xforms-jsp and the web.config with the described contents from the article.

    Any ideas on what could be wrong would be much appreciated.

    • Slavik says:

      Hello.
      Please try and use CONTEXT_PATH variable as follows:
      <add name=”CONTEXTS_PATH” value=”/appname” />

      Make sure “appname” is an application. If it’s not, open IIS manager, navigate to that folder and in the context menu click “Convert to Application”.

  2. jules says:

    I installed on a Windows 7 64 bit machine and then downloaded the jenkins.war file and tried to deploy it:
    But I get:
    HTTP ERROR: 503
    Problem accessing /test. Reason:
    Service Unavailable
    Powered by Jetty://

    ??

    • Slov says:

      I think installing Jenkins on IIS may deserve a separate article.
      First you will need to upgrade your Jetty installation as we have fixed some functions. Just delete C:\jetty folder and install again using Helicon Zoo feed.
      Then you will need to use contexts folder, instead of setting WAR file explicitly as Jenkins require additional configurations.
      Please remove all “environmentVariables” from web.config, create contexts folder, and create context.xml file in this folder with the following content:

      < ?xml version=”1.0″?>
      < !DOCTYPE Configure PUBLIC “-//Jetty//Configure//EN” “http://www.eclipse.org/jetty/configure.dtd”&gt;

      Test Realm
      /jenkins
      jenkins.war

      After that navigate to http://localhost/jenkins (not to the root folder). It should work now.

      • Slov says:

        A bug with tags. Try again:

        <?xml version=”1.0″?>
        <!–DOCTYPE Configure PUBLIC “-//Jetty//Configure//EN” “http://www.eclipse.org/jetty/configure.dtd”>–>

        <Configure class=”org.eclipse.jetty.webapp.WebAppContext”>
        <Get name=”securityHandler”>
        <Set name=”loginService”>
        <New class=”org.eclipse.jetty.security.HashLoginService”>
        <Set name=”name”>Test Realm</Set>
        </New>
        </Set>
        </Get>

        <Set name=”contextPath”>/jenkins</Set>
        <Set name=”war”>jenkins.war</Set>
        <Set name=”tempDirectory”>jenkins</Set>
        </Configure>

Reference :http://www.helicontech.com/articles/deploying-java-servlet-applications-on-windows-with-iis/

Advertisements
Comments
  1. vps says:

    Hello! I really love this blog. Please tell me – from where do you have information for ths post?

    Like

  2. Marguerite says:

    Perfect work you’ve done, this site is actually cool with good info.

    Like

  3. Cory says:

    Whatever usually do not realize is in fact how you’re no longer really much more neatly-preferred than you may be right this moment. You’re so intelligent.
    You recognize therefore significantly in relation to this matter, made me
    individually imagine it from numerous varied angles. Its like males and females usually are not interested until it’s something to accomplish with Woman gaga!
    Your individual stuffs outstanding. Always maintain it down!

    Like

  4. My Homepage says:

    … [Trackback]…

    […] Read More: zeeshanakhter.com/2013/03/12/deploying-java-servlet-applications-on-windows-with-iis/ […]…

    Like

  5. Basil says:

    Thanks a lot for sharing superb informations. Your site is very cool.
    I will be in awe of everything that you’ve in this internet site.

    It reveals how nicely you understand this subject. Bookmarked this
    website page, will return for extra articles. You, my friend, ROCK!
    I ran across simply the information I already searched everywhere and just couldn’t encounter. What an excellent web-site.

    Like

  6. Livable Room says:

    I need to admit you might have done a excellent job employing this.
    Also, your website – loads super quick in my opinion on Traveler.

    Outstanding Blog! Ever mind generally only pages and use a couple with all the articles in the event that
    Provided credit and sources to your webpage? My website elevates the very same
    market as yours and my users would really really take advantage
    of many of the information you provide here. Please inform me when this okay on your bottom line.
    Appreciate it!

    Like

  7. Wilson says:

    hey there and thanks to your information – I’ve certainly discovered something new from right here.
    Used to alternatively expertise some technical points using this site, since
    I skilled to reload the website a lot of occasions previous to I may makes it to load properly.
    I have been considering should your hosting is fine for some?
    No longer that I am complaining, however slow loading circumstances instances will sometimes impact your placement on the internet and can injury
    your high-quality rating if advertising and ***********

    Like

  8. I’ve joined your feed look at to seeking i’ll arrive at your
    magnificent post. Also, I’ve shared your web page around my web pages!

    Like

  9. I real glad to have this website on bing, precisely what I was searching for : D
    too saved to fav.

    Like

  10. Very interesting details you’ve observed, thanks for adding.

    Like

  11. Gwendolyn says:

    I’d must verify on your bottom line here.
    Which isn’t something I normally do! I appreciate reading a publish that will make individuals think. Additionally, thanks permitting me to comment!

    Like

  12. Hey very cool site!! Man .. Excellent .. Amazing .. I’ll book mark your site and accept the feeds additionally…I’m glad to get numerous
    useful information here inside submit, we would like figure
    out extra techniques within this regard, thanks for posting.
    . . . . .

    Like

  13. You’ve noted very interesting details ! ps nice web page.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s