Go Geronimo Go

Contents

Edit

Getting started with Geronimo 1.0

by Calvin Austin

This week Geronimo 1.0 was released. For anyone following the Geronimo project this is a significant event, it means that any developer can access the functioning certified J2EE without having to resort to an old snapshot or doing their own checkout and build which is often timing consuming and relies on access to online repositories.

SpikeSource are pleased to celebrate this release with a preview of Geronimo 1.0 with the rest of our 1.6.3 stack. What that means is that you have a complete, pre-configured J2EE/database stack in one install!

Edit

The Install

The first step to get started with Geronimo is to download the Geronimo-corestack install bundle. The preview is built from the very new 1.0 release. Extract the executable binary:

tar -zxvf geronimo-corestack-1.6.3.standalone.ix86-fedora3.tar.gz

Then run the installer. sh ./geronimo-corestack-1.6.3.standalone.ix86-fedora3.bin

If you have an equivalent distribution to Fedora Core 3, you can use the --force-platform option. The install will ask you to set JAVA_HOME, so select a previous JDK install often in /usr/java or download a new JDK.

Geronimo comes with its own internal database called derby, however the Spikesource stack additionally includes mysql and postgresql which are also popular open source database choices. The installer will prompt you for your database choice and will install and configure it for you and do post install tests as part of the installation process.

Once the install finishes you will be given the option to start the applications in the stack. Select yes. On slower machines it may not detect if Geronimo has completely started but you can browse to the console. You also have the option to enable the scripts to also start at machine boot time.

Geronimo-1.0 Parameters
--------------------------------------------------
  Geronimo Home [/opt/oss/share/geronimo]
      Http Port [8080]
       EJB Port [4201]
       JMS Port [61616]

Hibernate Parameters
--------------------------------------------------
  Hibernate Home [/opt/oss/lib/hibernate]

MySQL-4.1 Parameters
--------------------------------------------------
       Port [3306]
     Socket [/opt/oss/var/mysql/mysql.sock]
       User [mysql]

====================================================================

 Installation summary saved to /opt/oss/INSTALL-SUMMARY.txt                  
                                                                            
 Log files from installation are located at                                  
   /opt/oss/var/log/install.20060106-170759.log                              
   /opt/oss/var/log/rcd/rcd.log                                              
                                                                             
 Total installation took: 12 minute(s) 37 second(s)                                                                                                          

The Spikesource stack is self-contained under the directory /opt/oss. To initialize the right environment to use geronimo you simply need to source the env.sh file as follows:

source /opt/oss/env.sh

This ensures that the geronimo commands you need, like deploy.sh, are automatically on your path.

Edit

The Console

You now have an installed and running copy of Geronimo. Not convinced? Head on over to http://localhost:8080 . You should see something similar to this:


Image:Geronimo1.png



One of the newer features in geronimo is the introduction of a console. You can browse to the console again on port http://localhost:8080/console. The login account is system, with password manager. Now the first thing you may want to do is change that default. The file you need to change is /opt/oss/share/geronimo/var/security/user.properties. The installation version has only one line, system=manager. Simply change the word 'manager' to be your new password. As the password is also used by many of the command line tools it's a good idea to choose a password that doesn't use any special use characters that have a special use like '$' or '&' .


Image:Geronimo2.png


One of the first things you may look at is the Applications menu. In the All Configurations list you will see a mixture of services, some of which are already started. Geronimo uses a kernel architecture and deploys core services as GBeans, this makes for an application server that only deploys the services you need and can handle the lifecycle of those services. Now, if you were like me, you may be tempted to start clicking links, a word of caution those, there are some services that once disabled are difficult to bring back on line again.

One new service that is now enable by default in Geronimo 1.0 is the debug console. You can access is through http://localhost:8080/debug-tool. However its very possible you may want to disable it. To do this from the command line, look for the 'car' or configuration archive reference that matches the url you want to undeploy or stop as follows:

deploy.sh  list-modules

will show the list of car files, we need to find /debug-tool which is

geronimo/jmxdebug-tomcat/1.0/car @ http://localhost:8080/debug-tool 

To undeploy we then just need to run the command

deploy.sh  undeploy geronimo/jmxdebug-tomcat/1.0/car

Edit

Deploying your own application in Geronimo

Edit

Creating the datasource

OK. We've started the server and started one of the pre-configured GBeans. How do you then deploy your own application? The first task is to configure a DataSource for use with our simple application. Until 1.0 most of the datasource configuration had to be done by hand. Geronimo uses the TranQL J2EE connector architecture library for jdbc access. There are 3 scopes of datasource configurations available in Geronimo. In this example we select the simpler global scope which ensures the datasource is available to all applications. The console in 1.0 has a menu option for datasources under the Services folder. Select the Database Pools item and then you can configure and test additional connections fairly easily.


Image:Geronimo3.png


You can also deploy the datasource in the console or deploy it out of the console at a later time. We needed to deploy the TranQL rar file with our deployment configuration. The generated mysql configuration looks as follows, a postgres version is available in the download and named postgres-geronimo-plan.xml

file: mysql-geronimo-plan-1.0.xml

<?xml version="1.0" encoding="UTF-8"?>
<connector configId="user/database-poolExample1/1/car" parentId="geronimo/j2ee-server/1.0/car" xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0">
    <dep:dependency xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.0">
        <dep:uri>mysql/mysql-connector-java/3.1.11-bin/jar</dep:uri>
    </dep:dependency>
    <resourceadapter>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>Example1</name>
                    <config-property-setting name="Password">Mapinkbo</config-property-setting>
                    <config-property-setting name="CommitBeforeAutocommit">false</config-property-setting>
                    <config-property-setting name="Driver">com.mysql.jdbc.Driver</config-property-setting>
                    <config-property-setting name="ExceptionSorterClass">org.tranql.connector.AllExceptionsAreFatalSorter</config-property-setting>
                    <config-property-setting name="UserName">root</config-property-setting>
                    <config-property-setting name="ConnectionURL">jdbc:mysql://:3306/test</config-property-setting>
                    <connectionmanager>
                        <local-transaction/>
                        <single-pool>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
</connector>

There is also a geronimo specific deployment plan. The same datasource is referenced here. The parentID is the configuration we created through the wizard which is why the name user/database-poolExample1/1/car is new.

geronimo-web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/web"
  xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
  configId="Example1"
 parentId="user/database-poolExample1/1/car"
 >

<context-root>/example1</context-root>
<naming:resource-ref>
      <naming:ref-name>jdbc/GlobalJDBC</naming:ref-name>
      <naming:resource-link>Example1</naming:resource-link>
</naming:resource-ref>

</web-app>

In our application we reference the jndi field as

InitialContext ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/GlobalJDBC");

Finally to deploy the servlet run the command deploy.sh

deploy.sh deploy example1.war

Deployed Example1 @ http://localhost:8080/example1

To then undeploy this application, simple run deploy.sh undeploy Example1

Edit

Summary

Although Geronimo is very new, and there is still additional automated tool in the pipeline, the server is ready for internal testing and test migrations. In this article we also only used a tiny fraction of the J2EE services available. Being a fully compliant J2EE server there is a full EJB server, although deploying EJBs today isn't as simply as other application servers out there, look for that to change in the next release updates.

Edit

Resources

http://geronimo.apache.org The Geronimo home page

http://www.apache.org/dyn/closer.cgi/geronimo/1.0/RELEASE-NOTES-1.0.txt Geronimo 1.0 Release Notes

http://www-128.ibm.com/developerworks/opensource/library/os-ag-jdbc/ Three ways to connect a database to a Geronimo application server.

http://opensource2.atlassian.com/confluence/oss/pages/viewpage.action?pageId=1007 -JBoss to Geronimo migration



Most Recent

Most Popular

Most Active Categories




Back To Top Add New Article Printable Page

MediaWiki

This page has been accessed 24,385 times.

This page was last modified 15:33, 18 January 2006.