Technology insights, news and tips.

  • Sun
    January 23, 2006

Troubleshooting Deployment in Glassfish

In Java EE 5,
there are many new and exciting features. For example, developers can specify
annotations in Java files instead of putting metadata in deployment descriptors.
In some cases, applications can be completely free of deployment descriptors.
This simplifies the development of Jave EE applications.
This blog describes two common troubleshooting scenarios for
deployment in GlassFish.

  1. Runtime error due to annotations not correctly processed (if at all) during deployment.
    In this case, even though one may go through deployment, there will
    be a runtime error. For instance, suppose you have the following resource injection

        private @Resource(name="jdbc/__default") DataSource ds;

    then, you will have a NullPointerException
    when you try to access the ds.
    Verify that the annotation is not processed by doing the following:

    • turn on deployment log to FINE in the domain during deployment time
      In this case, you will see a FINE message in server.log as follows:

          Annotation is not processed for this archive.


    • Make sure that standard deployment descriptor files,
      such as ejb-jar.xml, web.xml,application-client.xml refer to the correct version of the
      XML schemas in the ear/war/jar files before deployment as the Java EE platform
      spec requires that annotations are only processed if the deployment descriptor
      uses the latest schema.
      Deployment DescriptorVersion of XSD
      ejb-jar.xml ejb-jar_3_0.xsd
      web.xml web-app_2_5.xsd
      application-client.xml application-client_5.xsd

    • If the descriptors mentioned above refer to the correct schema
      versions, then please make sure that the full attribute is "false"
      or not specified there as the Java EE platform spec indicates that annotations
      are only processed if the deployment descriptors using the latest schema have
      the full attribute either specified as "false" or not specified. For instance,

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" full="false" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

    • If the above are correct and the annotation in application client
      is still not processed, then please make sure that the application client jar
      file has a MANIFEST.MF containing a Main-Class entry
      pointing to the fully qualified name of the app client main class. Note that,
      in general, one can specify the application client main class as an appclient
      command line argument.
      But in cases with annotation, one needs to have MANIFEST.MF with
      Main-Class entry.

  2. A library jar file is incorrectly treated as app client jar in a
    deployment descriptor free application. This is due to the fact that the
    given library jar file has a Main-Class entry in
    MANIFEST.MF file.
    Note that even though the application may be able to deploy, it may not
    be as you desired. For instance, if the given ear does not have an
    app client jar, deployment may interpret a library jar as an app client jar.
    One can verify this in admin GUI.


    • Include application.xml and defined each module explicitly. In this case, the library jar is not mentioned in application.xml.
      For instance,

      <?xml version="1.0" encoding="UTF-8"?>

      <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd>














    • Or remove the Main-Class entry in MANIFEST.MF
      if it is unnecessary for the library function properly.

Join the discussion

Comments ( 3 )
  • Shing Wai Chan Monday, February 13, 2006
    The full attribute mentioned above has been renamed to metadata-complete.
  • Ben Tuesday, June 6, 2006
    Hello, thank you for this informative post. I am experiencing problems with dependency injection in an EJB application I am writing.

    Sun App Server 9

    Hibernate 3.2


    I need to call a webservice from another stateless bean (also exposed as a webservice). I am currently getting a NPE. I have "application.xml" in the ear file, and inside the ear are the EJB's inside a .jar file called "beans". Beans.jar has only a "persistence.xml". I have tried placing "application-client.xml" in the ear, and beans.jar to no avail.
    Any ideas?
  • Mitesh Monday, June 12, 2006
    Hi Ben,
    Its possible that the injection is not going though due to some error.
    Please run your app through the verifier utility (http://docs.sun.com/app/docs/doc/819-3660/6n5s7klpa?a=view#beadq)
    If You are still not able to nail down the issue, please post your issue in glassfish forums with complete stack trace.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.