<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Welcome to my world. &#187; Glassfish</title>
	<atom:link href="http://www.marceble.com/tag/glassfish/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marceble.com</link>
	<description>Marc E. Eble</description>
	<lastBuildDate>Thu, 22 Apr 2010 20:47:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Uploading Files Using Flash and Java</title>
		<link>http://www.marceble.com/2009/11/uploading-files-using-flash-and-java/</link>
		<comments>http://www.marceble.com/2009/11/uploading-files-using-flash-and-java/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 23:02:59 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[CS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JAVA]]></category>

		<guid isPermaLink="false">http://www.marceble.com/?p=210</guid>
		<description><![CDATA[The sample code attached below is a complete example for uploading multiple files using flash cs3 and java. After much searching I could not find a complete Flash File uploading tutorial that utilized java; most if not all are for php. This flash interface provides progress for each file independently, and upon completion can notify [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />The sample code attached below is a complete example for uploading multiple files using flash cs3 and java. After much searching I could not find a complete Flash File uploading tutorial that utilized java; most if not all are for php. This flash interface provides progress for each file independently, and upon completion can notify a javascript function. The files are sent to a simple JAVA servlet where they are saved to the local file system.</p>
<p><img class="alignnone" title="FlashUploadExample" src="http://www.marceble.com/downloads/FlashUploadExample/flashuploadexample.jpg" alt="" width="528" height="176" /></p>
<p>For the java servlet there are two library requirements:<br />
<strong> commons-fileupload-1.2.1.jar<br />
commons-io-1.3.2.jar</strong></p>
<p>They are included in the <strong>web/WEB-INF/lib</strong> folder. The source files are saved as a Netbeans 6.7 project with Glassfish set as the target server. It is simple to open the project and change the target server. Both the compiled flash and source file are in the <strong>web </strong>folder.</p>
<p>I extracted two settings to variables listed in the index.html file so that this could be used without recompiling/editing the flash file. The first variable <em>url</em> is the address of the java servlet to send the files to. The second variable is <em>f </em> and is the name of the javascript function to call when each file is uploaded. <em>f</em> is optional. These variables need to be set 3 times in the <strong>index.html</strong> file. See the file for further documentation.</p>
<p>I expect to update the source code slightly over the next couple weeks. I will replace the zip file with the latest as updates are completed.</p>
<p><a  href="http://www.marceble.com/downloads/FlashUploadExample/FlashUploadExample.zip"><span style="text-decoration: none;"><strong>source files</strong></span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceble.com/2009/11/uploading-files-using-flash-and-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Glassfish Enterprise v2.1 with HADB Setup on Windows 2003 Cluster</title>
		<link>http://www.marceble.com/2009/08/glassfish-enterprise-v2-1-with-hadb-setup-on-windows-2003-cluster/</link>
		<comments>http://www.marceble.com/2009/08/glassfish-enterprise-v2-1-with-hadb-setup-on-windows-2003-cluster/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 13:54:03 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[HADB]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[NLB]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www1.marceble.com/?p=82</guid>
		<description><![CDATA[ I am going to go over setting up Glassfish Enterprise v2.1 in a windows clustered high availability environment. For this we will be using two Windows 2003 servers with two network interface cards (NIC) in each server that are network loadbalanced, 2 instances of IIS as the web container and 4 instances of glassfish with [...]]]></description>
			<content:encoded><![CDATA[<p id="top" /> I am going to go over setting up Glassfish Enterprise v2.1 in a windows clustered high availability environment. For this we will be using two Windows 2003 servers with two network interface cards (NIC) in each server that are network loadbalanced, 2 instances of IIS as the web container and 4 instances of glassfish with HADB behind IIS. You may ask why, and the reason is simply those were the technologies I had to work with; my task was to move from JBOSS to Glassfish. I will attempt to go over this setup in great detail, so as anyone with a basic understanding of these technologies should be able to get this running. For all of the images in the post, click on them for a full size version.</p>
<p> <span id="more-82"></span></p>
<h2>Environment Setup</h2>
<p>At this point you should already have 2 identical windows 2003 servers running, for this tutorial I will refer to them as <strong>SERVER1</strong> and <strong>SERVER2</strong>. Each server should have 2 NICs. Make sure the default gateway is the SAME on all NICs. For clarification you will be using a total of 5 IP addresses. Two for each server, and one will be the virtual IP to reference the cluster. Though yours will likely be different, for this tutorial I will use<strong> 192.168.1.2</strong> for the virtual IP, <strong>192.168.1.3</strong> and <strong>192.168.1.103</strong> for SERVER1, and <strong>192.168.1.4</strong> and <strong>192.168.1.104 </strong>for SERVER2. Make sure your web address (if you have one) resolves to your virtual IP (192.168.1.2 here).</p>
<p> </p>
<h2>Network Load Balancing</h2>
<p>You will need two identical windows 2003 servers. Keep in mind that as there are two NICs in each server, it does not matter which network connection you use for the network load balancing, just make sure to only load balance one. I chose to load balance 192.168.1.3 and 192.168.1.4.</p>
<ol>
<li>In Network Connections right click one of the LAN connections and select properties.</li>
<li>Verify Network Load Balancing present and checked, if not you may need to add it by clicking Install.
<div class="mceTemp">
<dl class="wp-caption alignnone" style="width: 379px;">
<dt class="wp-caption-dt"><a  href="http://www.marceble.com/Images/glassfish_setup/DMZ_Properties.jpg" target="_blank" class="thickbox no_icon" rel="gallery-82" title="DMZ_Properties"><img title="DMZ_Properties" src="http://www.marceble.com/Images/glassfish_setup/DMZ_Properties.jpg" alt="Click for full size" width="369" height="443" /></a></dt>
</dl>
</div>
<p> </li>
<li>Select Network Load Balancing and click <strong>properties</strong></li>
<li>Enter the Virtual IP address to be associated with both servers.</li>
<li>For Cluster operation mode select <strong>Multicast</strong>.
<div class="mceTemp">
<dl class="wp-caption alignnone" style="width: 486px;">
<dt class="wp-caption-dt"><a  href="http://www.marceble.com/Images/glassfish_setup/cluster_parameters.jpg" target="_blank" class="thickbox no_icon" rel="gallery-82" title="cluster_parameters"><img title="cluster_parameters" src="http://www.marceble.com/Images/glassfish_setup/cluster_parameters.jpg" alt="Click for full size" width="476" height="445" /></a></dt>
</dl>
</div>
<p> </li>
<li>For host parameters set the machines IP and subnet.
<div class="mceTemp">
<dl class="wp-caption alignnone" style="width: 486px;">
<dt class="wp-caption-dt"><a  href="http://www.marceble.com/Images/glassfish_setup/host_parameters.jpg" target="_blank" class="thickbox no_icon" rel="gallery-82" title="host_parameters"><img title="host_parameters" src="http://www.marceble.com/Images/glassfish_setup/host_parameters.jpg" alt="Click for full size" width="476" height="444" /></a></dt>
</dl>
</div>
<p> </li>
<li>For port rules use all the defaults.</li>
<li>Click ok, select Internet Protocol (TCP/IP) and click <strong>properties</strong></li>
<li>Click <strong>advanced</strong></li>
<li>Under IP addresses make sure both the server IP and the virtual IP is listed.
<dt class="wp-caption-dt"><a  href="http://www.marceble.com/Images/glassfish_setup/advancedTCP.jpg" target="_blank"></a><a href="http://www.marceble.com/Images/glassfish_setup/advancedTCP.jpg"><img class="aligncenter" title="TCP Setting" src="http://www.marceble.com/Images/glassfish_setup/advancedTCP.jpg" alt="" width="1193" height="485" /></a> </dt>
</li>
<li>Repeat above for both servers.</li>
</ol>
<p> </p>
<h2>Java Setup</h2>
<p>I would assume since we are setting up a java server you are at least familiar with setting up java and may already have it installed. However for completeness I have outlined the exact setup I used.</p>
<p>Sun&#8217;s JAVA 1.6 JDK should be setup on both servers. You can download it from <a  href="http://java.sun.com">http://java.sun.com</a>. You can likely just use the latest version, as of this writing that was 1.6.15. I installed the jdk to the default location: <strong>C:\program files\java\jdk1.6.0_15</strong> and the JRE to <strong>C:\program files\java\jre6</strong>. Then create an environmental variable <strong>JAVA_HOME</strong> with the value <strong>C:\Program Files\Java\jdk1.6.0_15</strong>. Add <strong>C:\program files\java\jdk1.6.0_15\bin</strong> to the <strong>PATH</strong> environmental variable.</p>
<p> </p>
<h2>IIS Install</h2>
<p>IIS setup is trivial. In windows use the &#8220;Add a Role&#8221; on both servers to install IIS. In IIS Manager (found in administrative tools) right click on the default website, go to properties and enter in the virtual IP address and fully qualified domain name for the description. To verify it works try accessing <a  href="http://localhost">http://localhost</a>. If it doesn&#8217;t come up the first thing you should check are the permissions. Check the user account used for anonymous access. Once both servers are setup you then should be able to access IIS&#8217;s &#8220;Under Construction&#8221; page from the virtual ip, in this tutorial: <strong>http://192.168.1.2/</strong>.</p>
<p> </p>
<h2>Glassfish setup</h2>
<p>Make sure you download Glassfish Enterprise Server v2.1 with HADB. At the time of this writing you can find it <a  href="http://developers.sun.com/appserver/downloads/index.jsp" target="_blank">here</a>.</p>
<h3><strong>A. Complete the following setup on SERVER1 only:</strong></h3>
<ol>
<li>Open the setup file. Click next.<br />
<img class="aligncenter" title="glassfish install" src="http://www.marceble.com/Images/glassfish_setup/sjas1.jpg" alt="" width="622" height="538" /><a  href="http://www.marceble.com/Images/glassfish_setup/sjas1.jpg" target="_blank"> </a></li>
<li>The agreement will come up, complete that and click next again. </li>
<li>For installation Directory leave the default <strong>C:\Sun\AppServer</strong>. </li>
<li>Click next, if prompted select &#8220;create directory&#8221;. It should now ask you for &#8220;Component Selection&#8221;.<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/sjas2.jpg" class="thickbox no_icon" rel="gallery-82" title="component selection"><img class="aligncenter" title="component selection" src="http://www.marceble.com/Images/glassfish_setup/sjas2.jpg" alt="" width="624" height="555" /></a> </p>
<ol>
<li>Select all of the check boxes in the Server Tier: <strong>Node Agent, High Availability Database Server</strong>, and <strong>Load Balancing Plugin</strong>. </li>
<li>Under Administration Select the first option: <strong>Domain Administration Server and Administration Too</strong><strong>l</strong>. </li>
<li>Make sure  <strong>Sample Applications</strong> is checked under Additional.  </li>
</ol>
</li>
<li>Click Next to go to &#8220;Java Configuration&#8221;. Select <strong>Reuse existing Java 2 SDK</strong>. It should automatically then say C:\Program Files\Java\jdk1.6.0_15. </li>
<li>Click Next to go to &#8220;Web Server Location&#8221;. Select <strong>Microsoft IIS 5.0 or above</strong>. </li>
<li>Click Next. It will prompt you to setup the load balance plug in, select OK.</li>
<li>You should now be on &#8220;Admin Configuration&#8221;. Type in a password and master password. Set HTTP port to <strong>8080</strong> and HTTPS to <strong>8433</strong>.</li>
<li>Click Next to go to &#8220;Installation Options&#8221; Do not enable the update center client. <strong>Do not Create Windows Service</strong>, we will set this up later.<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/sjas6.jpg" target="_blank" class="thickbox no_icon" rel="gallery-82" title="Installation Options"><img class="aligncenter" title="Installation Options" src="http://www.marceble.com/Images/glassfish_setup/sjas6.jpg" alt="" width="620" height="548" /></a> </li>
<li>Click Next and Complete the installation.</li>
</ol>
<h3>B. IIS Redirector</h3>
<p>Open IIS Manager.</p>
<ol>
<li>Right click the default website and click properties.</li>
<li>Select the ISAPI filter tab.</li>
<li>Click Add<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/IIS_ISAPI.jpg" class="thickbox no_icon" rel="gallery-82" title="ISAPI"><img class="aligncenter" title="ISAPI" src="http://www.marceble.com/Images/glassfish_setup/IIS_ISAPI.jpg" alt="" width="692" height="570" /></a>    </p>
<ol>
<li>Filter Name: <strong>Application Server<span style="font-weight: normal; "> </span></strong></li>
<li><strong><span style="font-weight: normal; ">Executable: <strong>C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll<span style="font-weight: normal; "> </span></strong></span></strong></li>
</ol>
</li>
<li>In the default website create a new virtual directory
<ol>
<li>Alias: <strong>sun-paththrough<span style="font-weight: normal; "> </span></strong></li>
<li><strong><span style="font-weight: normal; ">Directory: <strong>C:\Inetpub\wwwroot\sun-passthrough<span style="font-weight: normal; "> </span></strong></span></strong></li>
<li><strong><span style="font-weight: normal; "><strong><span style="font-weight: normal; ">Under Permissions check <strong>Execute<span style="font-weight: normal; "> </span></strong></span></strong></span></strong></li>
</ol>
</li>
<li>Make sure the following is set for the PATH environmental variable:<strong> </strong>
<ol>
<li><strong>C:\Inetpub\wwwroot\sun-passthrough;C:\Sun\AppServer\lib;C:\Sun\AppServer\bin;C:\Program Files\Java\jdk1.6.0_15\bin<span style="font-weight: normal; "> </span></strong></li>
</ol>
</li>
<li>Right click Web Service Extensions and Select ADD<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/webserviceentension.jpg" class="thickbox no_icon" rel="gallery-82" title="iis setup"><img class="aligncenter" title="iis setup" src="http://www.marceble.com/Images/glassfish_setup/webserviceentension.jpg" alt="" width="804" height="623" /></a>    </p>
<ol>
<li>Name: <strong>Sun-Passthrough<span style="font-weight: normal; "> </span></strong></li>
<li><strong><span style="font-weight: normal; ">File: <strong>C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll<span style="font-weight: normal; "> </span></strong></span></strong></li>
<li><strong><span style="font-weight: normal; "><strong><span style="font-weight: normal; ">Check <strong>set status to allowed</strong></span></strong></span></strong></li>
</ol>
</li>
<li><strong> <span style="font-weight: normal; ">Create the file: <strong>C:\Inetpub\wwwroot\sun-passthrough\lb.log<span style="font-weight: normal; "> </span></strong></span></strong>
<ol>
<li>Modify the permissions on the file so the group<strong> IIS_WPG</strong> has <strong>write</strong> and <strong>modify</strong>.</li>
</ol>
</li>
<li>Reboot your server.</li>
</ol>
<h3><strong>C. Start the Node Agent and Admin Server.</strong></h3>
<ol>
<li>This can be achieved by going to Start -&gt; Program Files -&gt; Sun
<ul>
<li>Start both the admin server and node agent. You will be prompted for the passwords you entered during setup.</li>
</ul>
</li>
</ol>
<p><a  href="http://www.marceble.com/Images/glassfish_setup/sjasstartup.jpg" class="thickbox no_icon" rel="gallery-82" title="glassfish startup"><img class="aligncenter" title="glassfish startup" src="http://www.marceble.com/Images/glassfish_setup/sjasstartup.jpg" alt="" width="1224" height="834" /></a></p>
<h3><strong>D. Install glassfish on SERVER2</strong></h3>
<p>Repeat steps A through C above with the following exceptions:</p>
<ol>
<li>In the &#8220;Component Selection&#8221; of the glassfish install selection <strong>No Administration Tools</strong></li>
<li>Setup will ask you to specify the admin host. Use SERVER1&#8242;s IP:<strong> 192.168.1.3</strong></li>
</ol>
<p> </p>
<h2>Glassfish Cluster</h2>
<p>By now the domain admin server should be running on SERVER1 and the Node agents should be running on SERVER1 and SERVER2. Now we will create the glassfish cluster, with two instances on each physical server.</p>
<ol>
<li>login to the Admin Console found at <strong>https://localhost:4848/</strong> on SERVER1</li>
<li>Select <strong>Clusters</strong>, then click <strong>New</strong></li>
<li><strong> </strong>For the name of the cluster I used <strong>application_cluster</strong></li>
<li>under instances select new, call the instance <strong>app1</strong>, give it a weight of <strong>100</strong>, and select <strong>SERVER1</strong> as the node.
<ul>
<li>create 3 more instances, <strong>app2</strong>,<strong> app3</strong>, and <strong>app4</strong>, all with a weight of <strong>100</strong>. Make sure <strong>app3</strong> and <strong>app4</strong> user<strong> SERVER2</strong> for their nodes.</li>
</ul>
<div><a  href="http://www.marceble.com/Images/glassfish_setup/cluster-config.jpg" class="thickbox no_icon" rel="gallery-82" title="cluster config"><img class="aligncenter" title="cluster config" src="http://www.marceble.com/Images/glassfish_setup/cluster-config.jpg" alt="" width="1234" height="754" /></a></div>
</li>
</ol>
<h2 style="font-size: 1.5em; ">HTTP Load Balancer</h2>
<p>Now we need to setup the load balancer. This piece is essentially the map from IIS to glassfish. It is an xml file that will need to be updated every time you add a new application to the server, or add additional glassfish instances to the cluster. The admin console will build it for you, all is needed is to copy it over to IIS.</p>
<ol>
<li>In the admin console select &#8220;HTTP Load Balancers&#8221;.</li>
<li>Click <strong>New</strong>. Enter <strong>applicationlb</strong> for the name, <strong>localhost</strong> for IP and <strong>80</strong> for port.
<ul>
<li><em>The port and IP here are actually irrelevant as glassfish does not support auto updating the loadbalancer with IIS.</em></li>
</ul>
</li>
<li>Add <strong>application_cluster</strong> as the selected target<br />
 <a  href="http://www.marceble.com/Images/glassfish_setup/loadbalancer.jpg" class="thickbox no_icon" rel="gallery-82" title="loadbalancer"><img class="aligncenter" title="loadbalancer" src="http://www.marceble.com/Images/glassfish_setup/loadbalancer.jpg" alt="" width="948" height="867" /></a></li>
<li>Click ok. Click on <strong>applicationlb</strong> you just created and select the Export tab, then click Export Now.</li>
<li>If you get the following error: <strong>The XML page cannot be displayed</strong>, right click and select <strong>view source</strong>. </li>
<li>You need to create the file <strong>loadbalancer.xml</strong> at <strong>C:\Inetput\wwwroot\sun-passthrough\ </strong> and save the contents to this file. The file must be saved on BOTH servers. Afterward restart IIS on both machines and restart the glassfish cluster. You can see an example of my loadbalancer.xml below:</li>
</ol>
<pre><span style="font-family: Consolas; line-height: 18px; white-space: pre; ">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun Java System Application Server 9.1//EN" "sun-loadbalancer_1_2.dtd"&gt;
&lt;loadbalancer&gt;
  &lt;cluster name="application_cluster" policy="round-robin"&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38080 https://SERVER1:38181" name="app_2" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38081 https://SERVER1:38182" name="app_1" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38080 https://SERVER2:38181" name="app_3" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38081 https://SERVER2:38182" name="app_4" weight="100"/&gt;
    &lt;health-checker interval-in-seconds="30" timeout-in-seconds="10" url="/"/&gt;
  &lt;/cluster&gt;
  &lt;property name="response-timeout-in-seconds" value="60"/&gt;
  &lt;property name="reload-poll-interval-in-seconds" value="60"/&gt;
  &lt;property name="https-routing" value="true"/&gt;
  &lt;property name="require-monitor-data" value="false"/&gt;
  &lt;property name="last-exported" value=""/&gt;
  &lt;property name="active-healthcheck-enabled" value="false"/&gt;
  &lt;property name="number-healthcheck-retries" value="3"/&gt;
  &lt;property name="rewrite-location" value="true"/&gt;
&lt;/loadbalancer&gt;
&lt;!--
 This file was generated on: [Wed Aug 26 00:54:11 GMT-10:00 2009].
Debugging Tips:
By default, instances and web-modules are not enabled. Please enable them manually if you have not done that using asadmin.
--&gt;</span></pre>
<h2><strong>HADB Setup</strong></h2>
<p>Next we&#8217;ll setup the high availability. This is where the second network adapters come into play.  First we install the service.</p>
<ol>
<li>Open up a command prompt window </li>
<li><strong>C:\Sun\AppServer\hadb\4.4.3-6\bin\</strong></li>
<li>Run the command: <strong>ma -i ma.cfg</strong> to install the service.  <br />
<a  href="http://www.marceble.com/Images/glassfish_setup/hadb_service.jpg" class="thickbox no_icon" rel="gallery-82" title="hadb"><img class="aligncenter" title="hadb" src="http://www.marceble.com/Images/glassfish_setup/hadb_service.jpg" alt="" width="669" height="328" /></a> </li>
<li>open windows services and verify the<strong> HADBManagementAgent </strong>service is running.</li>
<li>Repeat on second server.</li>
</ol>
<p>Next we need to setup the HADB domain.</p>
<ol>
<li>On each server type the command <strong>hadbm listdomain</strong>, if a domain exists, delete it by using the command: <strong>hadbm deletedomain</strong>.</li>
<li>On <strong>SERVER1</strong> execute the following command:
<ul>
<li><strong>asadmin configure-ha-cluster &#8211;user admin &#8211;hosts 192.168.1.103,192.168.1.104 &#8211;devicesize 256 application_cluster</strong></li>
<li>It is important here that we use the IP addresses from the NIC&#8217;s that are not network load balanced.   <br />
 </li>
</ul>
</li>
</ol>
<h2>Windows Services</h2>
<p>Now that everything should be running well, we will register glassfish as a windows service so it starts up automatically. I will user SERVER1 below, make sure you repeat this for SERVER2.</p>
<ol>
<li>Stop the node agent if it is running, do this from Start-&gt;Program Files-&gt;Sun Stop Node Agent.</li>
<li>Create a file named <strong>password.txt </strong>in <strong>C:\Sun\Appserver</strong></li>
<li>Add the text below to the file, replacing <em>adminadmin</em> with your password.</li>
<pre>AS_ADMIN_MASTERPASSWORD=adminadmin
AS_ADMIN_PASSWORD=adminadmin</pre>
<li>Open a command prompt window and navigate to <strong>system32</strong>.</li>
<li>type the command below:</li>
</ol>
<p> </p>
<p><textarea> sc create SERVER1 binPath= &#8220;C:\Sun\AppServer\lib\appservAgentService.exe \&#8221;C:\Sun\AppServer\bin\asadmin.bat start-node-agent &#8211;user admin &#8211;passwordfile C:\Sun\AppServer\password.txt SERVER1\&#8221; \&#8221;C:\Sun\AppServer\bin\asadmin.bat stop-node-agent SERVER1\&#8221;" start= auto DisplayName= &#8220;SunJavaSystemAppServer SERVER1&#8243;</textarea></p>
<p> </p>
<h2>Test Application Deployment</h2>
<p>To test the server configuration Sun includes the Sample application clusterjsp. It is a simple application that tells you what server instance processed your request, and allows you to create session variables. you can then experiment will shutting down server instances and seeing if the session data persists. To deploy the app we do the following:</p>
<p> </p>
<ol>
<li>In the glassfish admin console, select <strong>Enterprise Applications</strong> then click <strong>Deploy.</strong></li>
<li>For location browse to the following file: <strong>C:\Sun\AppServer\samples\quickstart\clusterjsp\clusterjsp.ear</strong></li>
<li>Check the box for <strong>availability.</strong></li>
<li>Add only <strong>application_cluster</strong> for Targets.<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/deploy.jpg" target="_blank"><span style="color: #000000; text-decoration: none;"> </span></a><a  href="http://www.marceble.com/Images/glassfish_setup/deploy.jpg" class="thickbox no_icon" rel="gallery-82" title="deploy"><img class="alignnone" title="deploy" src="http://www.marceble.com/Images/glassfish_setup/deploy.jpg" alt="" width="1040" height="958" /></a><a  href="http://www.marceble.com/Images/glassfish_setup/deploy.jpg" target="_blank"> </a></li>
<li>Click OK.</li>
<li>Expand <strong>Clusters</strong> and select <strong>application_cluster</strong></li>
<li>Click on the <strong>applications</strong> tab, check clusterjsp, and select <strong>Load Balancer Enable</strong> from the &#8211;more actions&#8211; drop down.<br />
<a  href="http://www.marceble.com/Images/glassfish_setup/deploy1.jpg" target="_blank"><span style="color: #000000; text-decoration: none;"> </span></a><a  href="http://www.marceble.com/Images/glassfish_setup/deploy1.jpg" class="thickbox no_icon" rel="gallery-82" title="deploy1"><img class="aligncenter" title="deploy1" src="http://www.marceble.com/Images/glassfish_setup/deploy1.jpg" alt="" width="1062" height="945" /></a><a  href="http://www.marceble.com/Images/glassfish_setup/deploy1.jpg" target="_blank"> </a></li>
<li>Repeat the steps for setting up the Load Balancing. Your new loadbalancer.xml should look something like the following:</li>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE loadbalancer PUBLIC "-//Sun Microsystems Inc.//DTD Sun Java System Application Server 9.1//EN" "sun-loadbalancer_1_2.dtd"&gt;
&lt;loadbalancer&gt;
  &lt;cluster name="application_cluster" policy="round-robin"&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38080 https://SERVER1:38181" name="app_2" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER1:38081 https://SERVER1:38182" name="app_1" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38080 https://SERVER2:38181" name="app_3" weight="100"/&gt;
    &lt;instance disable-timeout-in-minutes="30" enabled="true" listeners="http://SERVER2:38081 https://SERVER2:38182" name="app_4" weight="100"/&gt;
    &lt;web-module context-root="/clusterjsp" disable-timeout-in-minutes="30" enabled="true"/&gt;
    &lt;health-checker interval-in-seconds="30" timeout-in-seconds="10" url="/"/&gt;
  &lt;/cluster&gt;
  &lt;property name="response-timeout-in-seconds" value="60"/&gt;
  &lt;property name="reload-poll-interval-in-seconds" value="60"/&gt;
  &lt;property name="https-routing" value="true"/&gt;
  &lt;property name="require-monitor-data" value="false"/&gt;
  &lt;property name="last-exported" value=""/&gt;
  &lt;property name="active-healthcheck-enabled" value="false"/&gt;
  &lt;property name="number-healthcheck-retries" value="3"/&gt;
  &lt;property name="rewrite-location" value="true"/&gt;
&lt;/loadbalancer&gt;
&lt;!--
 This file was generated on: [Wed Aug 26 00:54:11 GMT-10:00 2009].
Debugging Tips:
By default, instances and web-modules are not enabled. Please enable them manually if you have not done that using asadmin.
--&gt;</pre>
<li>Navigate to http://192.168.1.2/clusterjsp to test the server. Make sure you use the virtual IP to reference the application.</li>
</ol>
<p> </p>
<h2>SSL (optional)</h2>
<p>SSL is very straight forward to setup; it only involves IIS. Microsoft has an excellent tutorial on how to achieve this:</p>
<ul>
<li><a  href="http://support.microsoft.com/kb/313299">http://support.microsoft.com/kb/313299  </a></li>
</ul>
<h2>Summary</h2>
<p>If you have any problems or questions leave a comment below and I will try to answer.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1678px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div>
]]></content:encoded>
			<wfw:commentRss>http://www.marceble.com/2009/08/glassfish-enterprise-v2-1-with-hadb-setup-on-windows-2003-cluster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JAVA Security Provider Error</title>
		<link>http://www.marceble.com/2009/08/java-security-providers/</link>
		<comments>http://www.marceble.com/2009/08/java-security-providers/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 22:56:39 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.marceble.com/?p=147</guid>
		<description><![CDATA[Just a quick note about a simple but annoying error I encountered when porting an app to glassfish; The code in question was as follows:   ...      Charset charset = Charset.forName("UTF-8");     CharsetEncoder encoder = charset.newEncoder();     ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(str));   SecretKeySpec key = new SecretKeySpec( KEY_BASE, "DES" );     private static Cipher [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Just a quick note about a simple but annoying error I encountered when porting an app to glassfish; The code in question was as follows:</p>
<pre> 
     ... 
    Charset charset = Charset.forName("UTF-8");
    CharsetEncoder encoder = charset.newEncoder();
    ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(str));
    SecretKeySpec key = new SecretKeySpec( KEY_BASE, "DES" );

    private static Cipher ecipher = Cipher.getInstance( "DES");
    ecipher.init( Cipher.ENCRYPT_MODE, key ); 
    byte[] enc = ecipher.doFinal( bbuf.array() );
     ...</pre>
<pre><span style="font-family: Georgia; line-height: 19px; white-space: normal;">The code above just converts a string (stored as str here) to UTF-8 then encrypts it using DES. Equivalently you could use str.getBytes() for the UTF conversion. The code above worked fine on JBOSS, and worked fine stand alone. It even worked on my glassfish test server, however when deployed on glassfish enterprise I started getting the following stacktrace:<span id="more-147"></span>
</span></pre>
<pre>    java.security.ProviderException: update() failed
        at  sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:557)
        at  sun.security.pkcs11.P11Cipher.engineUpdate(P11Cipher.java:457)
        at  sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:485)
        at  sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:471)
        at  javax.crypto.Cipher.doFinal(DashoA13*..)
    ...
    Caused  by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
        at  sun.security.pkcs11.wrapper.PKCS11.C_EncryptUpdate(Native Method)
        at  sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:510)</pre>
<p>After much trial and error I found the issue at hand was caused by the security provider being used. Adding the following code segment I output the provider being used and ran it both stand alone and inside glassfish:</p>
<pre>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">            System.out.println("--------" + ecipher.getProvider().getName());</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">            System.out.println(ecipher.getProvider().getInfo());</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">            System.out.println(ecipher.getProvider().getVersion())            System.out.println("--------" + ecipher.getProvider().getName());</div>
</pre>
<pre>    System.out.println(ecipher.getProvider().getName());
    System.out.println(ecipher.getProvider().getInfo());
    System.out.println(ecipher.getProvider().getVersion());</pre>
<p>When running stand alone I got the following output:</p>
<pre style="padding-left: 30px; ">SunJCE
SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, 
                 ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
1.6</pre>
<p>Running in glassfish I got:</p>
<pre style="padding-left: 30px; ">SunPKCS11-__SUN_SJSAS_internal
SunPKCS11-__SUN_SJSAS_internal using library C:\Sun\AppServer\lib\softokn3.dll</pre>
<p>I tried prioritizing SunJCE in java.security however the above results did not change. Finally I just specified SunJCE in my Cipher.getInstance so:</p>
<pre style="padding-left: 30px; ">Cipher.getInstance("DES", "SunJCE");</pre>
<p>After that all worked well. A very trivial issue to resolve, however annoying nonetheless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marceble.com/2009/08/java-security-providers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Virtual Directories in Glassfish</title>
		<link>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/</link>
		<comments>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 11:55:09 +0000</pubDate>
		<dc:creator>Marc</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Glassfish]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[virtual directory]]></category>

		<guid isPermaLink="false">http://www.marceble.com/?p=121</guid>
		<description><![CDATA[There are many reasons you may want some of your content outside of the application server root. Perhaps you wish to share the content between applications or even webservers, or maybe you temporarily write data from a database to be served. Regardless, serving static content in glassfish is extremely easy. There are two ways to accomplish [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />There are many reasons you may want some of your content outside of the application server root. Perhaps you wish to share the content between applications or even webservers, or maybe you temporarily write data from a database to be served. Regardless, serving static content in glassfish is extremely easy. There are two ways to accomplish this; at the server level and at the application level.</p>
<h3>Server level</h3>
<p>First we will look at the server level, this will make your information available server wide, outside of any application context. Lets say you have images you wish to serve in the directory C:\media. In the glassfish admin console expand configuration &gt; http service &gt; virtual servers. Select &#8216;server&#8217; then scroll to the bottom and select &#8216;add property&#8217;.</p>
<p>For name use: <em><strong>alternatedocroot_1</strong>,</em> for value use: <em><strong>from=/media/* dir=C:/</strong></em></p>
<p>Keep in mind that glassfish expects the directory in the URL pattern to exist, so the <em><strong>from=</strong></em> is not just the URL pattern, but it is also the path relative to the <em><strong>dir=</strong></em>.</p>
<p><span id="more-121"></span>Luckily these changes do not require any restarts so you can experiment easily to make sure you have the settings you want. If you used the default glassfish install and your server runs at <a  href="http://localhost:8080">http://localhost:8080</a> then <a  href="http://localhost:8080/media/">http://localhost:8080/media/</a> should now resolve to the absolute path C:\media.</p>
<p style="TEXT-ALIGN: center"><a  href="http://www.marceble.com/virtualdirectories.jpg" target="_blank" class="thickbox no_icon" rel="gallery-121" title="virtualdirectories"><img class="aligncenter" title="virtualdirectories" src="http://www.marceble.com/virtualdirectories.jpg" alt="Using virtual directories in Glassfish." width="1013" height="596" /></a></p>
<p style="TEXT-ALIGN: center"><em>The image above shows adding an alternate docroot from in the admin console, click it for the full sized image.</em></p>
<p style="TEXT-ALIGN: center">
<h3>Application Level</h3>
<p>Let&#8217;s say you have an application <em>WebApplication1</em>. By editing sun-web.xml you can add an alternate docroot that is relative to the application. For this example I will use the same as above, serving /media/* from C:/.</p>
<p>Add the following line to <strong>sun-web.xml</strong> inside the <strong>&lt;sun-web-app&gt;</strong> tag:</p>
<p><strong>&lt;property name=&#8221;alternatedocroot_1&#8243; value=&#8221;from=/media/* dir=C:/&#8221;/&gt;</strong></p>
<p>If using the default glassfish setup, <a  href="http://localhost:8080/WebApplication1/media/">http://localhost:8080/WebApplication1/media/</a> should now resolve to the absolute directory C:\media</p>
<p style="text-align: center;"><a  href="http://www.marceble.com/sunwebxml.jpg" target="_blank" class="thickbox no_icon" rel="gallery-121" title="sunwebxml"><img class=" aligncenter" title="sunwebxml" src="http://www.marceble.com/sunwebxml.jpg" alt="alternate docroot in sun-web.xml" width="1042" height="678" /></a></p>
<p style="TEXT-ALIGN: center"><em> The image above shows an example of sun-web.xml. Click for full size.</em></p>
<p style="TEXT-ALIGN: left">In both of the above scenarios you can have as many alternate docroots as you want, as long as the follow the naming convention (alternatedocroot_1, alternatedocroot_2, etc&#8230;). Also your url pattern can be as specific as you like, for instance if you only wanted to catch requests for jpeg&#8217;s in the media directory then you would use: from=/media/*.jpg</p>
<p style="TEXT-ALIGN: left">
]]></content:encoded>
			<wfw:commentRss>http://www.marceble.com/2009/07/virtual-directories-in-glassfish/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
