users@glassfish.java.net

Glassfish and smth strange with class loading

From: <glassfish_at_javadesktop.org>
Date: Wed, 08 Jul 2009 02:56:43 PDT

Hi,
I try to use Glassfish v3 Preview and I have very strange problem with jaxb and jersey (json).
In web.xml I have two servlets:

<servlet>
        <servlet-name>Jersey Spring Web Application</servlet-name>
        <servlet-class>
                com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
                <param-name>com.sun.jersey.config.property.packages</param-name>
                <param-value>
                    pl.com.xxx.cnx.core.rs;
                    pl.com.xxx.cnx.sample.rs
            </param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
</servlet>
        <servlet-mapping>
                <servlet-name>Jersey Spring Web Application</servlet-name>
                <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <description></description>
                <display-name>JaxbTest</display-name>
                <servlet-name>JaxbTest</servlet-name>
                <servlet-class>test.JaxbTest</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>JaxbTest</servlet-name>
                <url-pattern>/jaxbtest</url-pattern>
        </servlet-mapping>


And in JaxbTest servlet:

@Override
        public void init(ServletConfig config) throws ServletException {
                try {
                        Class clazz=Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
                        System.out.println(clazz);
                } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                }
        }


Jersey servlet at init invoke analogyous code:

 public static Builder natural() {
        // this is to make sure people trying to use NATURAL notation will get clear message what is missing, when an old JAXB RI version is used
        try {
            Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(JSONConfiguration.class.getName()).log(Level.SEVERE, ImplMessages.ERROR_JAXB_RI_2_1_10_MISSING());
            throw new RuntimeException(ImplMessages.ERROR_JAXB_RI_2_1_10_MISSING());
        }
        return new Builder(Notation.NATURAL);
    }


I have set <load-on-startup> (in jaxbtest 1, in jersey servlet 2) and the most interesting is that first is executed ok, and in second is throwing ClassNotFoundException

I don't understand this completely and fight too much time with it.
Any sugestions?
Please help.
[Message sent by forum member 'rafik777' (rafik777)]

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