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.

    Solution:

    • 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.

    Solution:

    • 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>
        <display-name>deployment-ejb30-ear-securityApp</display-name>
        <module>
          <ejb>deployment-ejb30-ear-security-ejb.jar</ejb>
        </module>
        <module>
          <web>
            <web-uri>deployment-ejb30-ear-security-web.war</web-uri>
            <context-root>deployment-ejb30-ear-security</context-root>
          </web>
          </module>
        <module>
          <java>deployment-ejb30-ear-security-client.jar</java>
        </module>
      </application>
    • Or remove the Main-Class entry in MANIFEST.MF if it is unnecessary for the library function properly.
Comments:

The full attribute mentioned above has been renamed to metadata-complete.

Posted by Shing Wai Chan on February 13, 2006 at 11:15 AM PST #

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
Mysql

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?

Posted by Ben on June 06, 2006 at 09:19 AM PDT #

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.

Posted by Mitesh on June 12, 2006 at 01:24 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

Shing Wai Chan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today