Thursday June 18, 2009
TOTD #85: Getting Started with Django Applications on GlassFish v3
GlassFish v3 is an extensible App server. Basically the core App server
functionality can be easily extended using add-ons such as an OSGi
module. This allows to keep the core light-weight and install the
required features on demand. The add-ons can be easily installed using
the Update
Center. The what/why/how about extensibility is described in
the GlassFish
v3 Extensibility One-pager.
GlassFish v3 provides support for Dynamic Languages and Web Frameworks
such as Ruby-on-Rails, Groovy/Grails, and Python/Django using this
extensibility. This blog has published multiple tips on using
Ruby-on-Rails at rubyonrails+totd
and a few tips on Groovy/Grails at grails+totd.
This blog will explain how to get started with deploying Python/Django
applications on GlassFish
v3 Preview. The blog will use Jython interpreter
which is the Java implemention of Python.
Vivek already blogged about the detailed
instructions and this blog shows how to run the pre-bundled
samples.
| java -jar ~/Downloads/jython_installer-2.5.0.jar |

| alias
jython25=~/tools/jython2.5.0/bin/jython alias django-admin-jy="jython25 ~/tools/jython2.5.0/bin/django-admin.py" |
| ~/tools/jython/jython2.5rc4 >jython25 Jython 2.5rc4 (Release_2_5rc4:6470, Jun 8 2009, 13:23:16) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_13 Type "help", "copyright", "credits" or "license" for more information. >>> |
| ~/tools >tar xzvf
~/Downloads/Django-1.0.2-final.tar.gz Django-1.0.2-final/ Django-1.0.2-final/AUTHORS Django-1.0.2-final/django/ . . . Django-1.0.2-final/scripts/rpm-install.sh Django-1.0.2-final/setup.cfg Django-1.0.2-final/setup.py ~/tools/Django-1.0.2-final >jython25 setup.py install running install running build running build_py . . . running install_egg_info Writing /Users/arungupta/tools/jython/jython2.5.0/Lib/site-packages/Django-1.0.2_final-py2.5.egg-info |
| ~/tools/glassfish/v3/preview/glassfishv3/bin >./updatetool |

| ~/tools/glassfish/v3/preview/glassfishv3/glassfish >./bin/asadmin start-domain |
| ~/tools/glassfish/v3/preview/glassfishv3/glassfish
>./bin/asadmin
create-jvm-options -Djython.home=/Users/arungupta/tools/jython2.5.0
created 1 option(s) Command create-jvm-options executed successfully. |
| ~/tools/Django-1.0.2-final/examples >~/tools/glassfish/v3/preview/glassfishv3/glassfish/bin/asadmin
deploy . Command deploy executed successfully. |



| ~/tools/Django-1.0.2-final/examples >jython25 manage.py runserver Validating models... 0 errors found Django version 1.0.2 final, using settings 'examples.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. |

Posted by Arun Gupta in web2.0 | Comments[3]
|
|
|
|
|
Tuesday June 16, 2009
TOTD #84: Using Apache + mod_proxy_balancer to load balance Ruby-on-Rails running on GlassFish
TOTD
#81 explained how to install/configure nginx for
load-balancing/front-ending a cluster of Rails application running on GlassFish
Gem. Another popular approach in the Rails community is to
use Apache HTTPD
+ mod_proxy_balancer.
A user asked the exact details of this
setup on the GlassFish
Gem Forum. This Tip
Of The Day (TOTD) will
clearly explain the steps.
| LoadModule proxy_balancer_module libexec/apache2/mod_proxy_balancer.so |
| <Proxy balancer://glassfishgem> BalancerMember http://localhost:3000 BalancerMember http://localhost:3001 BalancerMember http://localhost:3002 </Proxy> |
| ProxyPass / balancer://glassfishgem/ CustomLog /var/log/glassfishgem.log/apache_access_log combined |
| CustomLog /var/log/glassfishgem.log/apache_access_log combined |
| ~/tools/jruby/rails/runner >../../bin/jruby -S glassfish -e
production -c myapp Starting GlassFish server at: 10.0.177.178:3000 in production environment... Writing log messages to: /Users/arungupta/tools/jruby-1.3.0/rails/runner/log/production.log. Press Ctrl+C to stop. . . . ~/tools/jruby/rails/runner >../../bin/jruby -S glassfish -e production -c myapp -p 3001 Starting GlassFish server at: 10.0.177.178:3001 in production environment... Writing log messages to: /Users/arungupta/tools/jruby-1.3.0/rails/runner/log/production.log. Press Ctrl+C to stop. . . . ~/tools/jruby/rails/runner >../../bin/jruby -S glassfish -e production -c myapp -p 3002 Starting GlassFish server at: 10.0.177.178:3002 in production environment... Writing log messages to: /Users/arungupta/tools/jruby-1.3.0/rails/runner/log/production.log. Press Ctrl+C to stop. |
| ProxyPass /myapp/
balancer://glassfishgem/myapp/ |
| LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{BALANCER_WORKER_NAME}e\"" custom |
| CustomLog /var/log/glassfishgem.com/apache_access_log custom |
| ::1 - - [17/Jun/2009:10:53:53 -0700] "GET /runlogs
HTTP/1.1" 304 - "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5;
en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11"
"http://localhost:3002" ::1 - - [17/Jun/2009:10:54:04 -0700] "GET /runlogs HTTP/1.1" 200 621 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11" "http://localhost:3000" ::1 - - [17/Jun/2009:10:54:05 -0700] "GET /runlogs HTTP/1.1" 304 - "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11" "http://localhost:3001" |
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Thursday May 21, 2009
TOTD #83: Eclipse Tools Bundle for GlassFish 1.0 - Now Available!
The GlassFish
Tools Bundle for Eclipse 1.0 is now available.

An earlier
blog entry explains how to get started using this bundle.
If you used an earlier version (0.99.x) of this bundle, then an upgrade
is not supported. However backwards compatibility will be maintained
going forward!
Here are some pointers to get you started:
Posted by Arun Gupta in General | Comments[3]
|
|
|
|
|
Tuesday May 19, 2009
TOTD #82: Getting Started with Servlet 3.0 and EJB 3.1 in Java EE 6 using NetBeans 6.7
EJB 3.1 (JSR
318) and Servlet 3.0 (JSR 315)
are the two new JSRs in Java EE 6 (JSR 316).
The EJB 3.1 specification provides multiple new features such as WAR
packaging, Optional
Local Business Interfaces, EJB.lite, Portable
Global JNDI Names, Singleton
Session Beans
(Container-managed and Bean-managed concurrency), Application
Initialization and Shutdown events, Timer Service enhancements,
Simple/Light-weight Asynchrony, and many other features defined in the specification.
The
Servlet 3.0 specification is an update to Servlet 2.5 and focuses on
ease-of-use. It also adds several new features such as "web.xml"
free
deployment (mostly), Dynamic Registration of
servlets/filters,
Pluggability
of frameworks using "web-fragment.xml", Asynchronous API,
Security
enhancements (Constraints via annotations, programmatic
container authentication and logout), and several other miscellaneous
additions like default error page, file upload, etc.
GlassFish v3
provides the most complete implementation of EJB 3.1 and Servlet 3.0
along with other Java EE 6 specifications. This Tip Of The Day (TOTD) will show
how to create a simple EJB and invoke it from a Servlet, all in a
deployment-descriptor free way.



| public String
sayHello(String name) { return "Hello " + name; } |
| package server; import javax.ejb.Stateless; /** * @author arungupta */ @Stateless public class HelloEJB { public String sayHello(String name) { return "Hello " + name; } } |
| @WebServlet(urlPatterns="/hello") |
| extends HttpServlet |
| @EJB HelloEJB ejbClient; |
| @Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); res.getOutputStream().print("<h1>Hosted at: " + req.getContextPath() + "</h1>"); res.getOutputStream().print("<h2>" + ejbClient.sayHello("Duke") + "</h2>"); } |
| package server; import java.io.IOException; import javax.ejb.EJB; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author arungupta */ @WebServlet(urlPatterns="/hello") public class HelloServlet extends HttpServlet { @EJB HelloEJB ejbClient; @Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html"); res.getOutputStream().print("<h1>Hosted at: " + req.getContextPath() + "</h1>"); res.getOutputStream().print("<h2>" + ejbClient.sayHello("Duke") + "</h2>"); } } |


Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Thursday April 30, 2009
TOTD #81: How to use nginx to load balance a cluster of GlassFish Gem ?
![]() |
nginx (pronounced as "engine-ex") is an open-source and high-performance HTTP server. It provides the common features such as reverse proxying with caching, load balancing, modular architecture using filters (gzipping, chunked responses, etc), virtual servers, flexible configuration and much more. |
| ~/tools
> curl -L -O http://sysoev.ru/nginx/nginx-0.6.36.tar.gz ~/tools > tar -xzf nginx-0.6.36.tar.gz ~/tools > curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz ~/tools > tar -xzf pcre-7.7.tar.gz ~/tools/nginx-0.6.36 > ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7 ~/tools/nginx-0.6.36 > make ~/tools/nginx-0.6.36 > sudo make install ~/tools/nginx-0.6.36 > which nginx /usr/sbin/nginx |

| ~/samples/jruby >~/tools/jruby/bin/jruby -S rails
runner ~/samples/jruby/runner >~/tools/jruby/bin/jruby script/generate scaffold runlog miles:float minutes:integer ~/samples/jruby/runner >sed s/'adapter: sqlite3'/'adapter: jdbcsqlite3'/ <config/database.yml >config/database.yml.new ~/samples/jruby/runner >mv config/database.yml.new config/database.yml ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S rake db:migrate |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3001 Starting GlassFish server at: 192.168.1.145:3001 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3002 Starting GlassFish server at: 192.168.1.145:3002 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| upstream
glassfish { server 127.0.0.1:3000; server 127.0.0.1:3001; server 127.0.0.1:3002; } |

| proxy_pass http://glassfish; |

| sudo
kill -15 `cat /usr/local/nginx/logs/nginx.pid` sudo nginx |

| log_format
main '$remote_addr - [$upstream_addr]
$remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:27:57 -0700] GET
/runlogs/ HTTP/1.1 "200" 3689 "-" "Mozilla/5.0 (Macintosh;
U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like
Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:27:57 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3002] - [29/Apr/2009:15:27:57 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:28:53 -0700] GET /runlogs/ HTTP/1.1 "200" 3689 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1"
"-" 127.0.0.1 - [127.0.0.1:3002, 127.0.0.1:3000] - [29/Apr/2009:15:28:53 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:28:53 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
Posted by Arun Gupta in web2.0 | Comments[6]
|
|
|
|
|
Wednesday April 29, 2009
TOTD #80: Sinatra CRUD application using Haml templates with JRuby and GlassFish Gem
TOTD
#79 showed how to run a trivial Sinatra
application using GlassFish
Gem. Sinatra
provides support for Haml,
Erb,
Builder,
Sass,
and Inline templates as described here.
This TOTD will show how to get started with creating a Sinatra CRUD
application using Haml templates.
![]() |
Haml is based on one primary principle - Markup should be beautiful
because beauty makes
you faster. Get started by installing the Haml gem as:
And follow the tutorial, documentation, and reference page for more details. |
| ~/tools/jruby/samples/sinatra-sample >mysql --user root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 664 Server version: 5.1.30 MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database hello_development; Query OK, 1 row affected (0.00 sec) mysql> use hello_development; Database changed mysql> CREATE TABLE `runners` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `distance` float, `minutes` int(11), `created_at` datetime, `updated_at` datetime); Query OK, 0 rows affected (0.06 sec) |
| require 'rubygems' require 'sinatra' require 'activerecord' ## Setup ActiveRecord::Base.establish_connection( :adapter => "jdbcmysql", :host => "localhost", :username => "root", :password => "", :database => "hello_development" ) ## Models class Runner < ActiveRecord::Base end ## Controller Actions get '/hi' do "Hello World!" end get '/' do @runner = Runner.find(:all) haml :index end get '/new' do haml :new end get '/:id' do @runner = Runner.find(params[:id]) if (@runner) haml :show else redirect '/' end end post '/' do @runner = Runner.new(:distance => params[:distance], :minutes => params[:minutes]) if @runner.save redirect "/#{@runner.id}" else redirect '/' end end |
| %h1 Listing all runners ... %table %tr %th Distance %th Minutes - @runner.each do |r| %tr %td= r.distance %td= r.minutes %br %a{:href=>"/new"} New Runner |
| %h1 Adding a new runner log ... %form{:method=>"post", :action=>"/"} Distance: %input{:type=>"text", :name=>"distance"} %br Minutes: %input{:type=>"text", :name=>"minutes"} %br %input{:type=>"submit", :value=>"Submit"} %br |
| %h1 Showing a runner log ... Distance: = @runner.distance %br Minutes: = @runner.minutes %br %br %a{:href=>"/"}= "Show All!" |
| . ./hello.rb ./views ./views/index.haml ./views/new.haml ./views/show.haml |
| ~/tools/jruby/samples/sinatra-sample >../../bin/jruby -S glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |





Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Tuesday April 28, 2009
TOTD #79: Getting Started with Sinatra applications on JRuby and GlassFish Gem
![]() |
Sinatra
is a DSL for quickly creating web-applications in Ruby with minimal
effort. Like Rails and Merb, Sinatra is not an MVC framework and
basically follows a flat-file structure instead. The framework define
conventions such as location of static files and
views, bootstrap, dev/production/test environment variables, filters,
helpers, TDD, and much more. Read Getting Started
for complete details. Even though Sinatra is not a MVC framework but sinatra-gen
may be used to generate new Sinatra projects. GlassFish Gem can easily run Rails, Merb, Sinatra, and any other Ruby framework applications based upon Rack. TOTD #70 shows how to run Rails applications and TOTD #53 shows to run Merb applications. This TOTD will explain how to run a trivial Sinatra application. A later blog will describe how to plug a generic Rack-based framework. |
| ~/tools/jruby >./bin/jruby -S gem install
sinatra JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed sinatra-0.9.1.1 1 gem installed Installing ri documentation for sinatra-0.9.1.1... Installing RDoc documentation for sinatra-0.9.1.1... |
| require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end |
| ~/tools/jruby/samples/sinatra-sample
>../../bin/jruby
-S glassfish Log file /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log does not exist. Creating a new one... Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |

Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Wednesday April 08, 2009
TOTD #78: GlassFish, EclipseLink, and MySQL efficient pagination using LIMIT
EclipseLink
JPA replaces TopLink
Essentials as the JPA implementation in GlassFish v3. One
of the benefits of using EclipseLink is that it provides efficient
pagination support for the MySQL database by generating
native SQL statements such as "SELECT ... FROM <table>
LIMIT <offset>, <rowcount>".
The MySQL LIMIT clause definition
says:
The
LIMIT clause can be used to constrain the number of rows returned by
the SELECT statement. LIMIT takes one or two numeric arguments, which
must both be non-negative integer constants (except when using prepared
statements).
With two arguments, the
first argument specifies
the offset of the first row to return, and the second specifies the
maximum number of rows to return. The offset of the initial row is 0
(not 1):
SELECT * FROM tbl LIMIT
5,10; # Retrieve rows 6-15
So instead of fetching all rows from the database and then filtering
from row 6-15, only rows 6 through 15 are fetched.
This TOTD (Tip
Of The Day) explains how to
create a JPA Persistence Unit for sakila
(MySQL sample database) using NetBeans,
use EclipseLink as the Persistence Provider, and then write a JPA query
to leverage the pagination support - all on GlassFish v3.

| <properties> <property name="eclipselink.logging.level" value="FINE"/> </properties> |
| ./asadmin create-jdbc-connection-pool
--datasourceclassname
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --property
user=duke:password=glassfish:ServerName=localhost:portNumber=3306:databaseName=sakila
jdbc-mysql-pool |
| ./asadmin create-jdbc-resource --connectionpoolid jdbc-mysql-pool jndi/sakila |
| @PersistenceUnit EntityManagerFactory emf; |
|
EntityManager em = emf.createEntityManager(); response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { int startRow = Integer.valueOf(request.getParameter("start_row")); int howMany = Integer.valueOf(request.getParameter("how_many")); Query q = em.createNamedQuery("Film.findAll"); q.setFirstResult(startRow); q.setMaxResults(startRow + howMany); for (Object film : q.getResultList()) { out.print(((Film)film).toString() + "<br/>"); } } finally { out.close(); } |

| [#|2009-04-07T14:01:12.815-0700|FINE|glassfish|org.eclipse.persistence.session.file:
/Users/arungupta/tools/glassfish/v3/b43/glassfishv3/glassfish/domains/domain1/applications/Pagination/WEB-INF/classes/-PaginationPU.sql|
_ThreadID=15;_ThreadName=Thread-1;ClassName=null;MethodName=null;|SELECT
film_id AS film_id1, special_features AS special_features2, last_update
AS last_update3, rental_duration AS rental_duration4, release_year AS
release_year5, title AS title6, description AS description7,
replacement_cost AS replacement_cost8, length AS length9, rating AS
rating10, rental_rate AS rental_rate11, language_id AS language_id12,
original_language_id AS original_language_id13 FROM film LIMIT ?, ? bind => [1, 11]|#] |
| [#|2009-04-07T17:00:34.210-0700|FINE|glassfish|org.eclipse.persistence.session.file: /Users/arungupta/tools/glassfish/v3/b43/glassfishv3/glassfish/domains/domain1/applications/Pagination/WEB-INF/classes/-PaginationPU.sql| _ThreadID=15;_ThreadName=Thread-1;ClassName=null;MethodName=null;|SELECT film_id, special_features, last_update, rental_duration, release_year, title, description, replacement_cost, length, rating, rental_rate, language_id, original_language_id FROM film|#] |
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Friday April 03, 2009
TOTD # 77: Running Seam examples with GlassFish
![]() |
Seam is a full-stack solution to assemble complex web applications using simple annotated classes, a rich set of UI components, and very little XML. It integrates Ajax and Business Process Modeling with several Java EE technologies such as Java Server Faces (JSF), Java Persistence API (JPA), and Enterprise Java Beans (EJB 3.0). |
| ~/tools/jboss-seam-2.1.1.GA/examples/jpa >ant glassfish Buildfile: build.xml glassfish: initcopy: initpoms: [echo] Setting up dependencies [mkdir] Created dir: /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms [copy] Copying 1 file to /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms [artifact:install] [INFO] Installing /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms/root.pom to . . . . . . init.war: war: [copy] Copying 27 files to /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/exploded-archives-glassfish/jboss-seam-jpa.war [copy] Copying 7 files to /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/exploded-archives-glassfish/jboss-seam-jpa.war/WEB-INF/lib noejb.war: [copy] Copying 18 files to /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/exploded-archives-glassfish/jboss-seam-jpa.war/WEB-INF/lib [copy] Copying 2 files to /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/exploded-archives-glassfish/jboss-seam-jpa.war [copy] Copying 4 files to /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/exploded-archives-glassfish/jboss-seam-jpa.war distributable.war: noejb.archive: [jar] Building jar: /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jpa/dist-glassfish/jboss-seam-jpa.war BUILD SUCCESSFUL Total time: 5 seconds |
| ~/tools/jboss-seam-2.1.1.GA/examples/jpa >~/tools/glassfish/v2.1/glassfish/bin/asadmin
deploy dist-glassfish/jboss-seam-jpa.war Command deploy executed successfully. |



| ~/tools/jboss-seam-2.1.1.GA/examples/hibernate
>ant glassfish Buildfile: build.xml glassfish: initcopy: initpoms: [echo] Setting up dependencies [copy] Copying 1 file to /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms [artifact:install] [INFO] Installing /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms/root.pom to /Users/arungupta/.m2/repository/org/jboss/seam/root/2.1.1.GA/root-2.1.1.GA.pom . . . distributable.war: noejb.archive: [jar] Building jar: /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/hibernate/dist-glassfish/jboss-seam-hibernate.war BUILD SUCCESSFUL Total time: 6 seconds |
| ~/tools/jboss-seam-2.1.1.GA/examples/hibernate
>~/tools/glassfish/v2.1/glassfish/bin/asadmin
deploy dist-glassfish/jboss-seam-hibernate.war Command deploy executed successfully. |
| ~/tools/jboss-seam-2.1.1.GA/examples/jee5/booking
>ant Buildfile: build.xml initcopy: initpoms: [echo] Setting up dependencies [copy] Copying 1 file to /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms [artifact:install] [INFO] Installing /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms/root.pom to /Users/arungupta/.m2/repository/org/jboss/seam/root/2.1.1.GA/root-2.1.1.GA.pom [copy] Copying 1 file to /Users/arungupta/tools/jboss-seam-2.1.1.GA/classes/poms . . . archive: [jar] Building jar: /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jee5/booking/dist/jboss-seam-jee5-booking.jar [jar] Building jar: /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jee5/booking/dist/jboss-seam-jee5-booking.war [jar] Building jar: /Users/arungupta/tools/jboss-seam-2.1.1.GA/examples/jee5/booking/dist/jboss-seam-jee5-booking.ear BUILD SUCCESSFUL Total time: 5 seconds ~/tools/jboss-seam-2.1.1.GA/examples/jee5/booking >~/tools/glassfish/v2.1/glassfish/bin/asadmin deploy dist/jboss-seam-jee5-booking.ear Command deploy executed successfully. |
Posted by Arun Gupta in Finance | Comments[6]
|
|
|
|
|
Friday March 20, 2009
Oh, what a week for the JRuby, Rails, and GlassFish enthusiasts!
JRuby
1.2, Rails
2.3, GlassFish
Gem 0.9.3, and ActiveRecord
JDBC Adapater 0.9.1 - all released earlier this week. This is
an
opportune moment to run the integration
tests to ensure the latest
JRuby and GlassFish versions work nicely with each other.
First, lets see whats there to get exicted in each release.
JRuby 1.2 introduces a new versioning scheme by jumping from 1.1.6
-> 1.2. JRUBY-3649 is an important fix for the Windows users.
Improved
Ruby 1.9 support, 3-6x faster parsing, and preliminary android support
are some other
highlights. 1052 revisions and
256 bugfixes since 1.1.6 (89 days ago) means close to 12 revisions /
day and 3 bugfixes/day!
Rails 2.3 has a bunch of highlights ranging from Rack integration,
nested forms,
attributes,
and transactions,
reconnecting
lost MySQL connections, Application
controller renamed (make sure to "rake
rails:update:action_controller" to update from an older version), faster
boot time in dev mode using lazy loading, and many others.
The Release
Notes provide all the detailed information.
The GlassFish Gem with features like running as daemon,
rake-style configuration of JVM options, ability to "sudo
install" gem and run as normal user and multi-level logging are all
gearing
towards adding more production-quality features. My favorite here is
running as
daemon since that brings the Gem one step closer to the Rails community.
Lets get back to running our tests #1,
#2,
#3,
#4,
and #5
for these released versions.
First, lets unzip JRuby
1.2 and install Rails 2.3, GlassFish Gem 0.9.3, and other
gems as:
| ~/tools/jruby-1.2.0 >./bin/jruby -S gem install rails
glassfish activerecord-jdbcmysql-adapter JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed activesupport-2.3.2 Successfully installed activerecord-2.3.2 Successfully installed actionpack-2.3.2 Successfully installed actionmailer-2.3.2 Successfully installed activeresource-2.3.2 Successfully installed rails-2.3.2 Successfully installed rack-0.9.1 Successfully installed glassfish-0.9.3-universal-java Successfully installed activerecord-jdbc-adapter-0.9.1 Successfully installed jdbc-mysql-5.0.4 Successfully installed activerecord-jdbcmysql-adapter-0.9.1 11 gems installed Installing ri documentation for activesupport-2.3.2... Installing ri documentation for activerecord-2.3.2... Installing ri documentation for actionpack-2.3.2... Installing ri documentation for actionmailer-2.3.2... Installing ri documentation for activeresource-2.3.2... Installing ri documentation for rack-0.9.1... Installing ri documentation for glassfish-0.9.3-universal-java... Installing ri documentation for activerecord-jdbc-adapter-0.9.1... Installing ri documentation for jdbc-mysql-5.0.4... Installing ri documentation for activerecord-jdbcmysql-adapter-0.9.1... Installing RDoc documentation for activesupport-2.3.2... Installing RDoc documentation for activerecord-2.3.2... Installing RDoc documentation for actionpack-2.3.2... Installing RDoc documentation for actionmailer-2.3.2... Installing RDoc documentation for activeresource-2.3.2... Installing RDoc documentation for rack-0.9.1... Installing RDoc documentation for glassfish-0.9.3-universal-java... Installing RDoc documentation for activerecord-jdbc-adapter-0.9.1... Installing RDoc documentation for jdbc-mysql-5.0.4... Installing RDoc documentation for activerecord-jdbcmysql-adapter-0.9.1... |
| ~/tools/jruby-1.1.6 >./bin/jruby -S gem update
glassfish JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating installed gems Updating glassfish Successfully installed glassfish-0.9.3-universal-java Gems updated: glassfish |
| ~/tools/jruby-1.1.6 >./bin/jruby -S gem update
activerecord JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Updating installed gems Updating activerecord-jdbc-adapter Successfully installed activerecord-jdbc-adapter-0.9.1 Updating activerecord-jdbcmysql-adapter Successfully installed activerecord-jdbcmysql-adapter-0.9.1 Updating activerecord-jdbcsqlite3-adapter Successfully installed jdbc-sqlite3-3.6.3.054 Successfully installed activerecord-jdbcsqlite3-adapter-0.9.1 Updating merb_activerecord Successfully installed merb_activerecord-1.0.0.1 Gems updated: activerecord-jdbc-adapter, activerecord-jdbcmysql-adapter, jdbc-sqlite3, activerecord-jdbcsqlite3-adapter, merb_activerecord |
| ~/tools/jruby-1.2.0 >./bin/jruby -S gem install
activerecord-jdbcsqlite3-adapter JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed jdbc-sqlite3-3.6.3.054 Successfully installed activerecord-jdbcsqlite3-adapter-0.9.1 2 gems installed Installing ri documentation for jdbc-sqlite3-3.6.3.054... Installing ri documentation for activerecord-jdbcsqlite3-adapter-0.9.1... Installing RDoc documentation for jdbc-sqlite3-3.6.3.054... Installing RDoc documentation for activerecord-jdbcsqlite3-adapter-0.9.1... |
| ~/tools/jruby-1.2.0/samples/rails
>../../bin/jruby -S rails runner create create app/controllers create app/helpers . . . create log/production.log create log/development.log create log/test.log |
| development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 |
| development: adapter: jdbcsqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 |
| ActionController::Base.session_store = :active_record_store |
| config.webxml.jruby.session_store = 'db' |
| if defined?(JRUBY_VERSION) # hack to fix jruby-rack's incompatibility with rails edge module ActionController module Session class JavaServletStore def initialize(app, options={}); end def call(env); end end end end end |
| Test # | Description | Status |
| #1 | Simple Scaffold using GlassFish Gem | PASS (with workaround in JRUBY-3502) |
| #2 | Simple Scaffold using GlassFish v3 Prelude | PASS |
| #3 | Simple Scaffold using GlassFish v3 | FAIL (used workaround mentioned in JRUBY-3502, issues #7266, #7270, #7271 still need to be fixed). PASS if the Application and Controller name are different. |
| #4 | Simple Scaffold as WAR-based application on GlassFish v2.1 | FAIL (issue #7385), PASS (with workaround in issue JRUBY-3515) |
| #5 | Redmine using GlassFish Gem | PASS |
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Wednesday March 18, 2009
TOTD #75: Getting Started with Grails using GlassFish v3 Embedded
For a change, this blog entry is talking about something that exists
for a while now :)
Basically, I wanted to setup a demo environment for Grails and GlassFish
v3 Prelude on my machine and so decided to dcument the steps
along the process. More detailed steps with explanation are available
on GlassFish/Grails
Getting Started Wiki.
| ~/demos/glassfishv3-prelude >./bin/updatetool The software needed for this command (updatetool) is not installed. If you choose to install Update Tool, your system will be automatically configured to periodically check for software updates. If you would like to configure the tool to not check for updates, you can override the default behavior via the tool's Preferences facility. When this tool interacts with package repositories, some system information such as your system's IP address and operating system type and version is sent to the repository server. For more information please see: http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2 Once installation is complete you may re-run this command. Would you like to install Update Tool now (y/n): y Install image: /Users/arungupta/demos/glassfishv3-prelude/bin/.. Installing pkg packages. Installing: [pkg:/pkg@1.0.7,0-15.1269:20081008T212532Z, pkg:/python2.4-minimal@2.4.5.0,0-15.1269:20081008T212544Z] Installing updatetool packages. Installing: [pkg:/updatetool@2.0.0,0-15.1269:20081008T212613Z, pkg:/wxpython2.8-minimal@2.8.8,0-15.1269:20081008T212630Z] Registering notifier: Already registered. Initialization complete. Software successfully installed. You may now re-run this command (updatetool). |

| ~/demos/glassfishv3-prelude/glassfish/grails
>export
GRAILS_HOME=~/demos/glassfishv3-prelude/glassfish/grails ~/demos/glassfishv3-prelude/glassfish/grails >export PATH=$GRAILS_HOME/bin:$PATH |
| ~/demos/glassfishv3-prelude/glassfish/grails/samples
>grails create-app
bookstore Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples Note: No plugin scripts found Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateApp.groovy Environment set to development [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src/java [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/src/groovy [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/controllers [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/services [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/domain [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/taglib [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/utils [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views/layouts [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/i18n [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/unit [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/scripts [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/js [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/css [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/images [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/META-INF [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/lib [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf/spring [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/conf/hibernate [propertyfile] Creating new property file: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/application.properties [copy] Copying 2 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [copy] Copied 1 empty directory to 1 empty directory under /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [copy] Copying 2 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/WEB-INF [copy] Copying 5 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/WEB-INF/tld [copy] Copying 28 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app [copy] Copying 18 files to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore [propertyfile] Updating property file: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/application.properties Created Grails Application at /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore |
| ~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
>grails
create-domain-class book Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore Note: No plugin scripts found Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateDomainClass.groovy Environment set to development [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/domain Created Domain Class for Book [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration Created Tests for Book |
| class Book { String title String author } |
| ~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
>grails
create-controller Book Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore Note: No plugin scripts found Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/CreateController.groovy Environment set to development [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/controllers Created Controller for Book [mkdir] Created dir: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/views/book [copy] Copying 1 file to /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/test/integration Created ControllerTests for Book |
| class BookController { def scaffold = Book } |
| ~/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore
>grails run-app Welcome to Grails 1.0.4 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails Base Directory: /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore Note: No plugin scripts found Running script /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/scripts/RunApp.groovy Environment set to development Starting GlassFish embedded server... [mkdir] Created dir: /Users/arungupta/.grails/1.0.4/projects/bookstore/classes [groovyc] Compiling 8 source files to /Users/arungupta/.grails/1.0.4/projects/bookstore/classes [mkdir] Created dir: /Users/arungupta/.grails/1.0.4/projects/bookstore/resources/grails-app/i18n [native2ascii] Converting 11 files from /Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/grails-app/i18n to /Users/arungupta/.grails/1.0.4/projects/bookstore/resources/grails-app/i18n [copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore/classes [copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore/resources [copy] Copying 1 file to /Users/arungupta/.grails/1.0.4/projects/bookstore Running Grails application.. Application name : bookstore Web App Root :/Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app web.xml:/Users/arungupta/.grails/1.0.4/projects/bookstore/resources/web.xml Mar 18, 2009 10:19:09 PM CommonClassLoaderManager Skipping creation of CommonClassLoader as there are no libraries available INFO: urls = [] no resource bundle found for version, using default GlassFish version Mar 18, 2009 10:19:09 PM AppServerStartup run INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started Mar 18, 2009 10:19:09 PM com.sun.enterprise.v3.services.impl.GrizzlyProxy start INFO: Listening on port 8080 Mar 18, 2009 10:19:10 PM org.glassfish.admin.mbeanserver.ConnectorStartupService$ConnectorsStarterThread startConnector INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://192.168.1.145:8686/jmxrmi Mar 18, 2009 10:19:10 PM com.sun.enterprise.v3.admin.adapter.AdminEndpointDecider setGuiContextRoot INFO: Admin Console Adapter: context root: /admin Mar 18, 2009 10:19:10 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: GlassFish v3 Prelude startup time : Embedded(418ms) startup services(887ms) total(1305ms) Mar 18, 2009 10:19:10 PM com.sun.enterprise.web.WebContainer createHttpListener INFO: Created HTTP listener http-listener-1 on port 8080 Mar 18, 2009 10:19:10 PM com.sun.enterprise.web.WebContainer createHosts INFO: Created virtual server server Mar 18, 2009 10:19:11 PM org.apache.catalina.loader.WebappLoader setClassPath INFO: Unknown loader org.glassfish.grails.MaskingClassLoader@3b948e75 class org.glassfish.grails.MaskingClassLoader Mar 18, 2009 10:19:12 PM org.apache.catalina.loader.WebappLoader setClassPath INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@191fa2af class org.glassfish.internal.api.DelegatingClassLoader Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Set web app root system property: 'bookstore-development-0.1' = [/Users/arungupta/demos/glassfishv3-prelude/glassfish/grails/samples/bookstore/web-app/] Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing log4j from [file:/Users/arungupta/.grails/1.0.4/projects/bookstore/resources/log4j.properties] Mar 18, 2009 10:19:12 PM org.apache.catalina.core.ApplicationContext log INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing Spring root WebApplicationContext [0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506: display name [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506]; startup date [Wed Mar 18 22:19:14 PDT 2009]; parent: org.springframework.web.context.support.XmlWebApplicationContext@6ceb51a8 [0] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@430b4506]: org.springframework.beans.factory.support.DefaultListableBeanFactory@1f43243e Mar 18, 2009 10:19:17 PM org.apache.catalina.core.ApplicationContext log INFO: PWC1412: WebModule[/bookstore] ServletContext.log():Initializing Spring FrameworkServlet 'grails' Mar 18, 2009 10:19:17 PM com.sun.enterprise.web.WebApplication start INFO: Loading application bookstore at /bookstore Server running. Browse to http://localhost:8080/bookstore |





Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Monday March 16, 2009
TOTD
#70, #71,
#72,
#73
shows four integration tests that can ensure
that the
latest JRuby and GlassFish versions work nicely with each other.
#70
showed how to create a trivial Rails application and run it using GlassFish
Gem. #71
showed how the same application can be deployed on GlassFish
v3 Prelude. #72
showed how to deploy the same application on GlassFish v3. #73
showed how to deploy a Rails application as WAR file and use the JDBC
connection pooling framework available in GlassFish.
The next set of tests ensure that some commonly used open source Rails
applications can be easily run using this setup. The first one is
Redmine - 0.8 is the stable release now. Redmine was first tried on
GlassFish a
few months ago. The steps have simplified since then :)
Lets begin integration test #5.
| /samples/jruby/redmine >svn co
http://redmine.rubyforge.org/svn/branches/0.8-stable redmine-0.8 A redmine-0.8/test A redmine-0.8/test/unit A redmine-0.8/test/unit/document_test.rb A redmine-0.8/test/unit/token_test.rb . . . A redmine-0.8/public/stylesheets/scm.css A redmine-0.8/public/stylesheets/application.css A redmine-0.8/public/favicon.ico U redmine-0.8 Checked out revision 2580. |
| ~/samples/jruby/redmine/redmine-0.8 >../jruby-1.2.0RC2/bin/jruby -S
rake db:create (in /Users/arungupta/samples/jruby/redmine/redmine-0.8) ~/samples/jruby/redmine/redmine-0.8 >../jruby-1.2.0RC2/bin/jruby -S rake db:migrate (in /Users/arungupta/samples/jruby/redmine/redmine-0.8) == 1 Setup: migrating ========================================================= -- create_table("attachments", {:force=>true}) -> 0.0880s -- create_table("auth_sources", {:force=>true}) -> 0.1430s . . . == 100 AddChangesetsUserId: migrating ========================================= -- add_column(:changesets, :user_id, :integer, {:default=>nil}) -> 0.0980s == 100 AddChangesetsUserId: migrated (0.0990s) ================================ == 101 PopulateChangesetsUserId: migrating ==================================== == 101 PopulateChangesetsUserId: migrated (0.0030s) =========================== |
| ~/samples/jruby/redmine/redmine-0.8 >../jruby-1.2.0RC2/bin/jruby -S
glassfish Mar 13, 2009 11:14:59 AM com.sun.enterprise.glassfish.bootstrap.ASMainStatic findDerbyClient INFO: Cannot find javadb client jar file, jdbc driver not available Mar 13, 2009 11:14:59 AM APIClassLoaderService createAPIClassLoader INFO: APIClassLoader = java.net.URLClassLoader@59fb8de1 . . . Mar 13, 2009 11:15:10 AM com.sun.grizzly.pool.DynamicPool$1 run INFO: New instance created in 10,175 milliseconds Mar 13, 2009 11:15:10 AM com.sun.enterprise.v3.server.AppServerStartup run INFO: GlassFish v3 startup time : Static(356ms) startup services(11456ms) total(11812ms) |







Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Wednesday March 11, 2009
TOTD
#70, #71,
#72
shows the first three integration tests that I typically run to ensure
that the
latest JRuby and GlassFish versions work nicely with each other.
#70
showed how to create a trivial Rails application and run it using GlassFish
Gem. #71
showed how the same application can be deployed on GlassFish
v3 Prelude. #72
showed how to deploy the same application on GlassFish v3.
The next test in the series is to ensure WAR-based deployment of a
Rails application continue to work on GlassFish v2. It also shows that
JNDI database connection pooling also work as expected. The latest
publicly
available build is GlassFish
v2.1.
Lets begin integration test #4.
| ~/tools/jruby-1.2.0RC2/samples/rails/runner
>../../../bin/jruby
-S gem install warbler JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed warbler-0.9.12 1 gem installed Installing ri documentation for warbler-0.9.12... Installing RDoc documentation for warbler-0.9.12... |
| production: adapter: mysql encoding: utf8 database: runner_production pool: 5 username: root password: socket: /tmp/mysql.sock |
| production: adapter: jdbcmysql encoding: utf8 database: runner_production pool: 5 username: duke password: glassfish socket: /tmp/mysql.sock jndi: jdbc/runner_production driver: com.mysql.jdbc.Driver |
| ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby -S rake
db:create RAILS_ENV=production (in /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner) ~/tools/jruby-1.2.0RC1/samples/rails/runner >../../../bin/jruby -S rake db:migrate RAILS_ENV=production (in /Users/arungupta/tools/jruby-1.2.0RC1/samples/rails/runner) == CreateRunners: migrating ================================================== -- create_table(:runners) -> 0.1150s -> 0 rows == CreateRunners: migrated (0.1170s) ========================================= |
| ~/tools/glassfish/v2.1/glassfish/ >cp ~/tools/mysql-connector-java-5.1.6/mysql-connector-java-5.1.6-bin.jar ./lib |
| ~/tools/glassfish/v2.1/glassfish/bin
>./asadmin
start-domain Starting Domain domain1, please wait. Default Log location is /Users/arungupta/tools/glassfish/v2.1/glassfish/domains/domain1/logs/server.log. Redirecting output to /Users/arungupta/tools/glassfish/v2.1/glassfish/domains/domain1/logs/server.log Domain domain1 started. Domain [domain1] is running [Sun GlassFish Enterprise Server v2.1 (9.1.1) (build b60e-fcs)] with its configuration and logs at: [/Users/arungupta/tools/glassfish/v2.1/glassfish/domains]. Admin Console is available at [http://localhost:4848]. Use the same port [4848] for "asadmin" commands. User web applications are available at these URLs: [http://localhost:8080 https://localhost:8181 ]. Following web-contexts are available: [/web1 /__wstx-services runner ]. Standard JMX Clients (like JConsole) can connect to JMXServiceURL: [service:jmx:rmi:///jndi/rmi://Macintosh-187.local:8686/jmxrmi] for domain management purposes. Domain listens on at least following ports for connections: [8080 8181 4848 3700 3820 3920 8686 ]. Domain supports application server clusters and other standalone instances. |
| ~/tools/glassfish/v2.1/glassfish/bin >./asadmin
create-jdbc-connection-pool --datasourceclassname
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype
javax.sql.DataSource --property
"User=duke:Password=glassfish:URL=jdbc\:mysql\://localhost/runner_production"
jdbc/runner_pool Command create-jdbc-connection-pool executed successfully. |
| ~/tools/glassfish/v2.1/glassfish/bin >./asadmin create-jdbc-resource
--connectionpoolid jdbc/runner_pool jdbc/runner_production Command create-jdbc-resource executed successfully. |
| ~/tools/jruby-1.2.0RC2/samples/rails/runner >../../../bin/jruby -S warble
config cp /Users/arungupta/tools/jruby-1.2.0RC2/lib/ruby/gems/1.8/gems/warbler-0.9.12/generators/warble/templates/warble.rb config/warble.rb |
| # Include all gems which are used by the
web application require "#{RAILS_ROOT}/config/environment" BUILD_GEMS = %w(warbler rake rcov) for gem in Gem.loaded_specs.values next if BUILD_GEMS.include?(gem.name) config.gems[gem.name] = gem.version.version end |
| config.gems += ["activerecord-jdbc-adapter"] |
| ~/tools/jruby-1.2.0RC2/samples/rails/runner >../../../bin/jruby -S warble mkdir -p tmp/war/WEB-INF/gems/specifications cp /Users/arungupta/tools/jruby-1.2.0RC2/lib/ruby/gems/1.8/specifications/rails-2.2.2.gemspec tmp/war/WEB-INF/gems/specifications/rails-2.2.2.gemspec mkdir -p tmp/war/WEB-INF/gems/gems . . . cp public/javascripts/prototype.js tmp/war/javascripts/prototype.js cp public/stylesheets/scaffold.css tmp/war/stylesheets/scaffold.css mkdir -p tmp/war/WEB-INF |
| ~/tools/jruby-1.2.0RC2/samples/rails/runner >~/tools/glassfish/v2.1/glassfish/bin/asadmin
deploy runner.war Command deploy executed successfully. |

Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Monday March 09, 2009
TOTD # 72: JRuby and GlassFish Integration Test #3: JRuby 1.2.0 RC2 + Rails 2.2.x + GlassFish v3
TOTD
#70 and #71
shows the first two integration tests that I typically run to ensure
that the
latest JRuby and GlassFish versions work nicely with each other.
#70
showed how to create a trivial Rails application and run it using GlassFish
Gem. #71
showed how the same application can be deployed on GlassFish
v3 Prelude.
The third test (explained in this blog) ensures that the
same
application can be easily deployed using GlassFish
v3. GlassFish v3 will be available later this year with full
support for Java EE 6.
JRuby 1.2.0 RC2 is now released. Test
#1 passed, Test
#2 gives the following error:
| Caused by: java.lang.NumberFormatException: For input
string: "0RC2" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:456) at java.lang.Integer.parseInt(Integer.java:497) at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:137) at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:131) at com.sun.grizzly.jruby.RailsAdapter.<init>(RailsAdapter.java:110) at com.sun.grizzly.jruby.RubyRuntime.<init>(RubyRuntime.java:48) ... 22 more |

| ~/tools/glassfish/v3/b39/glassfishv3/glassfish
>./bin/asadmin
start-domain Name of the domain started: [domain1] and its location: [/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/domains/domain1]. Admin port for the domain: [4848]. |
| ~/tools/glassfish/v3/b39/glassfishv3/glassfish
>./bin/asadmin
create-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC2" created 1 option(s) Command create-jvm-options executed successfully. |
| ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
deploy runner Command deploy executed successfully. |
| ActionController::RoutingError (No route matches
"s" with {:method=>:get}): /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/recognition_optimisation.rb:66:in `recognize_path' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:386:in `recognize' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:182:in `handle_request' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi' /Users/arungupta/tools/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch' file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/adapter/rails.rb:82:in `serve_rails' file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/adapter/rails.rb:109:in `call' file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/jruby/rack/rails.rb:81:in `call' file:/Users/arungupta/tools/glassfish/v3/b39/glassfishv3/glassfish/modules/grizzly-jruby.jar!/rack/handler/grizzly.rb:55:in `call' :1 |
| ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
deploy --contextroot runlog --force=true runner Command deploy executed successfully. |
| ~/tools/jruby-1.2.0RC2/samples/rails >~/tools/glassfish/v3/b39/glassfishv3/bin/asadmin
deploy runlog Command deploy executed successfully. |

Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Thursday March 05, 2009
TOTD
#70 shows the first integration integration tests
that I typically run to ensure
that the
latest JRuby and GlassFish versions work nicely with each other.
The second test (explained in this blog) ensures that the
same
application can be deployed using GlassFish
v3 Prelude.
GlassFish v3 Prelude allows Rails applications to be
deployed natively, i.e. without any packaging.
Lets begin integration test #2.
| ~/tools/glassfish/v3/glassfishv3-prelude/glassfish
>./bin/asadmin
start-domain Name of the domain started: [domain1] and its location: [/Users/arungupta/tools/glassfish/v3/glassfishv3-prelude/glassfish/domains/domain1]. Admin port for the domain: [4848]. |
| ~/tools/glassfish/v3/glassfishv3-prelude/glassfish
>./bin/asadmin
create-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC1" created 1 option(s) Command create-jvm-options executed successfully. |
| ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin
deploy runner Command deploy executed successfully. |
| Caused by: java.lang.NumberFormatException: For
input string: "0RC1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:456) at java.lang.Integer.parseInt(Integer.java:497) at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:137) at com.sun.grizzly.jruby.RailsAdapter$JRubyVersion.<init>(RailsAdapter.java:131) at com.sun.grizzly.jruby.RailsAdapter.<init>(RailsAdapter.java:110) at com.sun.grizzly.jruby.RubyRuntime.<init>(RubyRuntime.java:48) ... 30 more |
| ~/workspaces >svn co
http://svn.codehaus.org/jruby/trunk/jruby/ A jruby/bench A jruby/bench/bench_tak.rb A jruby/bench/bench_struct.rb . . . A jruby/.settings/org.eclipse.jdt.core.prefs A jruby/.settings/org.eclipse.jdt.ui.prefs U jruby Checked out revision 9347. ~/workspaces >cd jruby/ ~/workspaces/jruby >ant Buildfile: build.xml init: jar: . . . _update_scm_revision_: [jar] Building jar: /Users/arungupta/workspaces/jruby/lib/jruby.jar [jar] Warning: selected jar files include a META-INF/INDEX.LIST which will be replaced by a newly generated one. BUILD SUCCESSFUL Total time: 1 minute 21 seconds |
| ~/workspaces/jruby >./bin/jruby gem install rails JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed rake-0.8.4 Successfully installed activesupport-2.2.2 Successfully installed activerecord-2.2.2 Successfully installed actionpack-2.2.2 Successfully installed actionmailer-2.2.2 Successfully installed activeresource-2.2.2 Successfully installed rails-2.2.2 7 gems installed Installing ri documentation for rake-0.8.4... Installing ri documentation for activesupport-2.2.2... Installing ri documentation for activerecord-2.2.2... Installing ri documentation for actionpack-2.2.2... Installing ri documentation for actionmailer-2.2.2... Installing ri documentation for activeresource-2.2.2... Installing RDoc documentation for rake-0.8.4... Installing RDoc documentation for activesupport-2.2.2... Installing RDoc documentation for activerecord-2.2.2... Installing RDoc documentation for actionpack-2.2.2... Installing RDoc documentation for actionmailer-2.2.2... Installing RDoc documentation for activeresource-2.2.2... |
| ~/tools/glassfish/v3/glassfishv3-prelude/glassfish
>./bin/asadmin
delete-jvm-options -DJRUBY_HOME="/Users/arungupta/tools/jruby-1.2.0RC1" deleted 1 option(s) Command delete-jvm-options executed successfully. |
| ~/tools/glassfish/v3/glassfishv3-prelude/glassfish
>./bin/asadmin
create-jvm-options -DJRUBY_HOME="/Users/arungupta/workspaces/jruby" created 1 option(s) Command create-jvm-options executed successfully. |
| ~/tools/jruby-1.2.0RC1/samples/rails >~/tools/glassfish/v3/glassfishv3-prelude/bin/asadmin
deploy --force=true runner Command deploy executed successfully. |
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Today's Page Hits: 169
Total # blog entries: 931