<?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>NiceCabbage Blog &#187; sinatra</title>
	<atom:link href="http://www.nicecabbage.com/tag/sinatra/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicecabbage.com</link>
	<description>Life, Design, Web Application</description>
	<lastBuildDate>Mon, 07 Jun 2010 02:03:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby Sinatra application on Google App Engine Java</title>
		<link>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/</link>
		<comments>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 03:36:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Turoial]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=88</guid>
		<description><![CDATA[
This article is all about what I have done to make my first Sinatra application on Google’s App engine/Java aka GAE. As you know, Sinatra is a light web application framework for Ruby. We can run Sinatra on GAE because GAE has started to support Java since April 2009 and there existed a Java implementation [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://content.screencast.com/users/ltrain/folders/Jing/media/96a766bf-7287-4583-85ff-731add765cc7/2009-06-17_1245.png" class="alignnone" width="300" height="200" /></p>
<p>This article is all about what I have done to make my first <a href="http://www.sinatrarb.com/">Sinatra</a> application on <a href="http://code.google.com/appengine">Google’s App engine/Java</a> aka GAE. As you know, Sinatra is a light web application framework for <a href="http://www.ruby-lang.org/">Ruby</a>. We can run Sinatra on GAE because GAE has started to support Java since April 2009 and there existed a Java implementation of Ruby called <a href="http://jruby.codehaus.org/">JRuby</a>.</p>
<p>Before proceeding, you are sure that you already have a valid account for GAE. Otherwise, hurry up to register your account at <a href="http://appengine.google.com/">here</a>.</p>
<p>OK, now you are ready and let’s get started!</p>
<h2>Install JRuby</h2>
<p><img alt="" src="http://asset-1.kenai.com/attachments/images/project/jruby.png" class="alignnone" width="150" height="148" /></p>
<p>First, download a JRuby package using <a href="http://git-scm.com/">git</a>. If you are unfamiliar with <a href="http://git-scm.com">Git</a>, <a href="http://github.com/guides/home">tutorials and articles</a> on <a href="http://github.com">github</a>, including <a href="http://github.com/guides/git-screencasts">screencasts</a> and <a href="http://github.com/guides/git-podcasts">podcasts</a> are your good introduction. </p>
<p>Installation of git on Ubuntu is as easy as </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> git-core</pre></div></div>

<p>If you are using other operating systems, check <a title="http://github.com/guides/home" href="http://github.com/guides/home">http://github.com/guides/home</a>.</p>
<p>To install JRuby, type</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> git clone git:<span style="color: #000000; font-weight: bold;">//</span>kenai.com<span style="color: #000000; font-weight: bold;">/</span>jruby~main</pre></div></div>

<p>Do not type <strong>jruby-main.</strong> <strong>jruby~main </strong>is correct.</p>
<p>Moving to jruby~main directory, start compiling.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> jruby~main
<span style="color: #000000; font-weight: bold;">%</span> ant
<span style="color: #000000; font-weight: bold;">%</span> ant jar-complete</pre></div></div>

<p>Check the jruby version with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –version
jruby 1.4.0dev <span style="color: #7a0874; font-weight: bold;">&#40;</span>ruby 1.8.6p287<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2009</span>-06-<span style="color: #000000;">16</span> <span style="color: #000000;">6586</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Java HotSpot<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> Client VM 1.5.0_16<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>i386-java<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<h2>Install Sinatra and related gems</h2>
<p><img alt="" src="http://www.sinatrarb.com/images/logo.gif" width="156" height="108" /></p>
<p>Check the gem version with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –S gem –version
1.3.3</pre></div></div>

<p>To install rubygems for your new jruby, try</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –S gem <span style="color: #c20cb9; font-weight: bold;">install</span> rake sinatra wabler mongrel
JRuby limited openssl loaded. gem <span style="color: #c20cb9; font-weight: bold;">install</span> jruby-openssl <span style="color: #000000; font-weight: bold;">for</span> full support.
<span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>wiki.jruby.org<span style="color: #000000; font-weight: bold;">/</span>wiki<span style="color: #000000; font-weight: bold;">/</span>JRuby_Builtin_OpenSSL<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
Successfully installed rake-0.8.7
Successfully installed rack-1.0.0
Successfully installed sinatra-0.9.2
Successfully installed warbler-0.9.13
Successfully installed gem_plugin-0.2.3
Successfully installed mongrel-1.1.5-java
<span style="color: #000000;">6</span> gems installed</pre></div></div>

<p>Did you see OpenSSL messages, too? You can leave it for now.</p>
<h2>Install JRuby-Rack</h2>
<p>Get a copy of jruby-rack from github.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #666666; font-style: italic;"># only if you are still in jruby~main directory</span>
<span style="color: #000000; font-weight: bold;">%</span> git clone git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>nicksieger<span style="color: #000000; font-weight: bold;">/</span>jruby-rack.git
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> jruby-rack
<span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby\~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jruby <span style="color: #660033;">-S</span> rake <span style="color: #007800;">SKIP_SPECS</span>=<span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p>Be careful not to forget to add “SKIP_SPECS=true” when you perform rake command in jruby-rack. Without it, rake will fail.</p>
<h2>Create Sinatra Appcalition</h2>
<p>Now, let’s create a new Sinatra application. First make a directory for our first app.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myway-app</pre></div></div>

<p>Make directories</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> views public config lib</pre></div></div>

<p>Create files</p>
<h4>1. config.ru</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #ff0000;">'rubygems'</span>
require <span style="color: #ff0000;">'sinatra'</span>
root_dir = File.dirname<span style="color: #7a0874; font-weight: bold;">&#40;</span>__FILE__<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">set</span> :environment, :production
<span style="color: #000000; font-weight: bold;">set</span> :root, root_dir
<span style="color: #000000; font-weight: bold;">set</span> :app_file, File.join<span style="color: #7a0874; font-weight: bold;">&#40;</span>root_dir, <span style="color: #ff0000;">'app.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
disable :run
require <span style="color: #ff0000;">'app'</span>
run Sinatra::Application</pre></div></div>

<h4>2. app.rb</h4>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
&nbsp;
get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#996600;">&quot;Hello from Sinatra running on Java!&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>3. appengine-web.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appengine-web-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://appengine.google.com/ns/1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>live-ch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;static-files</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource-files</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sessions-enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sessions-enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system-properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.management.enabled&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;os.arch&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.mode&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;JIT&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- JIT|FORCE|OFF --&gt;</span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastest&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.frameless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.positionless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.threadless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastops&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastcase&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.chainsize&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;500&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.lazyHandles&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.peephole&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system-properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appengine-web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>4. config/warble.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Warbler::Config</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span>
  config.<span style="color:#9900CC;">dirs</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>lib views public<span style="color:#006600; font-weight:bold;">&#41;</span>
  config.<span style="color:#9900CC;">includes</span> = FileList<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;appengine-web.xml&quot;</span>, <span style="color:#996600;">&quot;app.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">staging_dir</span> = <span style="color:#996600;">'war'</span>
  config.<span style="color:#9900CC;">java_libs</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">gems</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'sinatra'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">gem_dependencies</span> = <span style="color:#0000FF; font-weight:bold;">true</span> 
  config.<span style="color:#9900CC;">webxml</span>.<span style="color:#9900CC;">booter</span> = <span style="color:#ff3333; font-weight:bold;">:rack</span> 
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>For a test run,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ruby app.rb
== Sinatra<span style="color: #000000; font-weight: bold;">/</span>0.9.2 has taken the stage on <span style="color: #000000;">4567</span> <span style="color: #000000; font-weight: bold;">for</span> development with backup from Mongrel</pre></div></div>

<p>Go to <a href="http://localhost:4567/">http://localhost:4567/</a>, and you will see a string message that sinatra is running. OK, press Ctrl+C to stop the server.</p>
<h2>Setup for GAE</h2>
<p><img alt="" src="http://code.google.com/intl/ja/appengine/images/appengine_lowres.gif" class="alignnone" width="142" height="109" /></p>
<p>You need to download GAE SDK for Java from <a href="http://code.google.com/appengine/downloads.html">here</a>. The latest version at this moment is version 1.2.1, released on May 13, 2009. </p>
<p>After the download is finished, we need to copy appengine-java-sdk-1.2.1/lib/user/appengine-api-1.0-sdk-1.2.1.jar to Sinatra Application’s lib directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>appengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>appengine-api-<span style="color: #000000;">1.0</span>-sdk-1.2.1.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Also, we need to copy jruby-rack jars to lib directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby-rack<span style="color: #000000; font-weight: bold;">/</span>target<span style="color: #000000; font-weight: bold;">/</span>jruby-rack-0.9.5-SNAPSHOT.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Next, we need to copy jruby itself in lib directory, and split it into a two files because the original jruby-complete.jar is too big to use in GAE.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>juby~main<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jruby-complete.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Then, create a shellscript called split-jar.sh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-core.jar
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> ruby-stdlib.jar
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> tmp_unpack
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> tmp_unpack
<span style="color: #7a0874; font-weight: bold;">cd</span> tmp_unpack
jar xf ..<span style="color: #000000; font-weight: bold;">/</span>jruby-complete.jar
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> jruby-core
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>org jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>com jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jline jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jay jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jruby jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> jruby-core
jar cf ..<span style="color: #000000; font-weight: bold;">/</span>jruby-core.jar .
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>tmp_unpack
jar cf ..<span style="color: #000000; font-weight: bold;">/</span>ruby-stdlib.jar .
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-core
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> tmp_unpack
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-complete.jar</pre></div></div>

<p>And run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> split-jar.sh</pre></div></div>

<p>Try “ls” to see that you have “jruby-core.jar” and “jruby-stdlib.jar” instead of “jruby-complete.jar”.</p>
<p>Now it is time to create “war” files with warbler.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jrruby –S warble</pre></div></div>

<p>Run at localhost.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>appgengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dev_appserver.sh <span style="color: #660033;">--port</span>=<span style="color: #000000;">18080</span> war</pre></div></div>

<p>If you have no error, open <a href="http://localhost:18080/">http://localhost:18080/</a> with your own browser. you will see the messages.</p>
<h2>Deployment</h2>
<p>You need to overwrite APPLICATION-ID with your own in appengine-web.xml. When finished, create war files again as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jrruby –S warble</pre></div></div>

<p>Then running deployment script</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>appgengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>appcfg.sh update war</pre></div></div>

<p>If you run this script first time, you will be prompted to input your email address and password. Input your email of your GAE account correctly. After a while, the script will be finished, and you can see your Sinatra/GAE apps at <a href="http://{YOUR-APPLICATION-ID}.appspot.com">http://{YOUR-APPLICATION-ID}.appspot.com</a>.</p>
<p>&#160;</p>
<p>This is all. Enjoy making Ruby web application on GAE!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
