Question

I am trying to run a particularly simple test case using the latest promoted build of Glassfish 4.0. I have tried placing META-INF/beans.xml in all possible permutations including its own jar in WEB-INF/lib

The best I get is the following errors with a layout+sources that are listed after it:

WARNING: Error while trying to load Bean Class WEB-INF.classes.com.example.cdibug.Test : java.lang.ClassNotFoundException: WEB-INF.classes.com.example.cdibug.Test
WARNING: Error while trying to load Bean Class WEB-INF.classes.com.example.cdibug.Foo : java.lang.ClassNotFoundException: WEB-INF.classes.com.example.cdibug.Foo
WARNING: Error while trying to load Bean Class WEB-INF.classes.com.example.cdibug.App : java.lang.ClassNotFoundException: WEB-INF.classes.com.example.cdibug.App
INFO: Registering the Jersey servlet application, named com.example.cdibug.App, at the servlet mapping /rest/*, with the Application class of the same name.
INFO: Loading application [cdibug] at [/cdibug]
INFO: cdibug was successfully deployed in 106 milliseconds.

Layout:

$ jar tvf cdibug.war 
     0 Tue May 07 23:19:48 HST 2013 META-INF/
    68 Tue May 07 23:19:48 HST 2013 META-INF/MANIFEST.MF
     0 Tue May 07 23:14:20 HST 2013 META-INF/beans.xml
     0 Tue May 07 23:19:32 HST 2013 WEB-INF/
     0 Tue May 07 23:18:58 HST 2013 WEB-INF/classes/
     0 Tue May 07 22:51:54 HST 2013 WEB-INF/classes/com/
     0 Tue May 07 22:51:54 HST 2013 WEB-INF/classes/com/example/
     0 Tue May 07 23:09:34 HST 2013 WEB-INF/classes/com/example/cdibug/
   174 Tue May 07 22:54:28 HST 2013 WEB-INF/classes/com/example/cdibug/Test.java
   171 Tue May 07 22:54:04 HST 2013 WEB-INF/classes/com/example/cdibug/App.java
   309 Tue May 07 22:56:30 HST 2013 WEB-INF/classes/com/example/cdibug/Foo.java
   398 Tue May 07 23:06:00 HST 2013 WEB-INF/classes/com/example/cdibug/Test.class
   304 Tue May 07 23:06:00 HST 2013 WEB-INF/classes/com/example/cdibug/App.class
   634 Tue May 07 23:06:00 HST 2013 WEB-INF/classes/com/example/cdibug/Foo.class
$

Source of beans.xml:

$ cat META-INF/beans.xml # EMPTY 0 bytes

Source of App.java:

$ cat WEB-INF/classes/com/example/cdibug/App.java 
package com.example.cdibug;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class App extends Application {
}

Source of Test.java:

$ cat WEB-INF/classes/com/example/cdibug/Test.java 
package com.example.cdibug;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/test")
public class Test {
  @GET
  public String greet () {
    return "hello";
  }
}

Source of Foo.java:

$ cat WEB-INF/classes/com/example/cdibug/Foo.java 
package com.example.cdibug;

import java.util.logging.Logger;

import javax.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class Foo {
  public Foo () {
    System.out.println("stdout: Foo()");
    System.err.println("stderr: Foo()");
    Logger.getGlobal().info("global_log: Foo()");
  }
}
Was it helpful?

Solution

it was a bug in the version bundled with eclipse kepler m6. it works fine under 4.0.0-b87

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top