eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
385 stars 143 forks source link

GF v3.1 can't work with JAX-RS Application class #13234

Closed glassfishrobot closed 14 years ago

glassfishrobot commented 14 years ago

When you try to use Application Config Class for JAX-RS the GF gives a warning message and not deploy the resources:

INFO: No timers to be deleted for id: 84110750714757120 INFO: PersistenceStrategyBuilderFactory>>createPersistenceStrategyBuilder: CandidateBuilderClassName = class com.sun.enterprise.web.MemoryStrategyBuilder INFO: WEB0671: Loading application [javaee6-jaxws] at [/javaee6-jaxws] WARNING: Unable to get Application config for: javaee6-jaxws INFO: PersistenceStrategyBuilderFactory>>createPersistenceStrategyBuilder: CandidateBuilderClassName = class com.sun.enterprise.web.MemoryStrategyBuilder

INFO: WEB0671: Loading application [javaee6-jaxws] at [/javaee6-jaxws] INFO: loading.application.time INFO: javaee6-jaxws was successfully deployed in 833 milliseconds.

Ill attach the test case.

Environment

Operating System: Windows 7 Platform: All

Affected Versions

[3.1]

glassfishrobot commented 6 years ago
glassfishrobot commented 14 years ago

@glassfishrobot Commented casmeiron said: Created an attachment (id=4789) Test case

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: I think there is a regression in GF 3.1 Web container detecting Jersey's ServletContainerInitializer implementation, i can reproduce on GF 3.1 b18.

The app works on GF 3.0.1:

glassfishrobot commented 14 years ago

@glassfishrobot Commented @shingwaichan said: Running "mvn install" with given pom.xml, I get the following error: Missing:

1) javax:javaee-api:jar:6.0-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command: mvn install:install-file -DgroupId=javax -DartifactId=javaee-api -Dversion=6.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=javax -DartifactId=javaee-api -Dversion=6.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency: 1) br.com.bestdeal.examples:javaee6-jaxrs:war:1.0-SNAPSHOT 2) javax:javaee-api:jar:6.0-SNAPSHOT


1 required artifact is missing.

for artifact: br.com.bestdeal.examples:javaee6-jaxrs:war:1.0-SNAPSHOT

from the specified remote repositories: central (http://repo1.maven.org/maven2)

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: Modify the pom with the following:

javax javaee-api 6.0 provided maven-repository.dev.java.net Java.net Maven 1 Repository (legacy) [http://download.java.net/maven/1](http://download.java.net/maven/1) legacy glassfish-repository Java.net Repository for Glassfish [http://maven.glassfish.org/content/groups/glassfish](http://maven.glassfish.org/content/groups/glassfish) maven2-repository.dev.java.net Java.net Repository for Maven [http://download.java.net/maven/2](http://download.java.net/maven/2) default
glassfishrobot commented 14 years ago

@glassfishrobot Commented casmeiron said: Sorry, I forgot to add the repositories, thanks sandoz.

glassfishrobot commented 14 years ago

@glassfishrobot Commented @shingwaichan said: With the above pom.xml change, I can start to build the application but with the following error:

[INFO] [war:war] [INFO] Packaging webapp [INFO] Assembling webapp[javaee6-jaxrs] in [/export/gfv3/test/IT/13234/javaee6-jaxrs/target/javaee6-jaxrs-1.0-SNAPSHOT] [INFO] Processing war project [INFO] Copying webapp resources[/export/gfv3/test/IT/13234/javaee6-jaxrs/src/main/webapp] [INFO] Webapp assembled in[53 msecs] [INFO] Building war: /export/gfv3/test/IT/13234/javaee6-jaxrs/target/javaee6-jaxrs-1.0-SNAPSHOT.war [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

glassfishrobot commented 14 years ago

@glassfishrobot Commented @ljnelson said: As an extremely quick way to get past that, invoke Maven like this:

mvn clean install -DfailOnMissingWebXml=false

See http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#failOnMissingWebXml for more details.

I will get back to this bug either later tonight or tomorrow.

glassfishrobot commented 14 years ago

@glassfishrobot Commented @shingwaichan said: I can deploy the war according to previous instruction. Note that the above WARNING mentioned is not shown all the time. Besides that, I do not see any other error in the log.

I have confirmed that the JerseyServletContainerInitializer has been called with example.TestResource in the debugger.

Reassign to Paul for further investigation.

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: Did you try and access the following URL?

http://localhost:8080/javaee6-jaxws-1.0-SNAPSHOT/rs/hello

Did you see anything in the log?

I tried the latest b19 nightly and it does not work, including debugging to the JerseyServletContainerInitializer, when deploying using NBs or using asdmin. I will build from the source next.

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: I tried with the latest dev build and the same result. The URL previously mentioned returns a 404.

I suspect there is something up with detecting META-INF/services/javax.servlet.ServletContainerInitializer for jars in GF/modules.

Playing bug tennis and reassigning back. Shing, can you share the GF log for when you say this is working?

glassfishrobot commented 14 years ago

@glassfishrobot Commented @shingwaichan said: I also get 404 for the url above. I mean JerseyServletContainerInitializer is invoked.

One can confirm this by adding the following debug in StandardContext.java: try

{ +//XXX +System.out.println("XXX calling " + initializer + " with " + initializerList.get(initializer)); ServletContainerInitializer iniInstance = initializer.newInstance(); iniInstance.onStartup( initializerList.get(initializer), ctxt); +//XXX +System.out.println("XXX calling " + initializer + " done "); }

catch (Throwable t) { log.log(Level.SEVERE, sm.getString(

With this debug change, I got the following in server.log:

XXX calling class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer with [class example.TestResource XXX calling class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer done XXX calling class com.sun.faces.config.FacesInitializer with null XXX calling class com.sun.faces.config.FacesInitializer done XXX calling class com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer with null XXX calling class com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer done XXX calling class org.apache.jasper.runtime.TldScanner with null XXX calling class org.apache.jasper.runtime.TldScanner done

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: Note that the last time JerseyServletContainerInitializer source was modified was on the October the 6th, and as previously stated the test case works on 3.0.1 (same code).

Perhaps there is something wrong with proxying? and onStartup of the proxy is not deferring to the actual implementation?

Or a class loading issue with two different class loaders?

Is it possible for you to debug into the startUp method? i tried with no success.

I would expect the following log statement to be output at JerseyServletContainerInitializer#206

LOGGER.info("Registering the Jersey servlet application, named " + a.getName() + ", at the servlet mapping, "

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: I know what the cause is, notice the declaration of @HandlesTypes:

@HandlesTypes(

{Path.class, Provider.class, Application.class}

) public class JerseyServletContainerInitializer implements ServletContainerInitializer

{ ... }

The set of classes passed into the onStart method should be TestResource and ApplicationConfig, but only the former is passed in.

On the JavaDoc of @HandlesTypes:

"If an implementation of ServletContainerInitializer specifies this annotation, the Servlet container must pass the Set of application classes that extend, implement, or have been annotated with the class types listed by this annotation to the ServletContainerInitializer.onStartup(java.util.Set>, javax.servlet.ServletContext) method of the ServletContainerInitializer (if no matching classes are found, null must be passed instead) "

glassfishrobot commented 14 years ago

@glassfishrobot Commented @ljnelson said: Paul, does this mean you also know the cause of issue 12268? You had surmised that there was a relationship between these two bugs. (Selfishly, I'm more interested in issue 12268.)

glassfishrobot commented 14 years ago

@glassfishrobot Commented sandoz said: I suspect this issue is unrelated to, but blocking investigation of, issue 12268.

glassfishrobot commented 14 years ago

@glassfishrobot Commented @shingwaichan said: In ServletContainerInitializerUtil.checkAgainstInterestList(Type, Map, Map,, Set ClassLoader), we have for (Class c: interestList.keySet()) { Type type = classInfo.getBy(c.getName()); if (type==null) continue;

When c is javax.ws.rs.core.Application, classInfo.getBy(c.getName()) is null. This should not be the case. Per discussion with Jerome, there may be an issue when the base class is not in the war. Assign to him for further investigation.

glassfishrobot commented 14 years ago

@glassfishrobot Commented dochez said: Hk2's new classmodel was only returning information about visited classes while in this case, we needed this information for referenced types as well. Added support and integrated hk2. I did not see an exception or warning in the log, the application object was also picked up by the servlet initializer code.

glassfishrobot commented 14 years ago

@glassfishrobot Commented File: javaee6-jaxrs.rar Attached By: casmeiron

glassfishrobot commented 14 years ago

@glassfishrobot Commented Was assigned to dochez

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-13234

glassfishrobot commented 14 years ago

@glassfishrobot Commented Reported by casmeiron

glassfishrobot commented 14 years ago

@glassfishrobot Commented Marked as fixed on Thursday, September 9th 2010, 1:44:05 pm