Showing posts with label JRuby. Show all posts
Showing posts with label JRuby. Show all posts

Saturday, February 05, 2011

Dynamic Languages on the JVM... Growth or Demise

TIOBE Index January 2011
Like most of you I saw the TIOBE Index this week. Java still holds the top slot, but the press is grinding out our slow inevitable demise.  My question to them is what language is replacing Java? I am not going to be such a zealot to assume that some day, hopefully in the distant future, Java will become COBOL. That day is not here.

One of the interesting observations was around dynamic languages. There was an overall decline, or stasis in dynamic languages. The exception being Python. My interest though is not in general languages like Python, or Ruby, but in their JVM compatible equivalents: Jython and JRuby. The press seems to group them in the "general" demise along with everything else.

I don't agree.

JRuby just released 1.6.0 RC1 on January 10th, 2011 and it will match pace with its parent Ruby when released. Jython has a new release candidate too: RC3 from January 11th, 2011.

I guess it is like a bumble bee, nobody told it: "You can't fly!" So it goes about its merry business like these projects. Nobody told them them of their imminent demise.

I believe that the decline of dynamic languages is real EXCEPT on the JVM. JRuby combined with Java has real staying power. It combines the ease of use in Ruby with the power and multitude of frameworks available in Java. I see growth here not decline.

It will be very interesting when JDK 7 is released later this year. The completion of JSR-292 Supporting Dynamic Languages on the JVM (InvokeDynamic) will breathe a new life into dynamic languages. If you are interested, it is already available. Just download OpenJDK to try it out.

Those are my thoughts. What are yours?
Enhanced by Zemanta

Sunday, September 12, 2010

JRuby and Rails 3

Rails 3.0 has been released. I know a number of you are excited about all of the possibilities. Along with the release of Rails is a new point release of JRuby.  So the big question is how do you use them together.

The default Rails environment uses SQLite as the database. Let me show you how to get started.
Riding on JRuby on Rails

  1. Start by downloading JRuby, and install it.
  2. Once it is installed you will want to install jruby-openssl.
    jruby -S gem install jruby-openssl
  3. Next lets install the SQLite database gems.
    jruby -S gem install jdbc-sqlite3 activerecord-jdbc-adapter \
    activerecord-jdbcsqlite3-adapter

  4. Once we have installed the gems for SQLite, we can install Rails.
    jruby -S gem install rails mongrel warbler
  5. Now that Rails is installed, we can create our example application. This will create our application.
    jruby -S rails new blog
  6. Next we replace the following line in the Gemfile

    gem 'sqlite3-ruby', :require => 'sqlite3'

    with the following:

    if defined?(JRUBY_VERSION)
    gem 'jdbc-sqlite3'
    gem 'activerecord-jdbc-adapter'
    gem 'activerecord-jdbcsqlite3-adapter'
    gem 'jruby-openssl'
    gem 'jruby-rack'
    gem 'warbler'
    else
    gem 'sqlite3-ruby', :require => 'sqlite3'
    end

    This allows us to run the application in JRuby, or Ruby.
  7. Next we need to modify the config/database.yml file.

    # SQLite version 3.x
    # gem install sqlite3-ruby (not necessary on OS X Leopard)
    development:
    adapter: jdbcsqlite3
    database: db/development.sqlite3
    pool: 5
    timeout: 5000

    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
    adapter: jdbcsqlite3
    database: db/test.sqlite3
    pool: 5
    timeout: 5000

    production:
    adapter: jdbcsqlite3
    database: db/production.sqlite3
    pool: 5
    timeout: 5000

  8. Next we need to migrate the database.
    jruby -S rake db:migrate
  9. Finally we can start our new Rails 3 application.
    jruby -S rails server
That's it. You are riding on Rails in 9 steps.

References:


Enhanced by Zemanta

Friday, August 20, 2010

Why Movable Type, Drupal, or Wordpress on GlassFish?

WordPress





The question of relevance has come up on why would you implement Movable Type, Drupal, or Wordpress on GlassFish. Is it because you can?

The answer is one of technology fundamentals and implementation strategies. I am a Java developer (if you could not figure that out from the blog title). I have access to GlassFish which I use for all of my web based application deployments. I want to be able to simplify my administration requirements by using a unified deployment platform. I also want to be able to combine the extensive libraries and frameworks that are available for Java. I want a simple intuitive administration console to handle most of my day-to-day needs. I want administration, and deployment to be scriptable. GlassFish solves a number of these issues, along with using Java, and Java based implementations of some popular languages like JRuby, and Jython.

First, GlassFish versions 2 and 3 are the reference implementations for Java Enterprise Editions (EE) 5 and 6 respectively. If you are doing enterprise software development, and want to use the latest reference versions, you should use GlassFish. I often write about Java Enterprise Edition (EE). I try to focus on the core technology since this keeps it compatible across other EE containers should you choose to move it to another container. GlassFish version 3 has made a number of positive steps in JEE 6 to make it easier to use. The new profiles in GlassFish make it easier to do web development.

Apache web server is very powerful. There is no question about that, but installing modules, and configuring it is not simple. If a module is not available in one of the pre-configured and installed versions on your system, you must compile it yourself. I am a very competent Apache administrator, and I have never had a simple download, and compile deployment. Let me contrast that with GlassFish, if you have Java 6 installed on your system, download and run it. If you are using JRuby, or Jython, GlassFish can handle it right out  of the box. In the case of JRuby, there have been a number of performance tests to show JRuby on Glassfish is faster that Ruby on WEBrick, or Mongrel. The Common Gateway Interface (CGI) servlet will allow you to take advantage of additional CGI technologies with simple configuration on a server wide basis, or on a per application basis.

Apache Web Server and GlassFish can take advantage of a number of frameworks. Apache Web Server can run Ruby applications with the appropriate module. However, it can not take advantage of other independent frameworks. Java on GlassFish allows Ruby developers to use Java frameworks like Swing within their applications. You can even create polyglot applications which use JRuby, Jython, and Clojure. This may be possible  with Apache Web Server, but I am unaware of it. This is a comment point for readers.

Simple and Intuitive administrative interface. That describes GlassFish administration console to a tee. I would even include elegant, and beautiful.

GlassFish Administration Console

Glassfish includes a very complete command-line interface. Anything you can do on the GUI based interface, you can do from the command-line. It also includes a number of advanced features which are not available in the adminstrative GUI.

Finally, as I noted above it has multiple configuration points with languages and technologies including Microsoft technologies.

I have found that GlassFish handles all of my Web based needs in a single platform. This combination of technology and integration points makes it easy to install relevant best of breed software like Drupal, Movable Type, or Redmine on the same platform and integrate functionality between them as necessary. It is very nice to have Redmine and Hudson CI running on the same platform. Combine it with Mercurial, and share a common SSO. This is not done easily on Apache Web Server, or any other platform.

I hope this clarifies my position on its relevance with Movable Type, Drupal, Wordpress, etc.

Thursday, February 25, 2010

Book Review - NetBeans Ruby and Rails IDE with JRuby


I decided to write a quick review on the NetBeans Ruby and Rails IDE with JRuby book from Apress. The book is focused on NetBeans 6.5 and JRuby development. This is not a limitation on the book however. The book is really an introduction to how to use NetBeans to do Ruby development. The latest version of NetBeans (6.8) has a number of additional features (enhancements) over the version detailed in this book. Perhaps the authors can do an up-to-date version of the book to cover the latest enhancements. If not, perhaps I will consider taking up the mantle.

I really loved the book. I would give it 4/5 stars which if you have read my reviews is a brutal rating to get.

I performed a baseline install of NetBeans 6.5 including the plugins required for doing JRuby/Ruby development as noted in the book. The book follows along perfectly with the installer and IDE. I guess you could call this book the reference to the IDE for JRuby/Ruby development.

The first chapter details the installation and configuration of the IDE. The explanation is spot on, but NetBeans is also really to install and configure.

The second chapter covers your basic "Hello World" from both a basic JRuby project and from JRuby on Rails (JRoR).

The third chapter covers configuration of JRuby using the NetBeans gem manager, setting up servers, and configuring databases for use with the development environment. The section on gems with native extensions, and replacements is very helpful.

Chapters four and five cover Ruby and Rails projects in more detail. It demonstrates a number of the capabilities that the IDE.  I really like the Rails Console and example of how to use it.

Chapter six covers editing files and the capabilities that the IDE provides including code completion. This was the first real mainstream IDE to provide JRuby/Ruby code completion. It does it beautifully.

Chapter seven covers debugging and testing. The authors do a great job of explaining why NetBeans should be your choice of IDE for doing Ruby development.

JRuby itself is the topic of chapter eight. There is an example of how to use JRuby in Java projects. This is really cool. However, it should be noted that you need to make some changes for it to work on JSE5. This is noted on Page 136, but the code needs a slight modification to use JRubyScriptEngineManager instead of ScriptEngineManager.

Chapter nine covers Ruby on Rails (RoR) deployments using warbler. I have found warbler to be a great  tool and use it extensively to deploy applications to GlassFish v 2.x.

Chapter ten is all about the IDE. It shows the user a number of customizations available to make NetBeans customized to your style.  This is no small accomplishment. The NetBeans team have made a really great IDE and made it extremely flexible. This flexibility did not sacrifice simplicity. Eclipse is flexible too, but a a severe penalty to ease.

In summary, if you are thinking of trying JRuby, or Ruby development, and you want to give NetBeans a try, this is the book to buy 4/5 stars.

Errata

There is not much to report. My only real gripe is that the Mac short-cut keys are incorrect in a number of places. However, you will figure it out immediately. If it says <cmd> and it does not work... try <ctrl>.

(Page 43)  Item #2 refers to a diagram which is not correct. The diagram which it refers to is not in the book.

(Page 133) The diagram JVM arguments are incorrect. The correct argument is listed under the input box as part of the inline help.

Tuesday, February 23, 2010

Book Review - GlassFish Administration

I was offered the opportunity to review the GlassFish Administration book by Xuekun Kou from Packt Publishing. The book focuses on GlassFish version 2.1.1, but does have some coverage of version 3 (V3). The book is a smaller digest of a number of books published by Oracle (Sun) and the GlassFish document team.

The book breaks down into ten chapters on version 2.1.1, and an eleventh chapter on version 3. I am not sure where I stand on this book. I really don't like references to certain features in the table of contents which would lead you to believe it has some depth on the subject. Later you discover that it refers you to the actual "official" publications I noted above. I think that if you give it a sub-chapter designation, it must actually have some depth. I really found the book to cover most of the subjects in a shallow manner.

My other pet peeve is when code is included (or not included) in a book which does not work, or is shallowly offered without explanation. For example, there is a code example for security, but no explanation, or setup instructions. The other issue is where the book refers to the code, but it does not exist in the format in the book. There are numerous examples of this as you will note below.

If you have gotten this far in my review, you must wonder if the book has any redeeming value. Yes, it does. As an experienced GlassFish administrator, there are a lot of topics that are covered in too little detail for me, but as a new administrator, the book is a good starting place. I was expecting more advanced coverage of some topics, but this is material for a book on Advanced GlassFish Administration. This book offers would be GlassFish administrators a look into all the functionality that it offers.

I would give it a 3/5 stars for advanced administrators. This book is a very good book for starting administrators which probably should be 3.5/5 stars.

Chapter Summaries

Chapter one covers the basic installation which is no real surprise. The information is essentially the same as found on the GlassFish project web site. There is a nice section on how to do silent installs which is not really covered on the site.

Chapter two is a high-level overview of the server architecture. This is where the book shines. The information and illustrations are great. The author has done a great job covering the architecture with very good explanations.

The third chapter provides the reader with information on the application deployment capabilities of GlassFish. The explanation on the ease of development functionality is very good. It covers items like dynamic reload and command-line deployment options. This is a good introduction to the CLI portion of GlassFish which makes it easy to script for your particular OS. This chapter also includes installing JRuby and Grails based applications. The Grails example is really cool and worked like a champion.

The fourth chapter covers container configuration and basic services. I believe that the section on configuring HTTP listeners should have been covered prior to virtual servers because of the dependency. This chapter is very shallow. It shows you how to configure these services from both the Admin Console and CLI, but gives really nothing in way of explanation of the options available.

The fourth chapter concludes with a confusing explanation of the Application Client Container. It seems very out of place and should be re-written with a code example.

Chapter five discusses how to configure (JNDI) resources within GlassFish. This is a very important topic. The author does a good job of explaining how to configure the various resources from JDBC to external JNDI resources. There are not too many good examples on how to configure external resources. There are a number of command-line example errors, but fortunately GlassFish really does a great job of making correction suggestions.

Chapter six covers JMS specifically Open MQ and Apache ActiveMQ. It is really well done and covers an import aspect of modern application servers. The asynchronous transaction is becoming more important especially when combined with AJAX technologies which allow web applications to continue to respond to user input while actions are occurring in the background. This chapter also covers the imqadmin console.

One of the best aspects of chapter six is its coverage of Apache ActiveMQ. I prefer to use Open MQ (included in GlassFish), but the chapter shows how to integrate external JMS resources into GlassFish. GlassFish includes a generic JMS JCA adapter which is used to integrate Apache ActiveMQ.

Chapter seven covers security and securing GlassFish. I was disappointed that there were no examples of client certificate authentication. I was also disappointed that the only coverage on certificates was based on self-signed, and there was absolutely no coverage of NSS security. The Java ACC support is incomplete especially without an example. The only really redeeming section in the chapter was the use of password aliases fro encrypting application resources.

Monitoring is covered in chapter eight. The basics of how to setup the monitoring are covered. There is no significant depth to the chapter. The discussion on call flow monitoring shows an example of an application which is not included in the sample code. It is from the Java EE tutorial (Duke's Bank). The chapter does topically demonstrate additional monitoring tools like JConsole and VisualVM. Both of these tools are included in the JDK, and don't get the coverage they deserve. VisualVM is a NetBeans platform application.

The chapter closes with Enterprise Manager, but refers you to external references. I was not impressed. It should have not even made mention of it, if there was no coverage.

Clustering and High Availability (HA) is covered in chapter nine. I liked chapter nine in general. The explanation of the clustering functionality: node agents, and instances was very good. The author explains in detail how to install the load balancer which needed some detail coverage. The information available online is not very centralized. The explanation on in-memory replication including diagrams is very good. It also explains replication ring and some issues with that are encountered on adjacent instance failures.

HADB should be removed from chapter nine. There is no coverage worth mentioning, and it should have been a cornerstone of the chapter.

Chapter ten covers troubleshooting and performance tuning. Actually that is the title, but it really does not cover performance tuning. The reference is to a commercial support contract Performance Advisor.

That being said, it does cover some additional functionality of tools like VisualVM and introduces jstack. It also covers the Thread Dump Analyzer (TDA) and NetBeans profiler.

Chapter eleven is a topical coverage of GlassFish version 3. It was not finalized at the time of release of this book. The information is generally correct though and will give the reader important aspects of the new release and its capabilities.

Summary

The overall impression of the book was a modest 3/5 stars. The book would be a good starting point for a new administrator, but lacks sufficient detail for an advanced practitioner. If you are looking for a beginning book on GlassFish administration, this is not a bad choice.


Chapter Details and Errata

These are notes, errors, comments, and impressions from the chapters. I suggest that if you encounter any errors in the book, please check here to see if I have addressed them.

Chapter 1

(Page 13) The MaxOS X support should include 10.6.

(Page 22) There should be a note to indicate that silent installs can only be done on file based installs (installer), and not on jar based installs.

Chapter 2

(Page 42) Second paragraph makes mention that you can edit the domain.xml file using a text editor. There should be a warning/note that tells the user should check the domain.xml file using the asadmin command to ensure that the file is syntactically correct.
asadmin verify-domain-xml
(Page 46) Item #4, third paragraph refers to a screen shot which is not present.

(Page 47) The command at the bottom of the page is missing a dash.
asadmin list-commands --help | more
(Page 48) The create-domain code is interactive since not all of the parameters are provided so the example is not correct. If you want to avoid interactively providing user and password information, use the --user XXX and --passwordfile XXX syntax.

(Page 49) The command for starting the newly created domain is incorrect. It includes command line switches that are not valid.
asadmin start-domain domain2

Chapter 3

(Page 58) The redeploy switch is not available on version 2.1.1. It is a GlassFish version 3 switch.

(Page 64) The POJO Web Services refers to code which is not available in the example downloads.

(Page 64) The enterprise example and client code is also missing from the example download code. This is a really too bad. The code would have made a really good example of how to use GlassFish.

(Page 67) I could not get this JRuby example running on GlassFish. It runs in Mongrel, and I believe it is valid code. The issue seems to be with rack and warble. It also should be noted that the MySQL JDBC drivers must be downloaded and installed in the CLASSPATH for this to work. I placed the MySQL drivers in the JRuby installation /lib directory. The rake db:migrate command will not work without them, nor will Mongrel connect to the database.

(Page 69) The PATH is incorrect. It should be
export PATH=$GRAILS_HOME/bin:$PATH

Chapter 4

(Page 75) The CLI example is incorrect. It should be:
asadmin set server.session-config.session-properties.timeout-in-seconds=900
(Page 85, 86, and 87) The 2nd and 3rd paragraphs are duplicated on the following pages.

Chapter 5

(Page 100) The CLI example is incorrect. It should be:
asadmin create-jdbc-resource --connectionpoolid MySQLPool jdbc/DevDS
(Page 104) The CLI example is incorrect. It should be:
asadmin create-javamail-resource --mailhost localhost --mailuser MailUser --fromaddress service@programming-stuff.com mail/MyMail
(Page 108) The CLI example is incorrect. It should be:
asadmin create-jndi-resource --jndilookupname cn=MyResources --restype com.programmingstuff.jndi.RegistryResource --factoryclass com.sun.jndi.ldap.LdapCtxFactory ref/SimpleResource

Chapter 6

The example code for the chapter does not work very well. There is no explanation of how to configure it to work. The included AMQBean code does not work out of the box.

Chapter 7

(Page 140) The LDIF file should have been included in the example code.

Chapter 8

(Page 164) The example is incomplete. The first of two screens is shown, and the discussion does not cover the second (more important) configuration screen.

Chapter 9

(Page 176) Clustering DOES work on Mac OS X.

Chapter 11

(Page 245) The paths in the commands are incorrect, they should be:
$examples/deploy ...
(Page 247, 248,250) The paths and project name are incorrect in the last CLI example on the page. It should be:
cd $examples/deploy/SimpleRails

(Page 250) The second CLI example is incorrect. The command to start embedded GlassFish is:
jruby -S glassfish SimpleRails
(Page 251) The path should be:
$examples/deploy/SimpleGroovy

Wednesday, August 26, 2009

Redmine 0.8.4 Deployment on GlassFish 2.1 using JRuby 1.3.1

Introduction

In this tutorial I will explain how to install Redmine 0.8.4 on GlassFish 2.1 using JRuby 1.3.1 with MySQL.

Required Software

  • Redmine 0.8.4

  • GlassFish 2.1

  • NetBeans 6.7

  • MySQL 5.1

Instructions


  1. First we will need to download and install JRuby 1.3.1. The binaries can be found on the Kenai site.

  2. Make sure that your PATH is set to point to your JRuby installation. You can check your install by typing jruby -v at the command prompt. You should see something similar to the listing below.
    dev:~ jyeary$ jruby -v
    jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]

  3. Run from the command line
    jruby -S gem update
    This will update all of the gems required to run our application.

  4. Run from the command line
    jruby -S gem install jruby-openssl rails mongrel jdbc-mysql activerecord-jdbcmysql-adapter warbler
    This will install all of the gems required to run our application.

  5. Download a copy of Redmine 0.8.4 and unzip it.

  6. Using NetBeans 6.7.1, check the Tools --> Ruby Platform Manager to make sure that you install the JRuby 1.3.1 platform.



  7. In NetBeans, create a new Ruby on Rails Application with Existing Sources. Next



  8. Select the unzipped RoR Redmine application as the project folder.

  9. Select the JRuby 1.3.1 Platform from the combo-box menu.

  10. Select Mongrel for the server from the combo-box menu. Click Finish. NetBeans will create the RoR project and install Warbler which will create our war file for deployment on GlassFish.



  11. We are now ready to configure the application. Follow the instructions for configuring the application here.

  12. In the redmine-0.8.4 directory run the following command
    jruby -S warble config
    This will create the configuration file for warbler to build our war file for deployment on GlassFish.

  13. Edit the warble.rb file and modify the config.dirs line to the following:
    config.dirs = %w(app config lib log vendor tmp files lang)
    This will make sure that we deploy all of the application relevant files in our war file.

  14. Edit the warble.rb file and add the following line:
    config.gems = ["activerecord-jdbcmysql-adapter"]
    This will make sure that when we convert the application to a war file that the appropriate ActiveRecord JDBC drivers for MySQL are added to it.

  15. Run the application to make sure that it runs correctly on Mongrel.

  16. Run the following commands to create the war file
    jruby -S rake war:clean
    jruby -S rake war



  17. Go to the Administrative Console on GlassFish. Select Web Applications and deploy the new redmine-0.8.4.war file.




Friday, February 06, 2009

Book Review: Pro Netbeans IDE 6 Rich Client Platform Edition

Disclaimer: Adam Myatt and I have been on the JavaOne 2008 and 2009 Tools and Languages Review Committee. I don't believe that there is any predjudice for/against the book, but in the interest of disclosure I thought it important to mention. Don't you wish politicians had that much honesty?

I had the pleasure of reading the Pro NetBeans IDE 6 Rich Client Platform Edition book by Adam Myatt. I had read it a while ago, but I did not have the time to do a review on it. The book is sixteen chapters long, and covers a variety of topics from download and installation to developing rich client applications. The book covers version 6/6.1 of NetBeans, but there is significant applicability to version 6.5 to make it worth purchasing.

The book has a primary target of new users to the NetBeans IDE. It is designed to take you from novice user to power user in a systematic organized way. The book is sufficiently modular that you can choose to read individual modules, or go from cover to cover. The chapters stand on their own so that you do not need to worry about missing something in a previous chapter if you decide to browse.

Based on the easy reading style and effectiveness of communicating complex topics, I would give the book (4/5) stars.

Chapter 1:
Downloading, Installing, and Customizing NetBeans

This chapter covers the basics of installation, and explains a number of options available for configuration.

Chapter 2:
The Source Editor

Here we cover the basics of the source code editor and its windows. It also covers some interesting features of the source editor like the error stripe and annotation glyphs. The error stripe allows the user to go directly to any errors which are in the code. The annotation glyph provides the user with suggestions. These may be as simple as reminding you to mark @Override on an overridden method.

One of the best discussions in the chapter has to do with built-in and custom macros you can create to simplify coding tasks. This was a great explanation of how it works.

Chapter 3:
Code Completion and Templates

Code completion is what makes an IDE so valuable. This chapter covers the NetBeans code completion technology in detail.

It also covers code templates which are a boon to any developer who learns to use them. Adam really explains this in a manner that makes them easy to learn and use.

Chapter 4:
Debugging

I thought I was fairly sophisticated in my use of debugging. This chapter made me feel inadequate. After reading it and implementing some of the ideas, I feel I am back to being an expert.

Note: I found one error on page 95. The third paragraph has Run --> Run File -->Run Debug Evaluate Expression. It should be Run --> Run File --> Run to Cursor.

I would buy the book for this chapter alone.


Chapter 5:
Profiling

This chapter covers profiling for performance. Sun and NetBeans has spent a lot of time creating this technology (like DTrace), instrumenting, and providing tools. It is a shame that they really have not promoted these capabilities to the developer community.

Adam has spent a lot of time detailing profiling and providing great examples to get you into it. His explanations may be enough to encourage developers to use these really great tools.

This chapter also includes how to profile remote JVMs and application servers. It is a really slick explanation and demo.

Chapter 6:
Managing Version Control

This chapter covers version control system implementations in NetBeans. It covers CVS and Subversion. Since the book was written, the Subversion implementaion has had numerous improvements. NetBeans 6.1 and 6.5 also include support for Mercurial.

Chapter 7:
Generating and Accessing Javadoc

This chapter covers Javadocs and tools in the IDE to make Javadocs easier to create. I must admit I thought they were already easy, but there are some features to make it even easier including code completion.

Chapter 8:
Managing Builds with Ant and Maven

This covers Apache Ant and Maven implementations in NetBeans. Adam covers some of the features of Ant with a high degree of skill. He covers the NetBeans implementation very well.

The section on Maven is a weak spot in the book. In fairness, the version of NetBeans which the book was based on had poor Maven capabilites. Version 6.5 of NetBeans has much better tools for handling Maven.

Chapter 9:
JUnit Testing

This chapter covers JUnit testing. This is another chapter that is a little to weak. NetBeans 6.0, 6.1, and 6.5 have some really great implementations for doing JUnit testing. This chapter does not do it justice.

Chapter 10:
Refactoring

This chapter covers refactoring. NetBeans has some really great refactoring tools.

JetBrains IntelliJ IDEA is the gold standard for refactoring, but each generation of NetBeans brings it one step closer.

There are some comprehensive explanations of how to use the refactoring tools in NetBeans. If you want to master the IDE, this chapter, and chapters 4, and 11 are a must.

Chapter 11:
Code Quality Tools

This chapter covers some of the really great plugins that are available for NetBeans including: Checkstyle, PMD, and SQE (FindBugs). If you are not using these static analysis tools in your code, you are doing yourself and customers a disservice. This chapter covers the tools in enough detail to get your interest. These plugins are in constant development, and you should check the latest versions and updates out.

These tools will make your code much better. You as a developer need to understand why. When Checkstyle marks code as a "Magic Number", you need to read the explanation. Understanding the why will help you to avoid these problems in your future code.

Chapter 12:
Developing JRuby/Ruby on Rails Applications

This chapter covers developing JRuby, and Ruby-on-Rails (RoR) applications using NetBeans. The chapter is not designed to teach you to program in Ruby, but to show you what features are available in the IDE. The NetBeans support for Ruby is fantastic. A number of other IDE developers are trying to emulate the functionality. I think that most Ruby developers will find that the support is a quantum leap in terms of ease and functionality over more traditional tools.

There is a note on page 297 which explains a really neat feature. If an existing application is deployed using Webrick, or Mongrel on port 3000, the IDE will increment the port number to prevent port in use errors.

Chapter 13:
Developing Web Applications

This is a long chapter covering web application development. The first part of the chapter covers the functionality of the IDE in terms of what features it provides. This includes items like the Javascript and CSS editors. Both of these tools are really useful.

The Javascript editor and debugger have been vastly improved in NetBeans 6.5.

The CSS editor with a change viewer make designing, or changing a CSS file a snap.

The chapter also covers the application server features and HTTP monitor. Specifically it covers Apache Tomcat and GlassFish. It explains how to add additional servers like JBoss, or Websphere to allow those server deployments.

The second half of the chapter covers web application development frameworks. The section covers Struts, Struts 2, Visual Java Server Faces (JSF) (Project Woodstock), and JMaki.

The Struts and Struts 2 section is relatively small. It provides the user with the basics of how to create and use Struts based projects.

The section on Visual JSF development is extensive and makes the book worth purchasing. The explanation on how to get started will set you on the right path. The section on visual data binding is elegant and simple. It also covers the Visual Database Query Editor. This functionality has been updated in NetBeans 6.5, but the explanation here still applies.

Note: Visual JavaServerFaces (JSF) development in NetBeans has been frozen. The promise of Project Woodstock in a version 4.3 release and beyond has been abandoned officially by Sun. The current supported version is 4.2. It will continued to be supported by the NetBeans team for the foreseeable future. The push by Sun is to provide support using third party providers of JSF components. The best of these providers is ICEFaces. They have a really great set of components, and have provided a transition plan for Project Woodstock developers.

The section on JMaki is too brief to really provide a great explanation of this great technology.

Chapter 14:
Developing Web Services: JAX-WS, SOA, BPEL, and RESTful

This chapter covers JAX-WS, SOA, BPEL, and RESTful services. These projects have undergone extensive updates which makes the information here slightly dated. The basic procedures are the same, but there are better tools in NetBeans 6.5.

Chapter 15:
Developing GUI Applications

This chapter covers GUI application development. It is the best aggregation on the subject I have seen. There are a number of tutorials on the NetBeans site, and some good explanations of the features, but this is the best explanation I have seen. There is a great tutorial example of how to use the various components of the IDE to do visual Swing development. I was impressed and learned some new things too.

There is a section on the Swing Application Framework (JSR-296) which is the best I have seen. This technology is supposed to make Swing development easier. I used the information in here to create an enterprise wide application in 1/4 of the time it normally takes. It was also less error prone since the framework handles threading and concurrency issues.

Note: On page 427 there is a code example that has the user add a showHelloWorld method. There is a missing variable that needs to be added. It should have:
private JDialog helloWorldBox;
There is another section on Beans Binding (JSR-296) which covers another ease of use technology for Swing. It allows the developer to bind data components to Swing components in an easy and consistent way. The explanation here of the technology combined with JSR-295 makes Swing development easy. It also covers the Database Table Editor to make modifying tables easy to use as part of the binding process.
Note: Page 431, last paragraph indicates that you can use the DOUGHNUTS table node to use the table editor, this is not correct. You must open the table, and select a column to open the table editor.

Note: Page 442, to use the validator you have created, you must compile the code first. Either by selecting the class itself and compiling it, or clean and building your project.

I personally found that the GUI project development section was crucial to me for using these great new technologies, and development of a successful enterprise Swing application.

Chapter 16:

Developing Rich Client Applications

This chapter covers the development of Rich Client Platform applications using the NetBeans platform as the base for your application. This section provides an introduction to the technology, and the basics of how to create your own branded rich client applications.

Summary:

I would recommend this book to anyone who wants to learn more about the NetBeans IDE.

Based on the easy reading style and effectiveness of communicating complex topics, I would give the book (4/5) stars.

Sunday, February 01, 2009

Quercus PHP 3.2.1 on GlassFish 2.1

I am trying to consolidate a number of applications running on various platforms to GlassFish, if possible. So far I have been incredibly successful with Ruby using JRuby. Our project tracking software (bugs/news/wiki/forums/repository browser) are running on Redmine using JRuby.

Based on the success of using Ruby (RoR), I decided to trying moving some PHP applications over to GlassFish.

I read a great blog article by Ludovic Champenois called 100% Java Quercus PHP engine running in GlassFish Java EE 5 Application Server It describes how to use an open source engine called Quercus from Caucho. I tried to follow the directions, but could not get it to work. I imagine because the versions of GlassFish application server and Quercus may have been different. I was not deterred.

I came across a follow-up article by Arun Gupta called PHP in GlassFish using Caucho Quercus. This article was the missing link. The major difference being the placement of the jar files in the domain/domainXX/lib directory.

Here are the application versions I used to get a functional Caucho Quercus PHP implementation running on GlassFish v 2.1

Mac OS X 10.5.6 (Intel x86)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • Java(TM) SE Runtime Environment (build 1.6.0_07-b06-146) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-56, mixed mode)

Mac OS X 10.5.6 (PowerPC)

  • GlassFish v 2.1 Build 60e ( 2.1 FCS)
  • Quercus 3.2.1
  • jsr223-api.jar (Project Phobos) Required for Java SE 5.
  • Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)
When I created my projects I used the following web.xml It is based on the example web.xml in the Quercus 3.2.1 war file.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
   <session-timeout>
       30
   </session-timeout>
</session-config>

<description>Caucho Technology's PHP Implementation</description>
<servlet>
   <servlet-name>Quercus Servlet</servlet-name>
   <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<!-- Specifies the encoding Quercus should use to read in PHP scripts.
    -->
<!--
    <init-param>
      <param-name>script-encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    -->

<!-- Tells Quercus to use the following JDBC database and to ignore the
         arguments of mysql_connect().
    -->
<!--
    <init-param>
      <param-name>database</param-name>
      <param-value>jdbc/test</param-value>
    </init-param>
    -->

<!--
    <init-param>
      <param-name>ini-file</param-name>
      <param-value>WEB-INF/php.ini</param-value>
    </init-param>
    -->
</servlet>

<servlet-mapping>
   <servlet-name>Quercus Servlet</servlet-name>
   <url-pattern>*.php</url-pattern>
</servlet-mapping>
<welcome-file-list>
   <welcome-file>index.php</welcome-file>
</welcome-file-list>
</web-app>


This arrangement will allow you run a large number of applications including XWiki, and Drupal. Unfortunately for me, it can not run phpLDAPadmin which I needed.

Popular Posts