Showing posts with label open source. Show all posts
Showing posts with label open source. Show all posts

Wednesday, October 24, 2012

Article: How to get (almost) everything you ever wanted in one (not very) easy step

I finished reading the article How to get (almost) everything you ever wanted in one (not very) easy step by Richard Kennard in SD Times magazine. At first I thought it was going to go in a direction that I thought would be helpful for most developers who want to get involved in open source projects, or just become more involved in their respective development communities. My hope was quickly dashed. Don't get me wrong, the article is good, but most folks will not be able to take this approach. 

Richard's approach is to find something that you can turn in to a doctoral thesis, and work on your Ph.D. The article then covers how Richard did this himself.  Richard's passion is a project called Metawidget. This is a really cool technology. In fact it was so cool, that as part of the JavaOne paper selection committee I strongly recommended it. The committee agreed, and Richard gave a talk about it at JavaOne a couple of years ago.

I like Richard's passion about putting in the extra mile to get something accomplished for you, and the community. I just want to make sure that people don't get lost in the idea of a Ph.D. as a minimum level of commitment.

I have an email from Ed Burns the specification lead for JSF. He is asking for assistance with Javadoc updates. This is for JSR-344 JSF 2.2. This is an example of something where you can make a difference without a lot of personal time expense, and may provide the push to continue into bigger and better things.


I sure could use some help in bringing the new Javadoc 7 style to the generated portion of the JSF spec [1].  Can anyone from the Adopt-a-JSR program help me out here?  The task would be very hands-on, as the generated portion of the spec uses several different kinds of documents as its source inputs.
Ed
[1]https://javaee.github.io/javaserverfaces-spec/
It can be something simple like this that would make the difference for a lot of people. 

Obviously, I like to blog which does not require a lot of time. Here is my secret about blogging... I forget things. My blog is a reminder of how to do things that I figure out, and need every so often. I know it may sound funny, but I often Google for something and get my own blog. Other times, I blog about articles which I find interesting. Like this article.

If you want to participate in any project, or technology just ask. The smart project owners/leads will find a place in their project for you. Eventually, you may lead your own project.


Tuesday, December 13, 2011

Secure Mercurial in GlassFish using SSL

A friend of mine, Wade Chandler, contacted me the other day to ask about implementing security (SSL) for Mercurial on GlassFish. Wade is NetBeans Dream Team member, and all-around great guy. I told him I would figure it out, and tell him how to do it. I also decided that I would explain to everyone how to take advantage of this cool functionality using GlassFish 3.1.1 and NetBeans 7.1 RC 2. 

In  a previous blog entry, Mercurial on GlassFish 2.1 Using Multiple Repositories, I successfully deployed Mercurial repositories on GlassFish. This time I have given everything a Java EE 6 upgrade.

One of the great aspects of using GlassFish to provide SSL is that we don't require messy configuration in Python and Mercurial to implement SSL. GlassFish handles the security for us. The only thing that the end client users will want to do is add the server fingerprint to the .hgrc file in their home directory. This will remove any warnings about a missing server fingerprint, or cacerts file.

If you have used Mercurial on Apache HTTPD Server, along with cacerts, and client certificates... this will make you make the switch immediately.

Requirements:

You can create your own web project in NetBeans, but the Mercurial.zip is a self-contained Mercurial repository, and NetBeans project which can serve as the basis for your own server with very little modification. I would simply use my project as the basis for your own deployment.

Note: The requirements include repos.zip which is optional. The repos.zip contains sample mercurial repos which are required for the demo.

Procedures

Configure GlassFish

  1. Start the GlassFish administration console.
  2. Go to Configurationserver-configSecurityRealmsfile.
    Note: You may create your own realm, this is just for demonstration purposes.
  3. Click on Manage Users.
    GlassFish Security Configuration
  4. Click on New. Add a user called mercurial in a group called Mercurial Users with the password hg.
    Note: Please change the username, group, and password for production.
  5. The server configuration is complete.

NetBeans

  1. Using NetBeans open the Mercurial project from the requirements link above.
  2. There are four files in the project (simple huh?) which control the behavior of the Mercurial repository on GlassFish: hgweb.cgi, hgweb.config, web.xml, and glassfish-web.xml.
  3. The hgweb.cgi should not need to be modified under normal circumstances.
  4. Open the hgweb.config file. Make any changes that you would like to customize the application. Pay particular attention to the location of the repositories.
    There are two examples: (1) using the "/" along with a * on the end of the file path will list all repositories in the specified directory, and (2) a specific listing.

    Note: Please note that allow_push = * and push_ssl = false are set. This will allow push to the server and let GlassFish take care of the SSL.
  5. The web.xml file has been modified to add security constraints for the alpha, and beta example repositories.
    The alpha repository has security only on PUT, POST, and DELETE.
    The beta repository will not allow you to perform any actions without logging into the server.
    The gamma repository has no security constraints.

    Note: You will need to modify the security constraints to meet your requirements.

    Note: You secure the entire repository by adding:
    <url-pattern>/cgi-bin/hgweb.cgi/*</url-pattern>.

  6. The glassfish-web.xml is used to map the security role(s) to the file realm on the GlassFish server.
  7. Clean, build, and Run the application.
  8. When the application successfully deploys, go to the secure connection on https://localhost:8181/Mercurial. It may prompt you to accept the server certificate. Accept it.
  9. You should see something like the image below:
    Mercurial Repositories
  10. Click on the beta repository. It should prompt you to login.
  11. Congratulations you are running Mercurial on GlassFish securely.

Note: To secure the application completely, you should disable the non-secure http port listener on port 8080, or redirect requests to the secure port. 

Verification

It would be unwise to accept that the application is secure without verification.

I made this demonstration video to prove the connection is secure. The demonstration shows both insecure and secure connections to the repository. I use Wireshark to sniff the connection, and pull the repository from the command line using hg clone.


Conclusion

Mercurial is a great distributed source control system. Its ease of use is further enhanced by using GlassFish 3.1.1 to provide the front end to your repository. It also simplifies the deployment, and use models.

Thursday, November 25, 2010

Oracle Certified Java Programmer Boot Camp Code Examples

Java Mascot introducing Netbeans.Image via Wikipedia
I uploaded all of my code examples today for the free Oracle™ Certified Java™ Programmer Boot Camp that I do for the Greenville Java Users Group (GreenJUG).

You can find more information on the JUG site about the boot camp, and from the links below. The projects are NetBeans 6 files.

You need to still need to attend for the presentations! If I posted those, you wouldn't feel the need to come and participate.

Code Examples

Links



Enhanced by Zemanta

Thursday, September 30, 2010

JavaOne 2010: JDK7 Milestones

It has been a week since JavaOne. I am on the OpenJDK site looking at the plans for JDK7, and it is still empty with no updated plans. Only an orange text box promising an update to the milestones.

There were enough repetitive presentations, and probably discussions behind the scenes prior to JavaOne. Where is the plan? You can check it out yourself at the link below.

JDK7 Milestones

Enhanced by Zemanta

Friday, September 17, 2010

Google Buys Instantiations

Google Web ToolkitImage via Wikipedia
It is interesting that Google acquired the GWT Designer, and Eclipse tools from Instantiations. Is this a sign that Google does not have any worries about the Oracle lawsuit. I don't think this is the case, I feel that it is in their business interests, and "lawsuit be dammed" they are going to continue doing what Google does. Albeit, they do it well.

I am not a GWT user, but it does offer developers other UI options, and options are good. This is especially true with Google; their options are generally very good.
Enhanced by Zemanta

Illumos: An OpenSolaris Replacement, or Vaporware

OpenSolarisImage via Wikipedia
OpenSolaris Logo
The end of the OpenSolaris project was cold blooded, and rather uneventful. Is that because we saw it coming, or has the relevance of OpenSolaris questionable?

There is no doubt that OpenSolaris was the barometer of where Solaris should be heading in an open source world. It included an incredible tool set, and an opportunity to contribute to a great project. The unceremonious end at the hands of Oracle is a brutal barometer to its intentions with regards to open source. This has nothing to do with its current legal battles with Google which is by no means innocent in those legal proceedings.

It was announced in SD Times, and in the Twitter space that Illumos was going to take up the banner for the OpenSolaris cause. As of today, there are no binaries, or code. I am not sure if the legal proceedings have killed the project, or seriously given the project owners a case of heartburn.

The last news is that it will support Mono. This news is least bit interesting to me, and actually I think I caught a chunk in my throat.

I like the idea of continuing the open source development of OpenSolaris, but I am wondering if it is going to fall under the veil of a legal clouds, or a Chinese puzzle box of legal quagmires. Let us not forget that Mono is a bulls-eye for Microsoft.

What are your thoughts?

Signed,

The disaffected, and disillusioned OpenSolaris advocate.
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.

Friday, July 02, 2010

HTML 5

I was looking at the presentation from Google on the HTML5 Rocks site. I found that the demo works for the most part on Firefox. I imagine that the presentation works better on Chrome, but I am not really interested in installing it. I went to the Microsoft site for HTML 5. It has a lot more quirks in it on Firefox.

It is really horrible that we are on the cusp of changing to HTML 5, and I am seeing the same issues that erupted during the browser wars of the 1990s. I am glad that Google has released the free video encoding codec WebM. It is a nice gesture on the part of Google. I only hope the rest of the vendors like Microsoft promote open codecs. It is not likely.

I am bothered that the HTML 5 Working Group at W3C considered putting a requirement for video codecs in the specification for which there was no freely available software. It is a fine demonstration of the the power of influence over standards bodies.  The W3C should work to keep the Internet free.

Wednesday, February 24, 2010

How to contribute to the Maven books

A friend of mine from the JUG community wrote a really neat article which explains (in depth I might add) on how to contribute to the Maven community by updating and fixing issues in the Maven books. A link to his article is listed below.

How to contribute to the Maven books

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

Monday, January 11, 2010

Book Review: Maven By Example

I received a copy of 0.2.1 of the Maven By Example book from Tim O'Brien from Sonatype. I was in the process of learning Maven and moving some of my projects to Maven when Tim contacted me and offered the book to me. He also included a number of copies to give away at my local JUG.

This turned out to be a really good book on learning Maven. It is a Creative Commons licensed book so that it offers the community a chance to update the book and add content. Like any great open source project, giving the community to have a direct chance to update the project produces a better final product.

The most important chapter in the book is chapter 7 which brings together the components of the book into a multi-module enterprise project. The code for the chapter really shows how the components fit together. However, this chapter is lacking a lot of material and does not match the code in the example code in the download.

The chapter needs additional work to explain how to do the project. It really should hand-hold the reader through the chapter, and allow them to use the code in the book to create a project from scratch. I had to download the code to see why examples would not work in the book.

I don't want the previous remarks to seem to critical. They are not meant to be. The book is really well done, and I am glad that I went through it thoroughly. It will serve as a good reference going forward.

You can get a PDF version of the book from here: Maven By Example

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, May 01, 2009

Mercurial on GlassFish 2.1 Using Multiple Repositories

Introduction

In this tutorial I explain the basics of creating multiple Mercurial repositories, and then configuring GlassFish 2.1 to connect and display them. Mercurial is an open source source control system. GlassFish is an open source Java™ application server. I will not explain how to install Mercurial, nor GlassFish. The respective sites have excellent documentation on how to install them.

Creating Repositories

1. Create a directory called /repos.

2. Using the command prompt, navigate to the /repos directory and issue the following commands.
hg init alpha
hg init beta
hg init omega
This will create three new Mercurial repositories.

3. Change to the respective repositories and add a file called hgrc to the .hg directory. This file should contain a contact and a description of the repository. Here is a representative example from my alpha repository.

[web]
contact = John Yeary <jyearyATbluelotussoftwareDOTcom>
description = Alpha source code repository.
This information will be displayed on our main page.

NetBeans 6.5

1. Using NetBeans create a new Project -> Java Web ->Web Application.

2. Call the project Mercurial.



3. The default Context Path is the project name. We will change it from /Mercurial to /mercurial.



4. Click Finish. This will create a basic web project which will compile to a nice WAR file for deployment on GlassFish.

5. We will begin to modify our project by removing the index.jsp file.

6. Next go to the Web Pages -> WEB-INF directory. In here you will find the default web.xml file. Open it in the editor.

7. Follow the directions from Jean-Francois Arcand's Blog on Enabling CGI support in GlassFish. An example of my web.xml file is displayed below. This will enable the CGI servlet which is used by Mercurial to display the repositories.
<?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">
<servlet>
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cgi</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

8. Next we will create a sub-directory WEB-INF called cgi. This will contain our CGI applications.

9. Obtain a copy of the source code for your version of Mercurial. Locate the hgwebdir.cgi file and copy it to your WEB-INF/cgi directory.

10. Create a file called hgweb.config in the WEB-INF/cgi directory. The hgwebdir.cgi application expects this file to exist and point to your repositories. The hgwebdir.cgi file contains help on configuring the file. Here is an example configuration based on our setup.

[paths]
/ = /repos/*

This will allow the hgwebdir.cgi to map all repositories located in the /repos directory.

11. Next we modify the web.xml file and change the welcome files list to point to the application.
<welcome-file-list>
  <welcome-file>cgi-bin/hgwebdir.cgi</welcome-file>
</welcome-file-list>
12. Click on Run and you should be delighted to see the following.


Issues

If you encounter any errors, or nothing appears, you can enable debugging for python by un-commenting the following lines in the hgwebdir.cgi file.
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb
#cgitb.enable()
You may also enable debugging on the cgi application by changing the debug parameter to 1 in the web.xml file
<init-param>
<param-name>debug</param-name>
<param-value>1</param-value>
</init-param>

Here is a copy of my NetBeans Mercurial Project. It is itself a Mercurial repository.

Saturday, November 01, 2008

ICEFaces 1.7.2 and NetBeans 6.1

I downloaded and installed ICEFaces 1.7.2 and its modules for NetBeans 6.1. My conclusion is that is not ready for primetime on NetBeans.

I would recommend that you read the release notes very carefully. The newest version of ICEFaces is not JSF 1.2 compliant. It needs to run in compatibility mode. This requires you to modify the faces-config.xml and web.xml files. This is a major pain point.

The next thing I noticed is that the design-time implementations are not complete. The ability to visually manipulate the components needs some serious work.

I attempted to do one of the tutorials to create a CRUD application using Netbeans. It was very flaky and did not cover the details adequately. In the end I got the application to deploy, and I could click on the table rows, but it did not work as it did in the tutorial.

I have used ICEFaces in the past and I do like their product in general, but it needs to come up to speed with the rest of the world on JSF 1.2 .Its support for NetBeans needs to have more than token capabilities, and it should account for its compatibility issues without intervention from the end user.

Saturday, September 27, 2008

OpenDS LDAP and GlassFish Configuration

Introduction

A question was posted to our JUG mailing list on how to lock a directory which contained an Adobe™ PDF file. In this example I want to cover a couple of really cool technologies, and how to implement them.

OpenDS is a project hosted on Java.net. It is an open source directory server which is based on the Sun™ SunOne™ Directory server and its predecessors (Netscape™ iPlanet™). It has a binary, or a Java™ Webstart deployment mechanism. It has a simple quick start setup including SSL based LDAP, and directory replication.

This is a simple to install, easy to use and configure, no-nosense LDAP server. It is a great server for prototyping.

Project Glassfish is an open source Java EE application server. It is simple to install and configure, and easy to use. The chances are pretty good that if you are reading this blog, you are familiar with its enormous benefits.

Case

The developer has a pdf file that is located inside a web project on the web server. The file can be bookmarked by users, but the developer wants to make sure that the user authenticates with the server before the file is displayed.


Software and Files Required


Setup

1. Download and install Glassfish

Note: When Glassfish is installed it creates its own self-signed SSL certificates. We will use this certificate later.
2. Start the installation of OpenDS



3. Create a new instance.

4. Accept the default installation directory. Set the password for the cn=Directory Manager to test.



5. Press the Configure button to configure the secure LDAP connection.
  • Set the Key Store Type to Java Key Store (JKS).
  • Set the key store path to point to the keystore.jks file located in the GLASSFISH_HOME/domains/domain1/config directory.
  • Set the Key Store Pin to changeit.


Note: "changeit" is the default password to the keystore. You will need to "change it" for a production system.




6. Select the default for topology options and continue to Directory Data Next.



  • Directory Data should have the default Directory Base DN: dc=example,dc=com
  • Select Import Data from LDIF file and use this example.ldif file. Next.

Note: I have created a pre-generated list of users previously. In this example, I have created a group and assigned it members. So to simplify the example, please use the example.ldif file.




7. Review the selections and Finish.



8. Authenticate with the server using cn=Directory Manager and password "test".






Note: A message will pop-up asking if you want to accept the certificate for the LDAP server. Use the this session only option.




Congrats. You now have a running LDAP server.

If you want to explore the contents of the directory use a tool like JXplorer, or Apache Directory Studio.

Now we need to configure our LDAP Security Realm in Glassfish. You may have multiple realms in Glassfish to accommodate application requirements.

1. Start Glassfish and login on http://localhost:4848. The default user is admin and password is adminadmin.

2. Go to Configuration --> Security --> Realms. Create a new Realm

  • Name: OpenDS
  • Class: com.sun.enterprise.security.auth.realm.LDAPRealm
  • JAAS context: ldapRealm
  • Directory: ldaps://localhost:1636
  • Base DN: dc=example, dc=com
  • Assign Group: ou=Groups,dc=example,dc=com
3. Add a property called group-target.
  • group-search-filter: member=%d





Note: The group-search-filter defines the attribute to look at when determining members of the groups. It may be member, memberurl, etc. depending on how you define your groups. In the example.ldif file, I have define the group as a groupOfNames which contains member [0...] attributes. The %d format expands to match the Relative Distinguished Name (RDN).


4. Save and you are done.

You have now configured Glassfish to use OpenDS.

Note: Since we configured it to use secure LDAP, remember to configure your server to use SSL to authenticate users. Otherwise the secure LDAP portion is a waste if the users are transmitting their usernames and passwords in cleartext over the network
I have created a sample Netbeans project which takes advantage of the new LDAP authentication. The project creates a page with a link to a PDF file located in a secured directory. The directory requires the user to authenticate using basic authentication implemented in the browser. If you fail to authenticate, it will produce a 403 error. The project is located here.

Once you successfully authenticate, you will see a list of popular software that runs on Glassfish.

Sunday, August 31, 2008

Sun™ Certified Java™ Programmer Boot Camp

The Greenville Java Users Group (GreenJUG) is conducting an ten (10) week boot camp to prepare its members for the CX-310-065 exam. It is a great opportunity to get a better understanding of Java™ and a obtain a valuable industry certification.

The code examples, books, and notes can be found on the Blue Lotus Software Sun™ Certified Java™ Programmer (SCJP) Boot Camp site. All of the code is Open Source Apache 2 licensed. The schedule for classes and final exam preparation are on the GreenJUG site.

Popular Posts