users@glassfish.java.net

static fields in class not being seen by glassfish

From: <glassfish_at_javadesktop.org>
Date: Wed, 16 May 2007 19:54:41 PDT

I have a Config.java class that has several static fields that hold properties used by my EJB 3.0 application. The unit tests run successfully (indicating the properties are being correctly read) from within eclipse and the code compiles and tests run succesfulyl in our continuous integration server.

When I deploy the application into Glassfish and use the admin console to test an EJB exposed as a web service I get the following error message in the stack trace:

Caused by: java.lang.NoSuchFieldError: departmentBase at mycompany.project.ejb.DirectoryBean.getDepartments(DirectoryBean.java:61) at mycompany.project.ejb.DirectoryBean.getDepartmentList(DirectoryBean.java:86) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at

I can't understand why this is happening. It's the same jar in which the tests run succesfully....but glassfish has a problem seeing any of the static fields in my Config.java class. Here is what my Config.java looks like:


package mycompany.project.ejb.lib.core;
import java.util.Properties;
import mycompany.project.resources.PropertyLoader;

public class Config {

        public static String peopleBase;

        public static String departmentBase = "ou=departments,dc=us";

        public static String departmentNumberAttribute;

        static {
                // create and load default properties
                Properties defaultProps = new Properties();
                defaultProps = PropertyLoader.loadProperties("config");

                peopleBase = defaultProps.getProperty("peopleBase");
                departmentBase = defaultProps.getProperty("departmentBase");
                departmentNumberAttribute = defaultProps
                                .getProperty("departmentNumberAttribute");
        }
}

I would appreciate any help troubleshooting this.
[Message sent by forum member 'r_sudh' (r_sudh)]

http://forums.java.net/jive/thread.jspa?messageID=217542