GlassFish Installation

Version 24.2 by Vincent Massol on 2010/09/23

  • Download the latest GlassFish (currently v3.0.1) from here
  • Donwload the exe for Windows or the shell script for Unix.
  • Start GlassFish instance using $GLASSFISH_HOME/bin/asadmin start-domain
  • Do you want to deploy from the web interface, or the commandline?
  • Deploying from the web interface:
    • point browser tohttp://localhost:4848
    • log in as default administrator user admin with default password adminadmin
    • select Applications -> Web Applications -> Deploy in the left tree
    • select the XWiki WAR archive to deploy and set the context root to xwiki (anything else will make XWiki navigation break)
  • Deploy from the commandline:
    • $GLASSFISH_HOME/bin/asadmin deploy --contextroot xwiki file.war
  • enjoy XWiki from http://localhost:8080/xwiki

The complete GlassFish Documentation is here: https://glassfish.dev.java.net/docs/project.html

Configuring a MySQL datasource in Glassfish

  • Download the MySQL jdbc driver from here
  • Extract the contents of the file.
  • Copy the jar file to GLASSFISH_HOME/glassfish/lib if you want it to be available to all Glassfish applications, or to the WEB-INF/lib dir of the xwiki deployment dir if you only want it to be locally available (example: GLASSFISH_HOME/glassfish/domains/domain1/applications/xwiki-enterprise-web-2.5-milestone-1/WEB-INF/lib).
  • Start or restart the Glassfish server: bin/asadmin start-domain or bin/asadmin restart-domain

Now if you want to use the web interface to define a datasource, you can find useful info here.

If you want to use the command line interface to define a datasource, you can find useful info here.

Quick and dirty is easy:

  • Create the connection pool: Assuming you did the MySQL stuff as explained here you have a MySQL database called 'xwiki' accessable by a user 'xwiki' with password 'xwiki'.
  • asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
    --restype javax.sql.ConnectionPoolDataSource --property "User=xwiki:Password=xwiki:URL=jdbc\\:mysql\\://localhost\\:3306/xwiki"
    jdbc/xwikipool
  • This should give you Command create-jdbc-connection-pool executed successfully.
  • Test the connection pool: asadmin ping-connection-pool jdbc/xwikipool 
  • This should give you Command ping-connection-pool executed successfully.
  • If not, just execute bin/asadmin delete-jdbc-connection-pool jdbc/xwikipool and start again :-)
  • Create the JDBC resource: asadmin --user=admin create-jdbc-resource --connectionpoolid jdbc/xwikipool jdbc/xwiki
  • This should give you Command create-jdbc-resource executed successfully.
  • Test the JDBC resource: asadmin --user admin list-jdbc-resources 
  • This should result in:
    jdbc/__TimerPool
    jdbc/__default
    jdbc/xwiki

    Command list-jdbc-resources executed successfully.

Now the last thing you need to do is go into the directory glassfish/domains/domain1/applications/xwiki-enterprise-web-2.5-milestone-1/WEB-INF and edit hibernate.cfg.xml.

Uncomment the default database section (simpy by moving the ">" part a couple of lines down), and uncomment the MySQL part.

Done!

Installing the default XAR file

First thing you would normally do is import the default xar file to initialize the wiki and populate it with some nice pages.
However, it is very likely that you will see an error message like:
com.xpn.xwiki.XWikiException: Error number 0 in 11: Uncaught exception Wrapped Exception: org.apache.commons.codec.binary.Base64.<init>(I[B)V
As explained here you have to do the following:

You should copy commons-codec-1.4.jar from the \xwiki\WEB-INF\lib to the \glassfishv3\glassfish\modules and also delete commons-codec-repackaged.jar in a \glassfishv3\glassfish\modules folder.

And that solves the problem.

Get Connected