GlassFish Installation

Version 20.1 by JeroenBaten on 2010/09/22

(tested with HSQL, JavaDB config coming...)

  • 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 defailt database section (simpy by moving the ">" part a couple of lines down, and uncomment the MySQL part.

Done!

Tags:
   

Get Connected