Sunday, June 20, 2010

GlassFish Admin Console initPage Error in Ubuntu 10.04

Hello,

I spent a lot of time trying to get the GlassFish Admin Console working in Ubuntu 10.04... It was really hard to find good resources for a Linux beginner, let alone resources at all. So I figured I'd share my knowledge with the world. Hope this helps.

The specific problem here is when you are trying to bring up the Glass Fish Administration Console you get an error 500. Specifically, an 'initPage' error. See error below.

HTTP Status 500 -


type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.reflect.InvocationTargetException while attempting to process a 'initPage' event for '/login.jsf'.

root cause

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException while attempting to process a 'initPage' event for '/login.jsf'.

root cause

java.lang.reflect.InvocationTargetException

root cause

java.lang.UnsupportedOperationException: Cannot create XMLStreamReader or XMLEventReader from a javax.xml.transform.stream.StreamSource

note The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.


GlassFish v3






















I managed to fix this error and get the Admin Console up and running.

Follow the instructions below to update your JDK and point GlassFish to the proper version of the JDK. Restart the domain service and reload the admin console url. Hopefully this will help you along your way.


----------------------------------------------------------------
JDK
----------------------------------------------------------------

Turns out my problem was specific to the OpenJDK Build 18 (1.6.0_18) of the Java JDK. I ended up getting the admin console working with Sun's JDK, Build 20 (1.6.0_20).

To get the latest Sun build of the JDK...
  1. Make sure you repositories are up to date. Perform this command in a terminal window...
    sudo apt-get update
  2. To download and install the JRE (Java Runtime Environment)
    sudo apt-get install sun-java6-jre sun-java6-plugin
  3. To download and install the JDK (Java Development Kit)
    sudo apt-get install sun-java6-jdk sun-java6-plugin
  4. Once installed. Run this command to switch the active version of Java to Sun's version
    sudo update-java-alternatives -s java-6-sun
  5. You can check the version of Java, which is installed using...
    java -version
  6. You should get something similar to...
    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
    Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
Great! Now the Java JDK and JRE should be installed and you should be on Build 20.

----------------------------------------------------------------
GlassFish
----------------------------------------------------------------

The next hurdle that I had to jump over was updating a configuration file for GlassFish.

This was the "asenv.config" file which was still pointed to the old JDK version.

Replace this...
AS_JAVA=/usr/lib/jvm/java-6-openjdk

With...
AS_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.20














Next you'll want to restart the GlassFish domain service...

##########
/glassfishv3/glassfish/bin$ bash asadmin

asadmin> start-domain
Waiting for DAS to start ......
Started domain: domain1
Domain location: /home/rbolton/glassfishv3/glassfish/domains/domain1
Log file: /home/rbolton/glassfishv3/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.
##########

After the service has started, open a web browser and go to the URL of the Admin Console.

http://localhost:4848/

----------------------------------------------------------------

Success!!! Can now load the Admin Console. :) Hopefully this will work for you as well. Please e-mail me or comment on this blog if you have any problems and I will try to help.
















Additional Resources:



14 comments:

  1. Thanks get post I had this working on my laptop and was trying to get it working on my desktop.

    I forgot to amend asenv.config.

    ReplyDelete
  2. Thank you!!!! but in ubuntu you forget to say "enable the parthner repository in /etc/apt/source.list", if you don't make this modify the package sun-java-jdk not apperar in apt get :)

    many thanks!

    ReplyDelete
  3. No problem. Glad I was able to help even if it was only a little bit. :)

    ReplyDelete
  4. Thank you, it really helped.

    By the way GF configuration file is asenv.conf and not asenv.config.

    ReplyDelete
  5. Thanks a lot. Saved me some hours of work ;)

    ReplyDelete
  6. Thanks for the tip!
    Cool bananas!

    Nick

    ReplyDelete
  7. grande master grande!!!!, tenia instalado esto en windows y me pasaba algo similar, ahora instale ubuntu y me daba lo mismo... me queria matar!!!! je.
    Ahora anda al pelo.

    ReplyDelete
  8. Damn Ubuntu, ty for posting this.

    ReplyDelete
  9. it's works!
    Funciono, muchas gracias. sabia que tenia que cambiar eso pero en mi archivo no estaba esa entrada.
    Saludos!

    ReplyDelete
  10. Thank you very much for this!
    After an Ubuntu update my GlassFish didn't work anymore, because the update changed java to OpenJDK... :/

    ReplyDelete
  11. Thanks a lot! You saved my Sunday afternoon

    ReplyDelete
  12. Thanks for that tip!!

    It's time to deploy some app and check this out!

    ReplyDelete
  13. Great stuff thanks - even though this is an old post, it's still valid. Although I am on a Debian server, so I had to add this line to /etc/apt/source.list:

    deb http://ftp.pl.debian.org/debian/ squeeze non-free

    After that I could install Sun (Oracle) Java and I didn't need to add the specific java to my conf file. Just a restart of the Glassfish server and it worked. :-)

    ReplyDelete