[GLASSFISH-20599] Using @Context SecurityContext in a method parameter makes that method single threaded Created: 31/May/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Blocker
Reporter: aaronjwhiteside Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Please see JERSEY-1905

This is serious issue






[GLASSFISH-20751] java.lang.IllegalStateException: Not inside a request scope. when deploying a custom MessageBodyWriter Created: 09/Aug/13  Updated: 19/Sep/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: hilbertinc Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Linux dechter 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 6.3 (Final)



 Description   

I adapted a custom MessageBodyWriter that worked on GlassFish 3.0.1 and I am trying to get it to work on Glassfish 4. This stack trace is from the latest nightly build (glassfish-4.0.1-b02-08_09_2013), but failed in different ways on 4.0 and 4.0.1-b01 as well. This works on TomEE 1.5.2 and appears to be to be compliant with the specifications of a MessageBodyWriter

This is what I am using for all of my HTML generation for jQueryUI, so this is a complete blocking issue for me.

[2013-08-09T12:52:11.197-0500] [glassfish 4.0] [SEVERE] [NCLS-CORE-00026] [javax.enterprise.system.core] [tid: _ThreadID=41 _ThreadName=admin-listener(2)] [timeMillis: 1376070731197] [levelValue: 1000] [[
Exception during lifecycle processing
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalStateException: Not inside a request scope.
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:168)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404)
at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:128)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:94)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:353)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:343)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:237)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:322)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:211)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:979)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:330)
at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:724)
]]

[2013-08-09T12:52:11.198-0500] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=41 _ThreadName=admin-listener(2)] [timeMillis: 1376070731198] [levelValue: 1000] [[
Exception while loading the app]]

[2013-08-09T12:52:11.199-0500] [glassfish 4.0] [SEVERE] [AS-WEB-GLUE-00192] [javax.enterprise.web] [tid: _ThreadID=41 _ThreadName=admin-listener(2)] [timeMillis: 1376070731199] [levelValue: 1000] [[
Undeployment failed for context /gfwriter]]

[2013-08-09T12:52:11.232-0500] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=41 _ThreadName=admin-listener(2)] [timeMillis: 1376070731232] [levelValue: 1000] [[
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalStateException: Not inside a request scope.]]



 Comments   
Comment by hilbertinc [ 09/Aug/13 ]

I don't see a way to upload example code, so the servlet that tries to use it and the provider itself can be download at the following locations:

http://www.hilbertinc.com/ftp/gfwriter-sources.jar
http://www.hilbertinc.com/ftp/jee-providers-1.0-sources.jar

The war doesn't deploy, but it if did, the PotusResource would be the item of interest





[GLASSFISH-21070] GlassFish Admin Console Never Appears - White Screen Created: 23/May/14  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1_b05
Fix Version/s: 4.1.1

Type: Bug Priority: Blocker
Reporter: peter_pilgrim Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Glassfish 4.0.1-b05-ml, Ubuntu Linux 12.04 LTS


Tags: Admin, Console, Exception, FacesServlet, JAXRS, UriBuilder

 Description   

Hello

I cannot access the Glassfish admin console remotely, because there is a failure with a web service.

Glassfish 4.0.1-b05-ml,
Ubuntu Linux 12.04 LTS
I cannot access the administration view http://www.xenonique.co.uk:4848/ on my server at all.
I enabled remote DAS.
I managed to see the admin console, then I restarted the server then now there is a blank screen.

Here is what I found inside the log:

[2014-05-23T19:11:45.498+0000] [glassfish 4.0] [WARNING] [] [javax.enterprise.web.core] [tid: _ThreadID=42 _ThreadName=admin-listener(3)] [timeMillis: 1400872305498] [levelValue: 900] [[
Servlet.service() for servlet FacesServlet threw exception
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:71)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:177)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:68)
at org.glassfish.admingui.common.util.RestUtil.get(RestUtil.java:862)
at org.glassfish.admingui.common.util.RestUtil.restRequest(RestUtil.java:209)
at org.glassfish.admingui.common.handlers.RestApiHandlers.restRequest(RestApiHandlers.java:224)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
at com.sun.jsftemplating.layout.descriptors.LayoutComponent.beforeCreate(LayoutComponent.java:348)
at com.sun.jsftemplating.layout.descriptors.LayoutComponent.getChild(LayoutComponent.java:288)
at com.sun.jsftemplating.layout.LayoutViewHandler.buildUIComponentTree(LayoutViewHandler.java:556)
at com.sun.jsftemplating.layout.LayoutViewHandler.createView(LayoutViewHandler.java:255)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:254)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:875)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.glassfish.admingui.common.security.AdminConsoleAuthModule.validateRequest(AdminConsoleAuthModule.java:224)
at com.sun.enterprise.security.jmac.config.GFServerConfigProvider$GFServerAuthContext.validateRequest(GFServerConfigProvider.java:1175)
at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1654)
at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1521)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:606)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:702)
at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:678)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:215)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:550)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:744)
]]



 Comments   
Comment by Anissa Lam [ 23/May/14 ]

Assign to Web Service team for initial investigation as the error is from there.

Comment by jimnicolson [ 08/Jul/14 ]

Getting the java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; error also.

Glassfish 4.0.1 (b7)
Oracle Linux 6.5
java version 1.7.0_55

I don't get (haven't seen) this error after clean install first boot with the default Domain1 nor on a freshly created domain.

After I deploy (in WAR form) Jenkins and Artifactory, the problem will arise either on next boot or (annoyingly) a few boots later. Even though there have been no other config changes or deployments!

Either the GF Admin Console will return a blank screen or hang on the "GF Admin console starting" page (a refresh will then return a blank page) or Artifactory will fail on startup.

After trying a few combinations, I found that if I deploy Artifactory after bouncing the server, set Artifactory Deployment order to 150 and Uncheck Enable Implicit CDI, then (relatively)consistently Artifactory starts but the GF Console Startup will fail.

Artifactory and Jenkins are running normally but integration/communication between Atrifactory plug-in and Jenkins also fails once the above GF Admin console startup error ccurs.

This combination of Artifactory, Jenkins (using earlier and current versions) is working and stable with GF 4.0.0.

I am caught between a rock and a hard place. After upgrading to OL 6.5 and it's default JDK of 1.7.0_55, I can't use Eclipse Kepler with GF 4.0.0 because of https://java.net/jira/browse/GLASSFISH-21004.

GF 4.0.1 resolves this but introduces build system failures because of the java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder.

I have a log file and added some comments (Search for !!!!). This is a single full boot process with deployment of Jenkins/Artifactory then an attempt to access the GF Console using a browser. If this is useful, how do I attach it?

Comment by Romain Grécourt [ 08/Jul/14 ]

I didn't reproduce using 4.0.1-b08 (using OSX 10.5 / jdk7u9 / jdk7u51 / jdk7u55).

Here is what I did:

unzip glassfish-4.0.1-b08-ml.zip
cd glassfish4/glassfish
bin/asadmin start-domain
bin/asadmin change-admin-password
bin/asadmin login
bin/asadmin enable-secure-admin
bin/asadmin restart-domain

Peter, can you provide an exact set of steps that reproduce this issue ?

Comment by peter_pilgrim [ 08/Jul/14 ]

Those are the steps I did use. The only differences are that I was accessing my server remotely from a different location and I configured Apache HTTPD server to certain server port 80 on set paths to access web context paths

*/artifactory -> web application "artifactory"
*/jenkins -> web application "jenkins"

E.g. I set up the HTTP conf to use the JkMount

<VirualHost> ...

  1. GlassFish 4.0.1 on worker 2
    JkMount /jenkins worker2
    JkMount /jenkins/* worker2
    JkMount /artifactory worker2
    JkMount /artifactory/* worker2
    ...
    </VirtualHost>

The original error, I saw when I tried access on port 4848, I reported the error that saw in the admin console . Since then, I reconfigured the administration port from 4848 to something else that only I know. Actually, I just tried access this URL and the admin login appears and I can login successfully. Here is how I set up the admin port:

$ asadmin set server.http-service.http-listener.admin-listener.port=9876
$ asadmin set configs.config.server-config.network-config.network-listeners.network-listener.admin-listener.port=9876

I thought the blocker was the Linux firewall, so as root user, I double checked that the ports were open.

$ iptables -A INPUT -p tcp --dport 9876 -j ACCEPT
$ iptables -L

Clearly, it is not a networking error, because Jim Nicolson also is seeing the same issue. So I am not sure why the error is no longer reproducible from my end. That's all of the info.

Comment by jimnicolson [ 09/Jul/14 ]

Hi Romain

Thanks for the quick response...

I realise that GLASSFISH-21004 has been resolved. this solved my Eclipse/Dev VM problem. This caused me to go to 4.0.1 but now I'm hitting the current problem with my build environment VM. I'd prefer to be running the same GF version for both.

On the current problem, I have never seen the issue on a clean domain (i.e. no apps deployed).

Although I've deployed both Jenkins and Artifactory, I did each deployment separately and each one was after a reboot of GF. I tested accessing the consoles of GF and the app(s) after each deployment before continuing.

Jenkins never showed a problem - it seems to be being triggered after the Artifactory deployment. But the problem does not always seem to manifest immediately. Usually immediately but sometimes after one or two GF reboots.

Two additional environment facts (seem unlikely to be a factor). OL 6.5 64 bit, and running on a VirtualBox 4.3.10 VM.

Domain Created with: /opt/glassfish4/glassfish/bin/asadmin --user oracle create-domain --savelogin --checkports=true --portbase 9000 nicolson-dev-mgmt-domain

Although I'm testing on the one VM, I do have a very basic Apache proxy setup for Jenkins/Artifactory set up. It makes no difference whether I use the direct or the proxy URL.

Regards





[GLASSFISH-12598] provide apis that will allow restful access to Created: 08/Jul/10  Updated: 15/Jan/13

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1
Fix Version/s: not determined

Type: Improvement Priority: Critical
Reporter: vince kraemer Assignee: Anissa Lam
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: JPEG File gui-webServiceEndpointInfo.jpg     File TestWebJAX-WS20.war    
Issue Links:
Dependency
blocks GLASSFISH-12361 need rest interface to webservice end... Resolved
Issuezilla Id: 12,598

 Description   

webservice endpoint data like the data available in
https://glassfish.dev.java.net/nonav/issues/showattachment.cgi/4546/details-for-ws-management.png

the details will need to be worked out with Jason Lee or Ludovic Champenois



 Comments   
Comment by vince kraemer [ 08/Jul/10 ]

see issue 12361 for additional details

Comment by Anissa Lam [ 12/Jul/10 ]

GUI needs to convert the web service endpoint information screen to use the REST
API. Please see the attached screen.
In v3, this is through a monitoring bean and invoke the appropriate method.

Here is the code:
private static TabularData getEndpointMap (String appName, String moduleName,
String componentName, String type){
ServerMon serverMon =
V3AMX.getInstance().getDomainRoot().getMonitoringRoot().getServerMon().get("server").as(ServerMon.class);
AMXConfigProxy webDeployment =
serverMon.childrenMap("web-service-mon").get("webservices-deployment").as(AMXConfigProxy.class);
String[] params = new String[]

{ appName, moduleName, componentName}

;
String[] sig = new String[]

{"java.lang.String", "java.lang.String", "java.lang.String"}

;
TabularData endpointMap = null;
if (type.equalsIgnoreCase("Servlet"))

{ endpointMap = (TabularData) webDeployment.invokeOp("getServlet109Endpoint", params, sig); }

else

{ endpointMap = (TabularData) webDeployment.invokeOp("getEjb109Endpoint", params, sig); }

return endpointMap;
}

I need to be able to do the same through some REST API.
I have shown this to Jitu and requested him to look into this. There maybe CLI
currently able to do that. He will get back to me.

Change to P2 and assign to Jitu.

Comment by Anissa Lam [ 12/Jul/10 ]

Created an attachment (id=4564)
GUI Web Service Endpoint Info screen

Comment by vince kraemer [ 12/Jul/10 ]

Anissa: thanks for filling in the details on this.

Comment by vince kraemer [ 23/Aug/10 ]

Is there an update on this issue?

I plan on having the view for this data implemented shortly in the glassfish
integration for netbeans, since I can put together 'mock' data easy enough. But
I really need to have access to the live data to validate the interface and
resolve any issues that might get exposed.

Comment by jitu [ 25/Aug/10 ]

I did receive some code for adding asadmin commands from Ludo. However, I will
take a look at this issue after a week or so.

Comment by vince kraemer [ 25/Aug/10 ]

thanks for the update. I should have a client ready for this next week, too.

Comment by vince kraemer [ 02/Sep/10 ]

The client for this is 'ready'. Have you gotten a chance to implement the 'server' for this data?

Comment by jitu [ 09/Sep/10 ]

Added a hidden asadmin command to list web services

Usage: asadmin [asadmin-utility-options] __list-webservices
[--applicationname <applicationname>] [--modulename <modulename>]
[--endpointname <endpointname>] [?|-help[=<help(default:false)>]]

But actually it is(don't know if there is way to show it as follows):
asadmin [asadmin-utility-options] __list-webservices
[-applicationname <applicationname> [modulename <modulename> [-
endpointname <endpointname>]]]

For example:
$ ./asadmin __list-webservices --applicationname echo
application:echo
module:echo
endpoint:Echo
appName:echo
tester:/echo/echoService?Tester
wsdl:/echo/echoService?wsdl
address:/echo/echoService
implType:SERVLET
deploymentType:109
endpointName:Echo
portName:EchoPort
implClass:fromjava.nosei.server.EchoImpl
serviceName:echoService
namespace:http://echo.org/

one can drill down using --applicationname --modulename --endpointname

Also, for REST interface, the whole tree is set as extra properties.

Eventhough it shows --servletlink, --ejblink in the usage, I plan to delete
them. Let me know if this works for you.

Comment by jitu [ 27/Sep/10 ]

Reassigning to Anissa.

Comment by Anissa Lam [ 27/Sep/10 ]

I think the output needs to be modified. Using extraProperties is ok, but there
is no way for me to know what is what.

Here is what i am seeing if i deploy the attached web service:

{"command":"__list-webservices
AdminCommand","exit_code":"SUCCESS","extraProperties":{"TestWebJAX-WS20":{"TestWebJAX-WS20":{"NewService":{"appName":"TestWebJAX-WS20","tester":"\/TestWebJAX-WS20\/NewServiceService?Tester","wsdl":"\/TestWebJAX-WS20\/NewServiceService?wsdl","address":"\/TestWebJAX-WS20\/NewServiceService","implType":"SERVLET","deploymentType":"109","endpointName":"NewService","portName":"NewServicePort","implClass":"service.NewService","serviceName":"NewServiceService","namespace":"http:\/\/service\/"}}}},"children":[{"message":"application:TestWebJAX-WS20","properties":{},"children":[{"message":"
module:TestWebJAX-WS20","properties":{},"children":[{"message":"
endpoint:NewService","properties":{},"children":[{"message":"
appName:TestWebJAX-WS20","properties":{},"children":[{"message":"
tester:\/TestWebJAX-WS20\/NewServiceService?Tester","properties":{},"children":[{"message":"

wsdl:\/TestWebJAX-WS20\/NewServiceService?wsdl","properties":{},"children":[{"message":"

address:\/TestWebJAX-WS20\/NewServiceService","properties":{},"children":[{"message":"
implType:SERVLET","properties":{},"children":[{"message":"
deploymentType:109","properties":{},"children":[{"message":"
endpointName:NewService","properties":{},"children":[{"message":"
portName:NewServicePort","properties":{},"children":[{"message":"
implClass:service.NewService","properties":{},"children":[{"message":"
serviceName:NewServiceService","properties":{},"children":[{"message":"
namespace:http:\/\/service\/","properties":{}}]}]}]}]}]}]}]}]}]}]}]}]}]}]}

the CLI output looks fine:

v3admin __list-webservices --applicationname TestWebJAX-WS20
application:TestWebJAX-WS20
module:TestWebJAX-WS20
endpoint:NewService
appName:TestWebJAX-WS20
tester:/TestWebJAX-WS20/NewServiceService?Tester
wsdl:/TestWebJAX-WS20/NewServiceService?wsdl
address:/TestWebJAX-WS20/NewServiceService
implType:SERVLET
deploymentType:109
endpointName:NewService
portName:NewServicePort
implClass:service.NewService
serviceName:NewServiceService
namespace:http://service/

Command __list-webservices executed successfully.

Are you saying that the
key of first map is 'application', followed by 'module' and then followed by
'endpoint' ?

I am really confused here.

but there is no 'key' for 'module' and 'endpoint'.

Comment by Anissa Lam [ 27/Sep/10 ]

After deploying the attached webservice, you can go to

http://localhost:4848/management/domain/list-webservices.json?applicationname=TestWebJAX-WS20

to see the output.

Comment by Anissa Lam [ 27/Sep/10 ]

Created an attachment (id=4974)
sample webservice

Comment by Tom Mueller [ 06/Mar/12 ]

Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.





[GLASSFISH-17074] Jersey picks wrong JAXB Context when Accept: header is missing Created: 20/Jul/11  Updated: 15/Dec/11

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1.1_b11
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: mkarg Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Win7 Pro SP1 64 Bit de_DE


Tags: 3_1_2-exclude

 Description   

(This problem was already discussed with Jakub Podlesak of the Jersey team. He has a GF3Fail.war which proofs the failure).

When a client does not care of the returned document type, it does not send an Accept: header. So the server is free to decide for a type that it thinks fits best. In case there is NO @Produces annotation found in a resource, and the application containing that resource has registered its own context provider HAVING a @Produces annotation, it is obvious that THIS custom provider shall be used to marshal the returned entity AND to define the use Content-Type: header when responding.

Actually this is not working in GFv3.1.1_b11 as the contained Jersey engine does NOT pick that custom context provider, but instead ALWAYS asks its own JSON context provider to marshal the result. This is working when the declared return type of the resource method is the custom JAXB class (actually it would be more smart to FIRST give the application-defined provider a chance to marshal the response before picking a Jersey-addon, but this is a different story).

But it is NOT WORKING (JSON context says it does not know that entity class) in case the declared return type is javax.ws.rs.core.Response and the actual entity class is to be retrieved from the dynamically provided entity given to Response.ok(CustomClass)! In that case the JSON provider is picked, which says it does not know that class.

As long as the JSON provider is picked by Jersey, it MUST add the dynamically the class found in the actual dynamic response.

A far better solution obviously would be to FIRST ask the application-provided providers to do the marshalling as this obviously is what the application programmer tries to achieve (as he doesn't know of the JSON provider at all).

There are two possible workarounds, which both render unuseable in case neither the code of the client not the code of the WAR is available to the GlassFish v3 administrator. As a result, this is a showstopper for non-programmers and such must get fixed ASAP.

(A) Change the client to always provide Accept: header – Only possible if the GlassFish administrator has control over all users, what is ridiculous in case of public anonymous services. Also this does not reflect the typical web scenario, where a client can safely assume to get back anything as long as the server can send anything (which this server could if not having this bug).

(B) Add @Provides(contentType) to the resource method – Only possible if the GlassFish administrator has control over the WAR's source code, what is ridiculous in case of running third party off-the-shelf applications provides by large ISVs ("We tested with application server XYZ and will not change our WAR just to make it run in your buggy server!").



 Comments   
Comment by mkarg [ 26/Jul/11 ]

Any progress here regarding a real fix? I mean, the workaround is nice and simple but enforces a software change either on the client or the server (what to do if one has no access to the source?). There should be a solution that does not need any changes in the application.

Comment by Jakub Podlesak [ 29/Jul/11 ]

Lowering the priority to Critical, as there are workarounds for the issue (see above),
so i do not consider it a show-stopper.

I still do not know what is wrong, as (in spite of what's written in the description)
the provided JAXB context is picked up and used by the JSON provider.
It could also be a class-loading issue.

Anyway, it is generally a good practice to use the @Produces annotation in order
to mark the resource methods with media types intended to be produced. And this
good practice is broken here.

Comment by mkarg [ 01/Aug/11 ]

As the solution enforces a source code change in the deployed application, this breaks the WORA principle and such IS a showstopper for ISVs. You cannot expect that every GlassFish administrator has full access to the source code of all deployed applications, and you cannot expect ISVs to change their source code (possibly developed with a different JAX-RS product) just to make it run on Jersey.

Comment by scatari [ 04/Nov/11 ]

Please evaluate this for possible inclusion into 3.1.2.

Comment by Jakub Podlesak [ 15/Dec/11 ]

Excluding from 3.1.2

Please see the reasoning in my previous comment above.
The custom context resolver is indeed being utilized.

The workaround (A) could still be considered.
Because even when server does not have direct control over
all the clients, one can utilize a server side filter which could
add the accept header to all incoming requests, when such a header
is missing.





[GLASSFISH-18836] [osgi/cdi] Regression: An OSGi Service cannot be injected into a JAX-RS resource Created: 25/Jun/12  Updated: 29/Mar/13

Status: Open
Project: glassfish
Component/s: jax-rs, OSGi-JavaEE
Affects Version/s: 4.0_b41
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Sanjeeb Sahoo Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Archive File sample.uas.api.jar     File sample.uas.simplejaxrs.war     Java Archive File sample.uas.simpleservice.jar     Text File server.log    
Issue Links:
Dependency
depends on JERSEY-1024 Integration with CDI Closed

 Description   

This is a regression caused by integration of Jersey 2.0. We have a test that injects an OSGi service into a JAX-RS resource and that's broken. It works fine with 4.0-b41. The steps to reproduce are:

  1. Start gf in foreground so that you can monitor the log messages
    0. asadmin start-domain -v

1. # Copy the attached 3 jars to autodpeloy/bundles/ & wait for a few seconds to deploy.
cp sample.uas.api.jar sample.uas.simpleservice.jar sample.uas.simplejaxrs.jar domain1/autodeploy/bundles/

2. Run the following command which requests the JAX-RS resource:
wget -O - "http://localhost:8080/simplejaxrs/register?name=admin&password=admin"

You will see the following exception in server.log:

[#|2012-06-25T07:37:25.772+0530|SEVERE|44.0|org.glassfish.jersey.server.ApplicationHandler|_ThreadID=14;_ThreadName=http-listener-1(1);|injection failed on org.glassfish.fighterfish.sample.uas.simplejaxrs.Register.uas with interface org.glassfish.fighterfish.sample.uas.api.UserAuthService
org.jvnet.hk2.component.UnsatisfiedDependencyException: injection failed on org.glassfish.fighterfish.sample.uas.simplejaxrs.Register.uas with interface org.glassfish.fighterfish.sample.uas.api.UserAuthService
at org.jvnet.hk2.component.InjectionManager.syncDoInject(InjectionManager.java:210)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:103)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:127)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:117)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:84)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:135)
at org.jvnet.hk2.component.Habitat.getByType(Habitat.java:1390)
at org.jvnet.hk2.component.Habitat.inject(Habitat.java:1199)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:170)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:101)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:116)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:119)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:119)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:119)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:105)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:65)
at org.glassfish.jersey.process.internal.RequestInvoker$AcceptingInvoker.apply(RequestInvoker.java:272)
at org.glassfish.jersey.process.internal.AsyncInflectorAdapter.apply(AsyncInflectorAdapter.java:150)
at org.glassfish.jersey.process.internal.RequestInvoker$2.run(RequestInvoker.java:234)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:237)
at org.glassfish.jersey.process.internal.RequestInvoker$3.run(RequestInvoker.java:245)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:44)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:41)
at org.glassfish.jersey.process.internal.RequestInvoker.apply(RequestInvoker.java:241)
at org.glassfish.jersey.server.ApplicationHandler$6.run(ApplicationHandler.java:618)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:260)
at org.glassfish.jersey.server.ApplicationHandler.apply(ApplicationHandler.java:610)
at org.glassfish.jersey.server.ApplicationHandler.apply(ApplicationHandler.java:583)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:261)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:338)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:304)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:190)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1593)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:285)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:660)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:600)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:337)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:240)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:172)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:164)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:169)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:815)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
at java.lang.Thread.run(Thread.java:662)

#]


 Comments   
Comment by Sanjeeb Sahoo [ 25/Jun/12 ]

Test jars. For source code, please check out:
https://svn.java.net/svn/glassfish~svn/trunk/fighterfish/sample/uas

Comment by TangYong [ 12/Sep/12 ]

Now, the problem is not still fixed. Based on current gf trunk snapshot, once running "http://localhost:8080/simplejaxrs/register?name=admin&password=admin", the sample can not work normally and the following exception[1] happened on server.log (similar to reporter). As a whole, It should result from "JERSEY Integration with CDI".

In addition, the bundles which I used contained the following bundles[2]

[1] pl. see the attachment(server.log)
[2] bundles on another test case
(1) sample.uas.entities.jar
(2) sample.uas.api.jar
(3) sample.uas.ejbservice2.jar
(4) sample.uas.simplejaxrs.war

I think that firstly we need to ask the status of JERSEY-1024.

Comment by Sanjeeb Sahoo [ 12/Sep/12 ]

No, the bug is not fixed and that's why it is still open. Jersey team will fix it before 4.0 gets released.

Comment by Sanjeeb Sahoo [ 23/Mar/13 ]

I stil see the issue using 4.0-b81

Comment by Sanjeeb Sahoo [ 24/Mar/13 ]

Jakub,

I tried using glassfish.zip from your area[1], but it still does not work for me. Here is how you can build the test cases whose binaries have been attached in this issue:

svn co https://svn.java.net/svn/glassfish~svn/trunk/fighterfish/sample/uas

mvn clean install

cp api/target/sample.uas.api.jar simplejaxrs/target/sample.uas.simplejaxrs.war simpleservice/target/sample.uas.simpleservice.jar .../domain1/autodeploy/bundles/

Start glassfish

Open http://localhost:8080/simplejaxrs/register?name=admin&password=admin in your browser. You will see following exception:

[#|2013-03-23T23:25:28.294-0700|SEVERE|glassfish 4.0|org.glassfish.jersey.server.ServerRuntime$Responder|_ThreadID=26;_ThreadName=http-listener-1(1);_TimeMillis=1364106328294;_LevelValue=1000;|
An exception mapping did not successfully produce and processed a response. Logging the original error.
org.glassfish.jersey.server.internal.process.MappableException: A MultiException has 1 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=UserAuthService,parent=Register,qualifiers=

{@org.glassfish.osgicdi.OSGiService(dynamic=true, waitTimeout=-1, serviceCriteria=)}),position=-1,optional=false,self=false,unqualified=null,798083002)

at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:138)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:195)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:217)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:231)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:227)
at org.glassfish.jersey.internal.Errors.process(Errors.java:275)
at org.glassfish.jersey.internal.Errors.process(Errors.java:257)
at org.glassfish.jersey.internal.Errors.process(Errors.java:227)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:191)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:819)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)
Caused by: A MultiException has 1 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=UserAuthService,parent=Register,qualifiers={@org.glassfish.osgicdi.OSGiService(dynamic=true, waitTimeout=-1, serviceCriteria=)}

),position=-1,optional=false,self=false,unqualified=null,798083002)

at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74)
at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:771)
at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:780)
at org.glassfish.jersey.gf.cdi.CdiComponentProvider$1.inject(CdiComponentProvider.java:256)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:103)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:93)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:82)
at org.glassfish.fighterfish.sample.uas.simplejaxrs.Register$Proxy$_$$_WeldClientProxy.getLogin(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125)
... 44 more
Caused by: org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=UserAuthService,parent=Register,qualifiers=

{@org.glassfish.osgicdi.OSGiService(dynamic=true, waitTimeout=-1, serviceCriteria=)}

),position=-1,optional=false,self=false,unqualified=null,798083002)
... 59 more

#]

Sahoo

[1] http://sysifos-sol.cz.oracle.com/hudson/view/Jersey%202/view/GF%20Integration/job/jersey2-gf4-integration/lastSuccessfulBuild/artifact/gf-main/appserver/distributions/glassfish/target/glassfish.zip

Comment by Jakub Podlesak [ 25/Mar/13 ]

Should be fixed in [1] now, will be integrated with jersey 2.0-rc1 into the gf main trunk

Comment by TangYong [ 29/Mar/13 ]

Sahoo,

The issue indeed has been fixed using recent trunk.





[GLASSFISH-20611] JAX-RS Resources Are Not Monitored Created: 06/Jun/13  Updated: 06/Jun/13

Status: Open
Project: glassfish
Component/s: jax-rs, monitoring
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: abien Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: fishcat

 Description   

Monitoring of plain JAX-RS resources does not work. JAX-RS resources do not even appear with "HIGH" monitoring level.






[GLASSFISH-20787] Glassfish injects null ServletContext Created: 31/Aug/13  Updated: 13/Dec/13

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Christian Schlichtherle Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Glassfish 4.0 with latest updates and running on JDK 1.7.0_25.



 Description   

I have a simple JAX-RS application:

@ApplicationPath("/")
public final class MavenUpdateServerApplication extends Application {

    private @Nullable URI configuration;

    public MavenUpdateServerApplication(final URI configuration) {
        this.configuration = Objects.requireNonNull(configuration);
    }

    public MavenUpdateServerApplication() { }

    @Context
    public void setContext(ServletContext context)
    throws URISyntaxException {
        this.configuration = new URI(SystemProperties.resolve(
                context.getInitParameter("configuration")));
    }

    ...
}

This class is bundled within a regular JAR.

Then I have a WAR which bundles this JAR and its dependencies in WEB-INF/lib. The WAR has a WEB-INF/web.xml which looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <context-param>
        <param-name>configuration</param-name>
        <param-value>net/java/trueupdate/artifact/impl/maven/main-repositories.xml</param-value>
    </context-param>
</web-app>

Now at runtime, the setContext() method does get called, but the parameter is always null, so that I get:

SEVERE:   WebModule[/trueupdate-server-appl-javaee]StandardWrapper.Throwable
MultiException stack 1 of 1
java.lang.NullPointerException
	at net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication.setContext(MavenUpdateServerApplication.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1010)
	at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:795)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:790)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:863)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:855)
	at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:293)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:272)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:724)

WARNING:   StandardWrapperValve[net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication]: Allocate exception for servlet net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication
java.lang.NullPointerException
	at net.java.trueupdate.server.impl.maven.MavenUpdateServerApplication.setContext(MavenUpdateServerApplication.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1010)
	at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:795)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:790)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:863)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:855)
	at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:293)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:272)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
	at java.lang.Thread.run(Thread.java:724)

The same code runs fine on Apache Tomcat 7.0.42 with the Jersey Servlet 1.17.1.



 Comments   
Comment by Christian Schlichtherle [ 31/Aug/13 ]

I also get a NullPointerException when trying to inject a ContextResolver into a root resource class like this:

    @Context
    public void setContextResolver(
            ContextResolver<ArtifactResolver> contextResolver) {
        this.artifactResolver = contextResolver.getContext(null);
    }

Seems that I cannot have injected any @Context parameters.

Comment by RobertoGB [ 13/Dec/13 ]

I think that could be jersey issue.

Comment by cowwoc [ 13/Dec/13 ]

It is. See JERSEY-2184





[GLASSFISH-21173] Glassfish / Jersey throws NPE on startup for versioned applications Created: 25/Aug/14  Updated: 23/Oct/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: lprimak Assignee: Marek Potociar
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Initiating Jersey application, version Jersey: 2.10.4 2014-08-08 15:09:00…]]
Glassfish 4.1 promoted build downloaded August 20th, 2014


Tags: jersey

 Description   

Application fails to start in a Availability-enabled clustered environment.
The application works in the same domain when not deployed as a versioned application.

The failure only happens when versioned, i.e. my_app:20140824
I think some parts of GF are broken with this naming convention now.
This is crucial for clusters as it supports hot-deployment.
I believe other parts of Glassfish are broken in regards to application versioning

Application versioning is as described here:
https://weblogs.java.net/blog/serli/archive/2010/08/30/how-use-glassfish-application-versioning?force=354

Related issues:
https://java.net/jira/browse/GLASSFISH-21171
https://java.net/jira/browse/JERSEY-2626

Here is the NPE:
[2014-08-24T05:28:38.406-0400] [glassfish 4.1] [INFO] [] [org.glassfish.jersey.server.ApplicationHandler] [tid: _ThreadID=18 _ThreadName=RunLevelControllerThread-1408872414218] [timeMillis: 1408872518406] [l
evelValue: 800] [[
Initiating Jersey application, version Jersey: 2.10.4 2014-08-08 15:09:00...]]
[2014-08-24T05:28:38.787-0400] [glassfish 4.1] [SEVERE] [] [javax.enterprise.web] [tid: _ThreadID=18 _ThreadName=RunLevelControllerThread-1408872414218] [timeMillis: 1408872518787] [levelValue: 1000] [[
WebModule[/stage]StandardWrapper.Throwable
java.lang.NullPointerException
at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.registerEjbInterceptor(EjbComponentProvider.java:169)
at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.bind(EjbComponentProvider.java:251)
at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:903)
at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:832)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:435)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:320)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:406)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:243)
at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:329)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:377)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:227)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:84)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)



 Comments   
Comment by lprimak [ 26/Aug/14 ]

Looks like the code points to this:

final Object interceptor = new EjbComponentInterceptor(locator);
165 initialContext = getInitialContext();
166 final EjbContainerUtil ejbUtil = EjbContainerUtilImpl.getInstance();
167 final ApplicationInfo appInfo = ejbUtil.getDeployment().get((String)initialContext.lookup("java:app/AppName"));
168 final List<String> tempLibNames = new LinkedList<String>();
169 for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) {
170 final String jarName = moduleInfo.getName();
171 if (jarName.endsWith(".jar")) {
172 final String moduleName = jarName.substring(0, jarName.length() - 4

Comment by lprimak [ 26/Aug/14 ]

Line 169, appInfo is null for versioned application.
Perhaps there needs to be a split / ignore everything from the colon,
i.e. when my_app:20140825, appName should be trimmed to just my_app

Comment by Hong Zhang [ 26/Aug/14 ]

Assign to jersey team to take a look

Comment by lprimak [ 26/Aug/14 ]

This issue is now "unassigned"
Hong,
Can you please assign it to Jersey (or appropriate) team?
It maybe Glassfish core, not Jersdy because
it's EJB Jersey deployer that's failing.

The failed bean is annotated @Stateless @Path("xxx")
thus both a stateless bean and a JAX-RS bean.

Thank you

Comment by lprimak [ 26/Aug/14 ]

I think this issue is a showstopper for GF 4.1 and needs to be fixed in this release.

Comment by Marek Potociar [ 27/Aug/14 ]

The exception is thrown on this code line and is related to line 167, where ApplicationInfo for the application is retrieved.

As noted in an earlier comment, the application does not seem to have an expected loader ApplicationInfo record in the application registry for the versioned applications, at least not under the versioned application name available in the JNDI tree under "java:app/AppName" binding key. It seems to me like a deployment issue - reassigning to deployment component for evaluation. From Jersey perspective, the primary questions to answer in the evaluation are following:

  1. Is Jersey code properly retrieving ApplicationInfo record?
  2. If not, what is the proper, bullet-proof way to retrieve the ApplicationInfo record?
Comment by lprimak [ 07/Sep/14 ]

Perhaps this should be assigned to Marina V so she could clarify how to make this part work correctly?
Thank you

Comment by lprimak [ 13/Sep/14 ]

Now I see it's too late for GF 4.1, can someone take a look so I can at least get a patch / nightly build or something?
Thank you

Comment by lprimak [ 14/Sep/14 ]

I have created a patch to Jersey 2.10.4 that fixes this problem
------------------

diff --git a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
index f08c81a..7d429be 100644
— a/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
+++ b/containers/glassfish/jersey-gf-ejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
@@ -42,6 +42,8 @@
import com.sun.ejb.containers.BaseContainer;
import com.sun.ejb.containers.EjbContainerUtil;
import com.sun.ejb.containers.EjbContainerUtilImpl;
+import com.sun.enterprise.config.serverbeans.Application;
+import com.sun.enterprise.config.serverbeans.Applications;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
@@ -56,9 +58,11 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -87,6 +91,7 @@
import org.glassfish.hk2.utilities.binding.ServiceBindingBuilder;

import org.glassfish.internal.data.ApplicationInfo;
+import org.glassfish.internal.data.ApplicationRegistry;
import org.glassfish.internal.data.ModuleInfo;

/**
@@ -106,7 +111,7 @@
private final List<String> libNames = new CopyOnWriteArrayList<String>();

private boolean ejbInterceptorRegistered = false;
-
+
/**

  • HK2 factory to provide EJB components obtained via JNDI lookup.
    */
    @@ -158,13 +163,51 @@
    Injections.addBinding(Injections.newBinder(this).to(ResourceMethodInvocationHandlerProvider.class), configuration);
    configuration.commit();
    }
    +
    + private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException
    + {
    + ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class);
    + Applications applications = ejbUtil.getServices().getService(Applications.class);
    + String appNamePrefix = (String) initialContext.lookup("java:app/AppName");
    + Set<String> appNames = appRegistry.getAllApplicationNames();
    + Set<String> disabledApps = new TreeSet<>();
    + for (String appName : appNames) {
    + if (appName.startsWith(appNamePrefix))
    Unknown macro: {+ Application appDesc = applications.getApplication(appName);+ if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) { + // skip disabled version of the app + disabledApps.add(appName); + }+ else+ { + return ejbUtil.getDeployment().get(appName); + }+ }

    + }
    +
    + // grab the latest one, there is no way to make
    + // sure which one the user is actually enabling,
    + // so use the best case, i.e. upgrade
    + Iterator<String> it = disabledApps.iterator();
    + String lastDisabledApp = null;
    + while(it.hasNext())
    +

    { + lastDisabledApp = it.next(); + }

    + if(lastDisabledApp != null)

    { + return ejbUtil.getDeployment().get(lastDisabledApp); + }

    +
    + throw new NamingException("Application Information Not Found");
    + }

private void registerEjbInterceptor() {
try {
final Object interceptor = new EjbComponentInterceptor(locator);
initialContext = getInitialContext();
final EjbContainerUtil ejbUtil = EjbContainerUtilImpl.getInstance();

  • final ApplicationInfo appInfo = ejbUtil.getDeployment().get((String)initialContext.lookup("java:app/AppName"));
    + // FL Patch for https://java.net/jira/browse/GLASSFISH-21173
    + final ApplicationInfo appInfo = getApplicationInfo(ejbUtil);
    final List<String> tempLibNames = new LinkedList<String>();
    for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) {
    final String jarName = moduleInfo.getName();
Comment by lprimak [ 05/Oct/14 ]

Any updates on this issue?
Thanks

Comment by Hong Zhang [ 07/Oct/14 ]

Sorry, was not able to get to this due to other higher priority work. I will reassign to Marek to ask him to review the jersey patch to see what he thinks.

Comment by lprimak [ 07/Oct/14 ]

Thanks, Hong. Understand and appreciate it.

Comment by lprimak [ 23/Oct/14 ]

Any progress on this issue?
Thanks





[GLASSFISH-21440] Webservices don't work properly in 4.1.1 Created: 12/Oct/15  Updated: 18/Jun/16

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1.1
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: setup Assignee: Unassigned
Resolution: Unresolved Votes: 15
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux Ubuntu 15.04



 Description   

After switching from 4.1 to 4.1.1 webservices fail with error 500
server-log

[2015-10-11T07:32:14.904+1000] [glassfish 4.1] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=34 _ThreadName=http-listener-1(5)] [timeMillis: 1444512734904] [levelValue: 900] [[
  StandardWrapperValve[javax.ws.rs.core.Application]: Servlet.service() for servlet javax.ws.rs.core.Application threw exception
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.persistence.jaxb.BeanValidationHelper
	at org.eclipse.persistence.jaxb.JAXBBeanValidator.isConstrainedObject(JAXBBeanValidator.java:257)
	at org.eclipse.persistence.jaxb.JAXBBeanValidator.shouldValidate(JAXBBeanValidator.java:208)
	at org.eclipse.persistence.jaxb.JAXBMarshaller.validateAndTransformIfNeeded(JAXBMarshaller.java:587)
	at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:481)
	at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:949)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
	at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:683)
	at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:424)
	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:414)
	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:312)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:460)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
	at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
	at org.setupit.experiment.controller.util.URLFilter.doFilter(URLFilter.java:122)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:745)

------------------------------------------------------------

@Entity
@Table(name = "TITLE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Title.findAll", query = "SELECT t FROM Title t"),
    @NamedQuery(name = "Title.findById", query = "SELECT t FROM Title t WHERE t.id = :id"),
    @NamedQuery(name = "Title.findByTitle", query = "SELECT t FROM Title t WHERE t.title = :title"),
    @NamedQuery(name = "Title.findByFullTitle", query = "SELECT t FROM Title t WHERE t.fullTitle = :fullTitle")})
public class Title implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "title")
    private String title;
    @Size(max = 1024)
    @Column(name = "full_title")
    private String fullTitle;
    @OneToMany(mappedBy = "title")
    private List<User> userList;

    public Title() {
    }

    public Title(Integer id) {
        this.id = id;
    }

    public Title(Integer id, String title) {
        this.id = id;
        this.title = title;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getFullTitle() {
        return fullTitle;
    }

    public void setFullTitle(String fullTitle) {
        this.fullTitle = fullTitle;
    }

    @XmlTransient
    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Title)) {
            return false;
        }
        Title other = (Title) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return title + " (id=" + id + " )";
    }
    
}

-----------------------------------

@Stateless
@Path("title")
public class TitleService extends AbstractFacade<Title> {
    @PersistenceContext(unitName = "org.setupit_experiment_war_1.0PU")
    private EntityManager em;

    public TitleService() {
        super(Title.class);
    }

    @GET
    @Path("{id}")
    @Produces({MediaType.APPLICATION_JSON})
    public Title find(@PathParam("id") Integer id) {
        return super.find(id);
    }

    @GET
    @Override
    @Produces({MediaType.APPLICATION_JSON})
    public List<Title> findAll() {
        List<Title> lt = super.findAll();
        return lt;
    }

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
}

---------------------------

    <servlet>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>


 Comments   
Comment by reza_rahman [ 12/Oct/15 ]

I can confirm this happens with Cargo Tracker as well. It's a fairly serious usability problem.

Comment by Vinay Vishal [ 14/Oct/15 ]

Bean validation was introduced in Eclipselink 2.6.0 and that is where the NoClassDefFoundError is thrown.

This could be a case of missing entries in MANIFEST.MF in org.eclipse.persistence.moxy osgi bundle. Following link suggests so.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=463169
https://java.net/jira/browse/JERSEY-2888

Comment by Lukas Jungmann [ 14/Oct/15 ]

this seems to be fixed with eclipselink-2.6.1-RC2

Comment by Vinay Vishal [ 14/Oct/15 ]

Thanks Lukas, it worked when I tried locally with eclipselink-2.6.1-RC2.

Comment by setup [ 14/Oct/15 ]

I just tried to replace eclipselink-2.6.1-RC1 with eclipselink-2.6.1-RC2. it didn't resolve the problem. Any other suggestions?

Comment by Vinay Vishal [ 15/Oct/15 ]

In my case, I rebuilt Glassfish locally after bumping up eclipselink version. Its working fine for me. May be you can try stopping the domain, cleaning up your osgi-cache inside domains/<domain> directory, restart the domain and see if it works?

Comment by nicof6786 [ 15/Oct/15 ]

Hi,
I tried to get around this issue using Jackson as a media provider.
I ran into a similar issue even though it was not blocking.
On the first call and only on the first call to a Jax-Rs resource I get the following error :

java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector
        at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospector(JsonMapperConfigurator.java:109)
        at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospectors(JsonMapperConfigurator.java:84)
        at com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase._setAnnotations(MapperConfiguratorBase.java:120)
        at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator.getDefaultMapper(JsonMapperConfigurator.java:45)
        at com.fasterxml.jackson.jaxrs.base.ProviderBase.locateMapper(ProviderBase.java:864)
        at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:588)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
        at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130)
        at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:683)
        at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:424)
        at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:414)
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:312)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:292)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1139)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:460)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:386)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:334)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
        at java.lang.Thread.run(Thread.java:745)

The subsequent calls work fine.
Should I declare another issue ?

Comment by xwibao [ 19/Oct/15 ]

That nasty JERSEY-2888 definitely crept into GlassFish 4.1.1 :-\

As a quick & dirty fix, one can find glassfish/modules/org.eclipse.persistence.moxy.jar and fix META-INF/MANIFEST.MF inside it. Simply append the following to Import-Package:

,org.xml.sax.helpers,javax.xml.parsers;resolution:=optional,javax.naming;resolution:=optional

and restart. That worked for me.

Comment by setup [ 26/Oct/15 ]

Thank you!

Editing glassfish/modules/org.eclipse.persistence.moxy.jar helps

Comment by sebastian2 [ 30/Nov/15 ]

Hi there,
this bug is also blocking us from updating to the new Glassfish version.

Comment by pdurbin [ 04/Dec/15 ]

This issue is blocking us from upgrading from Glassfish 4.1 to Glassfish 4.1.1 because bean validation isn't working in the latter. Please see the following comment for details and a stacktrace: https://github.com/IQSS/dataverse/issues/2628#issuecomment-158197478

At https://javabot.evanchooly.com/logs/%23glassfish/2015-12-04 Ed Burns mentioned that this issue (GLASSFISH-21440) is the one I should be tracking so if "bean validation" could be added to the title, I would really appreciate it. We're looking forward to a release that has the bug fix (Glassfish 4.1.2 or whatever). We'll pass on Glassfish 4.1.1. (We already do enough patching of Glassfish 4.1 per the GitHub issue above and our goal is to avoid making our users patch Glassfish.)

Thanks for Glassfish. It's great. We're looking forward to upgrading. (I kind of want to play with Ozark.

Comment by Pavel Bucek [ 04/Dec/15 ]

If you just wan't to "play", you can checkout and build glassfish trunk, I believe the issue is resolved there.

Comment by basler [ 22/Dec/15 ]

This bug is blocking my upgrade, but the moxy patch listed above worked.

Comment by nabizamani [ 23/Jan/16 ]

Hello Oracle!!!! I can confirm this bug also exists also on Mac OS.

It's such a pity that you don't care about this serious issue! I'm writing tutorials based on Glassfish and I just decided to drop Glassfish for all my future tutorials because the quality of GF is disgusting compared to the times it was managed by Sun! I will use Tomcat instead, congrats!! I'm so disappointed. It's such a shame that this obvious issue is not even assigned yet!

Comment by atiqkhaled [ 09/Apr/16 ]

Hi
Did you try it for XML. I mean replace xml on @Produces(

{MediaType.APPLICATION_JSON}

) . Hope it works then.

Comment by nabizamani [ 14/Apr/16 ]

Helloooo Oracle, anyone working on this???

Comment by andradeb.david [ 23/May/16 ]

Hi in this post is a solution .
http://ayudasdesarrollo.blogspot.com.co/2016/05/glassfish-441-falla-con-jax-rs-y-json.html

Comment by sombriks [ 18/Jun/16 ]

hello,

i can confirm that the bug still there.

i know that java.net stuff is being deactivated, however this bug is going to be one year old soon, even though the solution is documented here.

The solution is there like a couple of weeks after the bug was reported.





[GLASSFISH-16518] Jersey: Allow regular users to run different Jersey versions in parallel on GlassFish Created: 02/May/11  Updated: 15/Jan/13

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: None
Fix Version/s: future release

Type: Improvement Priority: Major
Reporter: Jakub Podlesak Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Dependency
depends on GLASSFISH-13236 [jersey] Jersey bundles optionally de... Resolved
depends on GLASSFISH-16838 [OSGi] jersey-*** does export package... Resolved
depends on GLASSFISH-13165 Jersey uses DynamicImport-Package: * Open
blocks JERSEY-660 NPE in com.sun.jersey.core.impl.provi... Closed
Tags: ee7ri_cleanup_deferred

 Description   

So far, only administrators could make this work by changing container properties.
The feature is demanded to work also for regular users in hosted environments



 Comments   
Comment by scatari [ 16/Jun/11 ]

Approved for 3.1.1.

Comment by scatari [ 25/Jun/11 ]

Enhancement to be targeted post 3.1.1.

Comment by Tom Mueller [ 18/Oct/12 ]

Marking the fix version field as "future-release". This is based on an evaluation by John, Michael, and Tom WRT to the PRD for the Java EE 7 RI/SDK. This issue was deemed to not be a P1 for that release. If this is in error or there are other reasons why this RFE should be targeted for the Java EE 7 RI/SDK release, then change the fix version field back to an appropriate build.





[GLASSFISH-16520] Jersey: enable REST client injection Created: 02/May/11  Updated: 15/Jan/13

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: None
Fix Version/s: future release

Type: New Feature Priority: Major
Reporter: Jakub Podlesak Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: ee7ri_cleanup_deferred

 Comments   
Comment by Tom Mueller [ 18/Oct/12 ]

Marking the fix version field as "future-release". This is based on an evaluation by John, Michael, and Tom WRT to the PRD for the Java EE 7 RI/SDK. This issue was deemed to not be a P1 for that release. If this is in error or there are other reasons why this RFE should be targeted for the Java EE 7 RI/SDK release, then change the fix version field back to an appropriate build.





[GLASSFISH-17917] list-sub-components lists JAX-RS applications as <JSP>. Created: 07/Dec/11  Updated: 24/Jan/12

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: hosamu Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File helloworld-webapp.war    
Tags: 3_1_2-exclude

 Description   

I deployed a web application including a class that extends JAX-RS's javax.ws.rs.core.Application, and then execute asadmin list-sub-components command.

The jax-rs application class was listed as follows.

rest.RESTApp     <JSP>

Deployed application code is here.

RESTApp.java
package rest;

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

@ApplicationPath("/jaxrs")
public class RESTApp extends Application{
}

I think JAX-RS applications should be listed as "<Servlet>" or some kind of component name that represends JAX-RS application.

Same problem is exists in 'Edit Application' page of the admin console.



 Comments   
Comment by Hong Zhang [ 15/Dec/11 ]

I searched through the GlassFish workspace and don't see a sniffer called JSP sniffer, it must be something from the JAX-RS code. I am assigning to the JAX-RS team for initial evaluation to see what the expected behavior should be.

Comment by Hong Zhang [ 15/Dec/11 ]

Hmm who is the current owner of JAX-RS module, I chose Automatic with JAX-RS category, it did not get assigned to anybody..

Comment by Jakub Podlesak [ 16/Dec/11 ]

Attaching a web.xml-less WAR containing
an @ApplicationPath annotated JAX-RS application.

after deploying, i am getting:

%$AS_HOME/bin/asadmin list-components
helloworld-webapp <web>
Command list-components executed successfully.

Comment by Jakub Podlesak [ 16/Dec/11 ]

%$AS_HOME/bin/asadmin list-sub-components
Enter the value for the modulename operand> helloworld-webapp
default <Servlet>
jsp <Servlet>
com.sun.jersey.samples.helloworld.resources.MyApplication <JSP>
Command list-sub-components executed successfully.

Comment by Jakub Podlesak [ 16/Dec/11 ]

Now after adding web.xml and registering JAX-RS servlet explicitly:

%$AS_HOME/bin/asadmin list-sub-components
Enter the value for the modulename operand> helloworld-webapp
com.sun.jersey.samples.helloworld.resources.MyApplication <Servlet>
default <Servlet>
jsp <Servlet>
Command list-sub-components executed successfully.

I wonder why the [default] and [jsp] components are listed there.

Anyway, seems that the buggy JSP tagging has something to do with
descriptor-less scenarios only.





[GLASSFISH-18482] WEB9031: WebappClassLoader unable to load resource Created: 08/Mar/12  Updated: 10/Jul/12

Status: Reopened
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1.2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: cowwoc Assignee: Pavel Bucek
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Netbeans 7.1.1, Glassfish 3.1.2, JDK7 update 2


Attachments: Zip Archive HomesForHumans.zip    

 Description   

I don't know if this is related to GLASSFISH-14416 but every time I deploy my webapp on a fresh Glassfish instance I get this error:

INFO: Scanning for root resource and provider classes in the packages:
  com.homesforhumans.resource
INFO: Root resource classes found:
  class com.homesforhumans.resource.PostalCodesResource
INFO: No provider classes found.
INFO: Initiating Jersey application, version 'Jersey: 1.12 02/15/2012 04:51 PM'
INFO: WEB0671: Loading application [com.homesforhumans_HomesForHumans_war_1.0-SNAPSHOT] at [/context]
INFO: com.homesforhumans_HomesForHumans_war_1.0-SNAPSHOT was successfully deployed in 2,238 milliseconds.
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.46 started in: 3ms - bound to [0.0.0.0:8181]
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [javax.ws.rs.core.Response$Status], because it has not yet been started, or was already stopped
	at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1401)
	at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
	at com.sun.jersey.core.spi.factory.ResponseBuilderImpl.<init>(ResponseBuilderImpl.java:67)
	at com.sun.jersey.core.spi.factory.AbstractRuntimeDelegate.createResponseBuilder(AbstractRuntimeDelegate.java:99)
	at javax.ws.rs.core.Response$ResponseBuilder.newInstance(Response.java:356)
	at javax.ws.rs.core.Response.status(Response.java:104)
	at com.sun.jersey.api.Responses.status(Responses.java:127)
	at com.sun.jersey.api.Responses.notFound(Responses.java:103)
	at com.sun.jersey.api.NotFoundException.<init>(NotFoundException.java:68)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1484)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
	at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:895)
	at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:843)
	at com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:804)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)

I'm attaching my project file for your review.



 Comments   
Comment by Shing Wai Chan [ 28/Mar/12 ]

I notice the following incorrect elements in glassfish-web.xml
9a10,13
> <sun-web-app error-url="">
> <context-root>/context</context-root>
> <class-loader delegate="false"/>
> </sun-web-app>
10a15,18
> <sun-web-app error-url="">
> <context-root>/context</context-root>
> <class-loader delegate="false"/>
> </sun-web-app>

I have fixed the app in my local env.
It is deployed in 3.1.2 without error in server.log. But the app cannot be accessed.

When it is deployed in the 4.0 trunk, I saw the following in server.log:
[#|2012-03-28T14:06:42.492-0700|SEVERE|44.0|com.sun.jersey.core.spi.component.ProviderFactory|_ThreadID=72;_ThreadName=Thread-2;|The provider class, class com.sun.jersey.moxy.MoxyMessageBodyWorker, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NullPointerException
at com.sun.jersey.moxy.MoxyMessageBodyWorker.<init>(MoxyMessageBodyWorker.java:84)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:209)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:179)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1287)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:171)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:777)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:773)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:773)
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.initiate(GuiceContainer.java:121)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:607)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:719)
at com.google.inject.servlet.FilterDefinition.init(FilterDefinition.java:114)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:98)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4857)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5549)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:936)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:920)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2010)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1660)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:512)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:414)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:351)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:366)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1075)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1308)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1276)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:479)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:223)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:293)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispatch(HK2Dispatcher.java:113)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:236)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:164)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:816)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
at java.lang.Thread.run(Thread.java:722)

#]

[#|2012-03-28T14:06:42.495-0700|SEVERE|44.0|com.sun.jersey.core.spi.component.ProviderFactory|_ThreadID=72;_ThreadName=Thread-2;|The provider class, class com.sun.jersey.moxy.MoxyListMessageBodyWorker, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NullPointerException
at com.sun.jersey.moxy.MoxyMessageBodyWorker.<init>(MoxyMessageBodyWorker.java:84)
at com.sun.jersey.moxy.MoxyListMessageBodyWorker.<init>(MoxyListMessageBodyWorker.java:72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:209)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:179)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1287)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:171)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:777)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:773)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:773)
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.initiate(GuiceContainer.java:121)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:607)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:719)
at com.google.inject.servlet.FilterDefinition.init(FilterDefinition.java:114)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:98)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4857)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5549)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:936)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:920)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2010)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1660)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:512)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:414)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:351)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:366)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1075)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1308)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1276)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:479)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:223)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:293)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispatch(HK2Dispatcher.java:113)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:236)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:164)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:816)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
at java.lang.Thread.run(Thread.java:722)

#]

[#|2012-03-28T14:06:42.501-0700|SEVERE|44.0|com.sun.jersey.core.spi.component.ProviderFactory|_ThreadID=72;_ThreadName=Thread-2;|The provider class, class com.sun.jersey.multipart.impl.MultiPartReaderServerSide, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
at com.sun.jersey.multipart.impl.MultiPartReaderClientSide.<init>(MultiPartReaderClientSide.java:102)
at com.sun.jersey.multipart.impl.MultiPartReaderServerSide.<init>(MultiPartReaderServerSide.java:71)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:209)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:179)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1287)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:171)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:777)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:773)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:773)
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.initiate(GuiceContainer.java:121)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:607)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:719)
at com.google.inject.servlet.FilterDefinition.init(FilterDefinition.java:114)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:98)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4857)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5549)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:936)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:920)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2010)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1660)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:512)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:262)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:414)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:351)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:366)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1075)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:98)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1308)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1276)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:479)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:223)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:293)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispatch(HK2Dispatcher.java:113)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:236)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:164)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:816)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:567)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:547)
at java.lang.Thread.run(Thread.java:722)

#]
Comment by cowwoc [ 14/Jun/12 ]

This error only seems to occur when overriding the built-in version of Glassfish by setting:

<class-loader delegate="false"/>
Comment by cowwoc [ 14/Jun/12 ]

Shing Wai Chan,

I don't understand your last post. What are the incorrect elements in glassfish.xml? It looks right to me.

Comment by cowwoc [ 14/Jun/12 ]

Good news! It looks like this issue is caused by setting:

<class-loader delegate="false"/>

in glassfish.xml but neglecting to set:

-Dcom.sun.enterprise.overrideablejavaxpackages=javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext

in domain.xml. The full instructions can be found here: http://jersey.java.net/nonav/documentation/latest/glassfish.html#d4e1903

In light of this discovery, is there a way to get Glassfish to throw a less misleading error message?

Also, can anyone reproduce this error in spite of following the above steps?

Comment by Pavel Bucek [ 15/Jun/12 ]

not about jersey anymore, user requests change in error reporting.

btw see http://java.net/jira/browse/GLASSFISH-13134 for full context.

Comment by Shing Wai Chan [ 09/Jul/12 ]

In Java EE 6, we cannot override the javax.* packages even with delegate flag.
We will mark this as a duplicate of the improvement task has been filed http://java.net/jira/browse/GLASSFISH-13134 .

Comment by cowwoc [ 10/Jul/12 ]

Shing,

Regardless of when GLASSFISH-13134 is implemented, we need to improve the error message. GLASSFISH-13134 does not cover this. Can we reopen this issue?

Comment by Shing Wai Chan [ 10/Jul/12 ]

Per request, we will reopen the bug for a better error message.





[GLASSFISH-20505] @PostConstruct method called twice on @Singleton Created: 10/May/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b87_RC3
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: agksmehx Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Oracle JDK 7, Linux Fedora 18 64-bit, Eclipse Kepler m6


Tags: 4_0-exclude, ejb_container, jax-rs

 Description   

I am running a simple .war file under Glassfish 4.0-b87 that was created in Eclipse Kepler M6 using M2E as a simple project with Dynamic Web Module facet added, using Oracle Java 7 JDK/JVM.

There is essentially a single class for which I expect the `post_construct` method to be called exactly once. But it is called twice, first when the app is deployed, and one more time on the first and only the first HTTP request.

Here is the class (the log output follows). It should print "hello world" only once but in the log it can be seen twice.

    package com.example.main;
    
    import javax.annotation.PostConstruct;
    import javax.annotation.PreDestroy;
    import javax.ejb.LocalBean;
    import javax.ejb.PostActivate;
    import javax.ejb.PrePassivate;
    import javax.ejb.Singleton;
    import javax.ejb.Startup;
    import javax.enterprise.inject.spi.PassivationCapable;
    import javax.ws.rs.ApplicationPath;
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.core.Application;
    
    @Singleton
    @Startup
    @LocalBean
    @ApplicationPath("/rest")
    @Path("/life")
    public class Life extends Application implements PassivationCapable {
    
      @PostConstruct
      public void post_construct () {
        System.out.println("hello world!");
      }
    
      @PreDestroy
      public void pre_destroy () {
        System.out.println("so long and thanks for the fish!");
      }
    
      @PrePassivate
      public void pre_passivate () {
        System.out.println("taking a break");
      }
    
      @PostActivate
      public void post_activate () {
        System.out.println("back from break");
      }
    
      @Override
      public String getId () {
        return "life";
      }
    
      @GET
      public String greet () {
        return "hi";
      }
    }

The log output is as follows with a dashed line separating the part before the first HTTP call and the part after the HTTP call:

[2013-05-09T19:42:26.660-1000] [glassfish 4.0] [INFO] [NCLS-DEPLOYMENT-00027] [javax.enterprise.system.tools.deployment.autodeploy] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546660] [levelValue: 800] [[
Selecting file /usr/local/glassfish4/glassfish/domains/domain1/autodeploy/singleton.war for autodeployment]]

[2013-05-09T19:42:26.692-1000] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546692] [levelValue: 800] [[
visiting unvisited references]]

[2013-05-09T19:42:26.702-1000] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546702] [levelValue: 800] [[
visiting unvisited references]]

[2013-05-09T19:42:26.706-1000] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546706] [levelValue: 800] [[
visiting unvisited references]]

[2013-05-09T19:42:26.709-1000] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546709] [levelValue: 800] [[
visiting unvisited references]]

[2013-05-09T19:42:26.749-1000] [glassfish 4.0] [INFO] [ejb.portable_jndi_names] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546749] [levelValue: 800] [[
EJB5181:Portable JNDI names for EJB Life: [java:global/singleton/Life, java:global/singleton/Life!com.example.main.Life]]]

[2013-05-09T19:42:26.959-1000] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546959] [levelValue: 900] [[
WELD-001473 javax.enterprise.inject.spi.Bean implementation org.glassfish.jms.injection.JMSCDIExtension$LocalBean@cbcbf4a declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]]

[2013-05-09T19:42:26.970-1000] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=59 _ThreadName=Thread-3] [timeMillis: 1368164546970] [levelValue: 800] [[
hello world!]]

[2013-05-09T19:42:26.982-1000] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546982] [levelValue: 800] [[
Registering the Jersey servlet application, named com.example.main.Life, at the servlet mapping /rest/*, with the Application class of the same name.]]

[2013-05-09T19:42:26.988-1000] [glassfish 4.0] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164546988] [levelValue: 800] [[
Loading application [singleton] at [/singleton]]]

[2013-05-09T19:42:27.003-1000] [glassfish 4.0] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164547003] [levelValue: 800] [[
singleton was successfully deployed in 332 milliseconds.]]

[2013-05-09T19:42:27.006-1000] [glassfish 4.0] [INFO] [NCLS-DEPLOYMENT-00035] [javax.enterprise.system.tools.deployment.autodeploy] [tid: _ThreadID=59 _ThreadName=AutoDeployer] [timeMillis: 1368164547006] [levelValue: 800] [[
[AutoDeploy] Successfully autodeployed : /usr/local/glassfish4/glassfish/domains/domain1/autodeploy/singleton.war.]]

-----------------------------AFTER FIRST HTTP CALL-----------------------------

[2013-05-09T19:42:44.940-1000] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=21 _ThreadName=Thread-3] [timeMillis: 1368164564940] [levelValue: 800] [[
hello world!]]

[2013-05-09T19:42:44.940-1000] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.server.ApplicationHandler] [tid: _ThreadID=21 _ThreadName=http-listener-1(4)] [timeMillis: 1368164564940] [levelValue: 800] [[
Initiating Jersey application, version Jersey: 2.0-rc2 2013-04-23 12:04:25...]]

[2013-05-09T19:42:44.956-1000] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.gf.ejb.EjbComponentProvider] [tid: _ThreadID=21 _ThreadName=http-listener-1(4)] [timeMillis: 1368164564956] [levelValue: 800] [[
The Jersey EJB interceptor is bound. JAX-RS EJB integration support is enabled.]]



 Comments   
Comment by agksmehx [ 10/May/13 ]

I got a stack trace of the second singleton creation by making it throw an error if a static boolean was found initialized to true

java.lang.Error: second singleton
at com.example.Life.post_construct(Life.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1010)
at org.jvnet.hk2.internal.Utilities.justPostConstruct(Utilities.java:735)
at org.jvnet.hk2.internal.ServiceLocatorImpl.postConstruct(ServiceLocatorImpl.java:818)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:864)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:855)
at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:293)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:272)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)

Comment by marina vatkina [ 10/May/13 ]

no EJB container code in the stack

Comment by agksmehx [ 10/May/13 ]

Essentially the @Singleton annotation is not playing well the @ApplicationPath + "extends Application" part. When I created a separate class for @ApplicationPath + "extends Application" and left the @Singleton + @Path together, things seemed fine (although I don't know whether Jersey would create more singletons under load).

What does the standard say about putting @Application, @Singleton, @Path all on the same class?

Comment by Marek Potociar [ 14/May/13 ]

Updated java code formatting in the issue desc.

Comment by Jakub Podlesak [ 14/May/13 ]

JAX-RS/EJB integration does not work fully for Application subclasses. There are some technical difficulties
as Application subclasses are involved in application bootstrapping. Jersey only makes sure certain scenarios work
(e.g. @PostConstruct/@PreDestroy annotated methods are invoked at all). The rest (like e.g. this one, that @Singleton annotated
beans should get created just once per an application) should be resolved
with future Jersey releases.

I recommend to stick with the above described workaround (keep separate classes for application and JAX-RS resources/providers)
until this gets resolved.

Comment by Jakub Podlesak [ 14/May/13 ]

deferred to 4.0.1

Comment by agksmehx [ 15/May/13 ]

love the formatting: "so long and thanks for the fish", "taking a break"

seriously, thank you marek for fixing the formatting and thank you jakub and everybody else for your very kind attention. love glassfish + jersey!

Comment by rdelaplante [ 28/Jun/13 ]

I'm getting @PostConstruct called twice in a row on this class in GlassFish 4.0 release:

@Singleton
@Startup
public class LoggingService {

@Inject @Cached
private SystemSettings systemSettings;

@PostConstruct
public void initializeLogAppenders()

{ LogManager.resetConfiguration(); PropertyConfigurator.configure( systemSettings.getRuntimeDataPath() + "logging.properties"); }

@PreDestroy
public void closeLogAppenders()

{ LogManager.shutdown(); }

}





[GLASSFISH-20515] [fishcat] codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "name" (Class com.demo.User), not marked as ignorable Created: 13/May/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b88_RC4
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: survivant Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Product Version: NetBeans IDE Dev (Build 201305052300)
Java: 1.7.0_13; Java HotSpot(TM) Client VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_13-b20
System: Windows XP version 5.1 running on x86; Cp1252; fr_CA (nb)
User directory: C:\Documents and Settings\sdionne1\Application Data\NetBeans\dev
Cache directory: C:\Documents and Settings\sdionne1\Local Settings\Application Data\NetBeans\Cache\dev


Tags: 4_0-exclude, fishcat, jax-rs, rest

 Description   

I used Netbeans to generate a jax-rs resources and config to test a jax-rs application.

I also used Netbeans to generate the jax-rs client from the HelloResources.

The problem is when I try to consume a "application/json" into a User object. I obtain this stacktrace in GF 4.0 latest promoted build.

I'll provide the source code at the end of the stacktrace.

INFO: class com.demo.CDIManagedBean post construct
INFO: class com.demo.HelloResource post construct
WARNING: StandardWrapperValve[org.netbeans.rest.application.config.ApplicationConfig]: Servlet.service() for servlet org.netbeans.rest.application.config.ApplicationConfig threw exception
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "name" (Class com.demo.User), not marked as ignorable
at [Source: org.glassfish.jersey.message.internal.EntityInputStream@d03ff; line: 1, column: 10] (through reference chain: com.demo.User["name"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:181)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:72)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:134)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:828)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:833)
at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:245)
at org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.get(EntityParamValueFactoryProvider.java:96)
at org.glassfish.jersey.server.internal.inject.AbstractHttpContextValueFactory.provide(AbstractHttpContextValueFactory.java:66)
at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:121)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:136)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:323)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)

package com.demo;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author sdionne1
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class User {
    
    public String name;
    public String lastname;

}
package com.demo;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
 *
 * @author sdionne1
 */
@Path("hello")
public class HelloResource {
    
    @Inject            
    CDIManagedBean bean;
    
    @Inject
    EJBManagedBean ejb;
    
    @PostConstruct
    public void init(){
        System.out.println(HelloResource.class + " post construct");
    } 
    
    @GET
    @Produces("text/plain")
    public String getHello(){
        return "hello : " + bean.getOutput() + "  : " + ejb.getOutput();
    }
    
    @POST
    @Consumes("text/plain")
    public void sayHello(String message){
        System.out.println("Say Hello : " + message);
    }
    
    @POST
    @Consumes("application/json")
    public void helloJson(User user){
        System.out.println("helloJson user : " + user);
    }
}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.demo;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;

/**
 * Jersey REST client generated for REST resource:HelloResource [hello]<br>
 * USAGE:
 * <pre>
 *        NewJerseyClient client = new NewJerseyClient();
 *        Object response = client.XXX(...);
 *        // do whatever with response
 *        client.close();
 * </pre>
 *
 * @author sdionne1
 */
public class NewJerseyClient {
    private WebResource webResource;
    private Client client;
    private static final String BASE_URI = "http://localhost:8080/WebApplication1/resources";

    public NewJerseyClient() {
        com.sun.jersey.api.client.config.ClientConfig config = new com.sun.jersey.api.client.config.DefaultClientConfig();
        client = Client.create(config);
        webResource = client.resource(BASE_URI).path("hello");
    }

    public void helloJson(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.APPLICATION_JSON).post(requestEntity);
    }

    public String getHello() throws UniformInterfaceException {
        WebResource resource = webResource;
        return resource.accept(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
    }

    public void sayHello(Object requestEntity) throws UniformInterfaceException {
        webResource.type(javax.ws.rs.core.MediaType.TEXT_PLAIN).post(requestEntity);
    }

    public void close() {
        client.destroy();
    }
    
    public static void main(String[] args){
        NewJerseyClient client = new NewJerseyClient();
        
        User user = new User();
        user.name="name1";
        user.lastname="lastname2";
        
        client.helloJson(user);
        
        client.close();
    }
}


 Comments   
Comment by survivant [ 13/May/13 ]

I can provide the source code in zip if you give my your email address.

thanks

Comment by Marek Potociar [ 14/May/13 ]

Updated java listing formatting in the issue desc.

Comment by Jakub Podlesak [ 14/May/13 ]

Deferred to 4.0.1.

Comment by survivant [ 17/May/13 ]

I created a new project and Netbeans dev, this time found some JSON providers.

Personnaly, I think Netbeans shouldn't override the method : getClasses(...) and let the container auto-detect the providers.

That method should be use if you want to force a provider, if not, the code won't be portable unless we add specific jars in the war.

My goal was to create a simple demo to show JSON -> Pojo with jax-rs that will work "out-of-the-box" in GF4 or Wildfly.. any JavaEE6 ou Java7 container without specific jax-rs implementation.

package org.netbeans.rest.application.config;

import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

/**
*

  • @author sdionne1
    */
    @ApplicationPath("resources")
    public class ApplicationConfig extends Application {

/**

  • Do not modify addRestResourceClasses() method.
  • It is automatically re-generated by NetBeans REST support to populate
  • given list with all resources defined in the project.
    */
    @Override
    public Set<Class<?>> getClasses()
    Unknown macro: { Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); // following code can be used to customize Jersey 2.0 JSON provider}

private void addRestResourceClasses(Set<Class<?>> resources)

{ resources.add(com.demo.HelloResource.class); }

}

Comment by survivant [ 20/May/13 ]

wierd. The code wasn't right when I saved it in the previous comment.

try

{ Class jsonProvider = Class.forName("org.glassfish.jersey.jackson.JacksonFeature"); // Class jsonProvider = Class.forName("org.glassfish.jersey.moxy.json.MoxyJsonFeature"); // Class jsonProvider = Class.forName("org.glassfish.jersey.jettison.JettisonFeature"); resources.add(jsonProvider); }

catch (ClassNotFoundException ex)

{ java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, null, ex); }

addRestResourceClasses(resources);
return resources;
}

private void addRestResourceClasses(Set<Class<?>> resources)

{ resources.add(com.demo.HelloResource.class); }




[GLASSFISH-20576] Internal Server Error on JSON REST web service returning array Created: 23/May/13  Updated: 21/Dec/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: Peter Salomonsen Assignee: Marek Potociar
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

glassfish-4.0-b90-05_22_2013, jdk1.7


Tags: glassfish4, jersey, json, rest

 Description   

The following REST web service causes internal server error (and no stack trace in server.log). Returning an empty array works, but as soon as there are elements in the array - it does not.

@GET
@Produces("application/json")
public Object[] getArray() {
return new Object[]

{"Test"}

;
}



 Comments   
Comment by Marek Potociar [ 28/May/13 ]

Targeting for GF 4.0.1, Re-assigning to dev eng. for evaluation.

Comment by Michal Gajdos [ 11/Jun/13 ]

Which Json provider from Jersey are you using? Have you configured one? Thanks.

Comment by Peter Salomonsen [ 11/Jun/13 ]

I haven't configured anything - no web.xml at all. Just application config class like this:

@javax.ws.rs.ApplicationPath("webresources")
public class ApplicationConfig extends Application {

}

And the REST service class:

@Path("generic")
public class GenericResource {

@Context
private UriInfo context;

public GenericResource() {
}

@GET
@Produces("application/json")
public Object[] getArray() {
return new Object[]

{"Test"}

;
}
}

That's all.

Comment by Michal Gajdos [ 13/Jun/13 ]

The easiest way would be registering JacksonFeature (make sure you have jersey-media-json-jackson on your classpath) in your ApplicationConfig. Something like:

public Set<Class<?>> getClasses() {
    return new HashSet<Class<?>>() {{ add(GenericResource.class); add(JacksonFeature.class); }};
}
Comment by Peter Salomonsen [ 13/Jun/13 ]

org.glassfish.jersey.jackson.JacksonFeature works as you propose. MoxyJsonFeature gives the server error, and JettisonFeature says it cannot find a MessageBodyWriter. Is MoxyJsonFeature the default? Shouldn't this also be able to handle arrays?





[GLASSFISH-20590] Response.created(URI) does not convert relative URI to absolute Created: 29/May/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: Aslak Knutsen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JERSEY-1910 Response.created(URI) does not conver... Closed
is related to JERSEY-1910 Response.created(URI) does not conver... Closed

 Description   

According to the JavaDoc for Response:

   /**
    * Create a new ResponseBuilder for a created resource, set the location
    * header using the supplied value.
    *
    * @param location the URI of the new resource. If a relative URI is
    *                 supplied it will be converted into an absolute URI by resolving it
    *                 relative to the request URI (see {@link UriInfo#getRequestUri}).
    * @return a new ResponseBuilder
    * @throws java.lang.IllegalArgumentException
    *          if location is null
    */
   public static ResponseBuilder created(URI location)

Given:

@Path("/conference")
public class ConferenceResource {

    @POST
    @Consumes({"application/vnd.ced+xml"})
    public Response create(ConferenceRepresentation conferenceRepresenttion) {
        Conference conference = conferenceRepresenttion.toConference();
        repository.store(conference);
        return Response.created(UriBuilder.fromResource(ConferenceResource.class)
                            .segment("{id}")
                            .build(conference.getId())).build();
    }
}

Result:

DEBUG [org.apache.http.wire] >> "POST /f5255003-a267-4f28-9c65-775a19325621/api/conference HTTP/1.1[\r][\n]"
DEBUG [org.apache.http.wire] >> "Accept: */*[\r][\n]"
DEBUG [org.apache.http.wire] >> "Content-Length: 251[\r][\n]"
DEBUG [org.apache.http.wire] >> "Content-Type: application/vnd.ced+xml; type=conference; charset=ISO-8859-1[\r][\n]"
DEBUG [org.apache.http.wire] >> "Host: localhost:8080[\r][\n]"
DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[\r][\n]"
DEBUG [org.apache.http.wire] >> "Accept-Encoding: gzip,deflate[\r][\n]"
DEBUG [org.apache.http.wire] >> "[\r][\n]"
DEBUG [org.apache.http.wire] >> "<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><ns2:conference xmlns:ns2="urn:ced:conference"><end>2013-05-30T01:06:51.448+02:00</end><name>Test</name><start>2013-05-30T01:06:51.448+02:00</start><tagLine>Tagline</tagLine></ns2:conference>"
DEBUG [org.apache.http.wire] << "HTTP/1.1 201 Created[\r][\n]"
DEBUG [org.apache.http.wire] << "X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition  4.0  Java/Oracle Corporation/1.7)[\r][\n]"
DEBUG [org.apache.http.wire] << "Server: GlassFish Server Open Source Edition  4.0 [\r][\n]"
DEBUG [org.apache.http.wire] << "Location: /conference/6bd9902e-39b1-45b9-b3d4-d618ee782a25[\r][\n]"
DEBUG [org.apache.http.wire] << "Date: Wed, 29 May 2013 23:06:51 GMT[\r][\n]"
DEBUG [org.apache.http.wire] << "Content-Length: 0[\r][\n]"
DEBUG [org.apache.http.wire] << "[\r][\n]"

Expected:

Location: http://localhost:8080/f5255003-a267-4f28-9c65-775a19325621/api/conference/6bd9902e-39b1-45b9-b3d4-d618ee782a25



 Comments   
Comment by Libor Kramolis [ 04/Nov/13 ]

Jersey issue JERSEY-1910 is already fixed.





[GLASSFISH-20591] JAX-RSResponse.status(404) is overwritten by WebContainer Created: 29/May/13  Updated: 21/Sep/15

Status: Open
Project: glassfish
Component/s: jax-rs, web_container
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: Aslak Knutsen Assignee: Miroslav Fuksa
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JERSEY-1909 JAX-RSResponse.status(404) is overwri... Closed

 Description   

Given:

@Path("/conference")
public class ConferenceResource implements Resource {
 
    private static final String BASE_MEDIA_TYPE = "application/vnd.ced+xml";
    private static final String CONFERENCE_MEDIA_TYPE = BASE_MEDIA_TYPE + ";type=conference";
    private static final String SESSION_MEDIA_TYPE = BASE_MEDIA_TYPE + ";type=session";
 
...
 
    @GET
    @Path("/{id}")
    @Produces("application/vnd.ced+xml")
    public Response get(@PathParam("id") String id) {
        Conference conference = repository.get(id);
        if(conference == null) {
            return Response.status(Status.NOT_FOUND).type(CONFERENCE_MEDIA_TYPE).build();
        }
        return Response.ok(
                new ConferenceRepresentation(conference, uriInfo.getAbsolutePathBuilder()))
                .type(CONFERENCE_MEDIA_TYPE).build();
    }
...
}

Expected:

Content-Type: application/vnd.ced+xml; type=conference
[Empty Body]

Result:

When the Resource is not found (http 404 is returned by JAX-RS), the WebContainer takes over and returns Content-Type: text/html and the standard Error page as a body.

wire log

DEBUG [org.apache.http.wire] >> "GET /3998f027-d794-4650-9144-aac9990f26bd/api/conference/b849d477-fb42-4e93-9902-84e0741d1ffb HTTP/1.1[\r][\n]"
DEBUG [org.apache.http.wire] >> "Accept: application/vnd.ced+xml; type=conference[\r][\n]"
DEBUG [org.apache.http.wire] >> "Host: localhost:8080[\r][\n]"
DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[\r][\n]"
DEBUG [org.apache.http.wire] >> "Accept-Encoding: gzip,deflate[\r][\n]"
DEBUG [org.apache.http.wire] >> "[\r][\n]"
DEBUG [org.apache.http.wire] << "HTTP/1.1 404 Not Found[\r][\n]"
DEBUG [org.apache.http.wire] << "X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition  4.0  Java/Oracle Corporation/1.7)[\r][\n]"
DEBUG [org.apache.http.wire] << "Server: GlassFish Server Open Source Edition  4.0 [\r][\n]"
DEBUG [org.apache.http.wire] << "Content-Language: [\r][\n]"
DEBUG [org.apache.http.wire] << "Content-Type: text/html[\r][\n]"
DEBUG [org.apache.http.wire] << "Date: Wed, 29 May 2013 23:29:43 GMT[\r][\n]"
DEBUG [org.apache.http.wire] << "Content-Length: 1082[\r][\n]"
DEBUG [org.apache.http.wire] << "[\r][\n]"
DEBUG [org.apache.http.wire] << "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition  4.0  - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Not Found</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>Not Found</p><p><b>description</b>The requested resource is not available.</p><hr/><h3>GlassFish Server Open Source Edition  4.0 </h3></body></html>"





[GLASSFISH-20640] Injection of HttpServletRequest-Context in ContainerRequestFilter does not work Created: 17/Jun/13  Updated: 19/Sep/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Wasomumba Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The Injection of HttpServletRequest-Context in ContainerRequestFilter does not work.

I get the following error:

java.lang.IllegalStateException: Not inside a request scope.

Here is the source of an example filter:

package de.aidaorga.ewas.configcentral.auth;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;

@Provider
public class LoggerFilter implements ContainerRequestFilter {

    @Context
    HttpServletRequest httpRequest;

    @Override
    public void filter(ContainerRequestContext requestContext) {
        System.out.println("httpRequest = " + httpRequest);
    }
}

The full stack trace:

SEVERE:   WebModule[/ewas-configcentral]StandardWrapper.Throwable
MultiException stack 1 of 3
java.lang.IllegalStateException: Not inside a request scope.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:149)
	at org.glassfish.jersey.process.internal.RequestScope.current(RequestScope.java:225)
	at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:153)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:579)
	at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:87)
	at org.glassfish.jersey.internal.inject.ReferencingFactory.provide(ReferencingFactory.java:101)
	at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:104)
	at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:208)
	at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:231)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:583)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:393)
	at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:157)
	at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:280)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:277)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:722)
MultiException stack 2 of 3
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of de.aidaorga.ewas.configcentral.auth.LoggerFilter errors were found
	at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:243)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:583)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:393)
	at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:157)
	at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:280)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:277)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:722)
MultiException stack 3 of 3
java.lang.IllegalStateException: Unable to perform operation: resolve on de.aidaorga.ewas.configcentral.auth.LoggerFilter
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:357)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:583)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:393)
	at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:157)
	at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:280)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:277)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:722)

WARNING:   StandardWrapperValve[de.aidaorga.ewas.configcentral.ApplicationConfig]: Allocate exception for servlet de.aidaorga.ewas.configcentral.ApplicationConfig
java.lang.IllegalStateException: Not inside a request scope.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:149)
	at org.glassfish.jersey.process.internal.RequestScope.current(RequestScope.java:225)
	at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:153)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:579)
	at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:87)
	at org.glassfish.jersey.internal.inject.ReferencingFactory.provide(ReferencingFactory.java:101)
	at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:104)
	at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:208)
	at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:231)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
	at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:118)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2294)
	at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
	at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:583)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:393)
	at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:157)
	at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:280)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:277)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:262)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1225)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:237)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:722)



 Comments   
Comment by paulkmoore [ 20/Aug/13 ]

See https://java.net/jira/browse/JERSEY-1960





[GLASSFISH-20655] 500 error in browser - nothing in server logs Created: 21/Jun/13  Updated: 21/Dec/15

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: 4.1.1

Type: Bug Priority: Major
Reporter: walec51 Assignee: Marek Potociar
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I have no idea whats wrong because there is no error message anywhere.

Try to run the attached project from the latest Netbeans with GF 4 and entering:
http://localhost:8080/PcRepairLocations/



 Comments   
Comment by walec51 [ 21/Jun/13 ]

Project: http://walczak.it/files/PcRepairLocations2.zip

Comment by walec51 [ 21/Jun/13 ]

In the browser I get:

HTTP Status 500 - Internal Server Error

type Status report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

GlassFish Server Open Source Edition 4.0

Comment by walec51 [ 21/Jun/13 ]

adding the produced annotation to:

@GET
    @Produces(MediaType.TEXT_HTML)
    public Viewable getIndex() {
        Map<String, Object> model = new HashMap<>();
        model.put("repairLocations", repairLocationRepository.getAll());
        return new Viewable("WEB-INF/index.jsp", model);
    }

stooped the strange 500 but still something should appear in the lost even without it

Comment by michael.y.chen [ 24/Jun/13 ]

please reassign if needed.

Comment by Shing Wai Chan [ 24/Jun/13 ]

The given application has JAX-RS, EJB and persistent. Assign to JAX-RS team for evaluation.





[GLASSFISH-20699] GlassFish returns 500 instead of 404 upon WebApplicationException Created: 14/Jul/13  Updated: 11/Dec/13

Status: Reopened
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: svanimpe Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OSX Mavericks Preview 3


Attachments: Text File cdi-transaction-rollback.patch     Zip Archive GlassFish-20699.zip     Zip Archive GlassFish-20699_updated.zip    
Issue Links:
Related
is related to JAX_RS_SPEC-440 WebApplicationException contract coul... Open

 Description   

The following method does not return a status of 404 Not Found, but instead returns a 500 Internal Server Error.

@Path("something")
public class Something {

@GET
public String getSomething()

{ throw new WebApplicationException(Status.NOT_FOUND); }

}

This used to work fine with GlassFish 3.1.
I do not have this problem when returning Status.BAD_REQUEST.



 Comments   
Comment by svanimpe [ 11/Sep/13 ]

Can someone please take a look at this ? Two months later and this issue is still exactly the same.

I can also add that the same thing happens with "throw new WebApplicationException(Status.FORBIDDEN)", as well as with "throw new NotFoundException()" and "throw new ForbiddenException()".

Comment by TangYong [ 11/Sep/13 ]

I made a sample the same as you said, however, my sample ran well, and 404 error can be displayed normally.

[Steps]
1. mvn clean install
2. asadmin deploy ...
3. accessing "http://localhost:8080/glassfish-20699/webapi/test/"

So, pl. seeing whether having any wrong config in your sample.

Then, I will close the jira.

Thanks
Tang

Comment by svanimpe [ 11/Sep/13 ]

Hi Tang,

The problem seems to be reproducible if you add @Transactional to the class in the sample.
In that case you no longer get a 404 but a 500 with a RollbackException.

Comment by TangYong [ 11/Sep/13 ]

Surly, if adding javax.transaction.Transactional into TestService class(GlassFish-20699_updated.zip), 500 error happened, and in the server.log,

[2013-09-11T19:01:03.780+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.resource.jta.org.glassfish.cdi.transaction] [tid: _ThreadID=39 _ThreadName=http-listener-1(4)] [timeMillis: 1378893663780] [levelValue: 800] [[
In REQUIRED TransactionalInterceptor]]

[2013-09-11T19:01:03.952+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.resource.jta.org.glassfish.cdi.transaction] [tid: _ThreadID=39 _ThreadName=http-listener-1(4)] [timeMillis: 1378893663952] [levelValue: 800] [[
Managed bean with Transactional annotation and TxType of REQUIRED called outside a transaction context. Beginning a transaction...]]

[2013-09-11T19:01:03.999+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.resource.jta.org.glassfish.cdi.transaction] [tid: _ThreadID=39 _ThreadName=http-listener-1(4)] [timeMillis: 1378893663999] [levelValue: 800] [[
About to setRollbackOnly from @Transactional interceptor on transaction:JavaEETransactionImpl: txId=1 nonXAResource=null jtsTx=null localTxStatus=0 syncs=[]]]

[2013-09-11T19:01:04.015+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.resource.jta.org.glassfish.cdi.transaction] [tid: _ThreadID=39 _ThreadName=http-listener-1(4)] [timeMillis: 1378893664015] [levelValue: 800] [[
Managed bean with Transactional annotation and TxType of REQUIRED encountered exception during commit javax.transaction.RollbackException: Transaction marked for rollback.]]

[2013-09-11T19:01:04.015+0900] [glassfish 4.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=39 _ThreadName=http-listener-1(4)] [timeMillis: 1378893664015] [levelValue: 900] [[
StandardWrapperValve[javax.ws.rs.core.Application]: Servlet.service() for servlet javax.ws.rs.core.Application threw exception
javax.transaction.RollbackException: Transaction marked for rollback.
at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:445)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:854)
at com.sun.enterprise.transaction.TransactionManagerHelper.commit(TransactionManagerHelper.java:81)
at org.glassfish.cdi.transaction.TransactionalInterceptorRequired.transactional(TransactionalInterceptorRequired.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.jboss.weld.interceptor.proxy.SimpleMethodInvocation.invoke(SimpleMethodInvocation.java:30)
at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNext(AbstractInterceptionChain.java:93)
at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNextInterceptor(AbstractInterceptionChain.java:78)
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:48)
at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:41)
at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53)
at org.jboss.weld.proxies.TestService$Proxy$_$$_WeldSubclass.greet(Unknown Source)
at org.jboss.weld.proxies.TestService$Proxy$_$$_WeldClientProxy.greet(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:140)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:158)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:195)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:101)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:353)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:343)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:237)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:211)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:982)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:359)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:359)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:496)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:175)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:187)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:722)
]]

So, forwarding to jta comp firstly to evaluate the issue.

Comment by TangYong [ 11/Sep/13 ]

According to the JTA 1.2 specification, any unchecked Exception will automatically rollback the transaction. So, for the sample, "throw new WebApplicationException(Status.NOT_FOUND);" will cause rollback the transaction.

Then, the exception stack should be right, however, a point needs to be confirmed, whether 500 error is right?

Thanks
Tang

Comment by svanimpe [ 11/Sep/13 ]

I can verify that this does indeed happen with all my WebApplicationExceptions. In the past (Java EE 6, so no @Transactional), this did not happen when returning a Bad Request, but now it does too. I can work around it by returning a Response object from every method, but that's very cumbersome.

The API docs for WebApplicationException say the following:
This exception may be thrown by a resource method, provider or StreamingOutput implementation if a specific HTTP error response needs to be produced.

So a 500 response is not what one would expect when using these exceptions.

Comment by marina vatkina [ 11/Sep/13 ]

Assigning to the web-container to check which response code is appropriate

Comment by Shing Wai Chan [ 11/Sep/13 ]

This is a jaxrs application. Assign to jaxrs team.

Comment by Shing Wai Chan [ 11/Sep/13 ]

This is a jaxrs application. Assign to jax-rs team.

Comment by TangYong [ 11/Oct/13 ]

Waiting the fix of https://java.net/jira/browse/JERSEY-2137.

Comment by Jakub Podlesak [ 06/Dec/13 ]

Just to confirm, the expected behaviour should be: 404 is returned back a no rollback happens, right?

Comment by TangYong [ 06/Dec/13 ]

Jakub,

IMHO, based on the following and [1], while specifying Status.NOT_FOUND, an user should see 404 rather than 500. As for rollback, this should be guaranteed by JTA 1.2 Spec, even if the sample can not demostrate the point well.

@GET
public String getSomething()

{ throw new WebApplicationException(Status.NOT_FOUND); }

[1]: http://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Response.Status.html

Tang

Comment by Jakub Podlesak [ 09/Dec/13 ]

We could probably fix this in JAX-RS/CDI integration layer. However, i believe this should be fixed in the application itself.
The problem is, combination of JTA/JAX-RS is not covered by either of the spec. Now, you complain JAX-RS WebApplicationException
contract is broken. If we fixed the runtime, someone else could complain the JTA @Transactional contract is broken, i.e. a non-checked exception
is thrown and no rollback happens.

I believe the right thing to do in your case is to fix the application code as follows:
Instead of plain

@Transactional

annotation, you should rather
be using

@Transactional(dontRollbackOn=WebApplicationException.class)
Comment by Jakub Podlesak [ 09/Dec/13 ]

Please see my earlier comment on how to fix this.

Comment by Jakub Podlesak [ 09/Dec/13 ]

Tang,

I only see your comment now. My suggested solution would then unfortunately not work for you. Going to re-open this one.
I will keep JAX_RS_SPEC-440 open, as i think this could still be covered in the spec.

~Jakub

Comment by Jakub Podlesak [ 09/Dec/13 ]

Hmm, suggested solution does not seem to work as requested, going to try to fix this in the JAX-RS integration layer.

Comment by svanimpe [ 09/Dec/13 ]

Can I ask what the difference is between:

@Path("test")
@Stateless
public class Test
{
    @PersistenceContext
    private EntityManager em;
    
    @GET
    public void test()
    {
        // ...
        throw new BadRequestException("Some message");
    }
}

and

@Path("test")
@Transactional(dontRollbackOn=BadRequestException.class)
public class Test
{
    @PersistenceContext
    private EntityManager em;
    
    @GET
    public void test()
    {
        // ...
        throw new BadRequestException("Some message");
    }
}

with regard to transactions? Is the transaction rolled back in the EJB case? Are the changes in

// ....

ever committed?

Comment by Jakub Podlesak [ 09/Dec/13 ]

Not sure about the above. It is a question for JTA guys.

My plan regarding fixing the original issue is as follows.
[1] is quite clear on how the @Transactional support is implemented.
From the Jersey runtime side, i apparently need to make sure that:

  • JTA interceptor will still see the WebApplicationException thrown
  • but after the above happens, Jersey runtime makes sure the original WebApplicaitonException gets propagated further

I need to make sure the HTTP response is driven by the WebApplicationException regardless value of the dontRollbackOn parameter.

Please let me know, if your understanding of how the issue should be fixed is different.

[1]https://javaee-spec.java.net/nonav/javadocs/javax/transaction/Transactional.html

Comment by TangYong [ 10/Dec/13 ]

Jakub,

Yes, whether needing to roll back should be JTA interceptor doing. Here's focus is HTTP response which is driven by the WebApplicationException.

Best Regards
Tang

Comment by TangYong [ 10/Dec/13 ]

I guess this fixing should have some difficulties as following:

There is a large risk that whether such fixing will be related to JTA. After all, javax.transaction.RollbackException causes 500 Internal Server Error. Then, while trying to fix Jersey runtime and propagate WAE, how to handle RollbackException's propagation and WAE's propagation will be a hard point.

Tang

Comment by Jakub Podlesak [ 11/Dec/13 ]

I have a fix ready, that works around the JTA issue. It involves an additional CDI interceptor that retains the original

{WebApplicationException}

and Jersey extended exception mapper that handles the unfortunate

{TransactionalException}

. I must say that i do not like the fix, as it is IMHO rather
a workaround for a bug in GlassFish JTA/CDI integration code.

The workaround should be only used temporarily (for running newer Jersey version on a stable GF release) until a fixed GF version is available.

Comment by Jakub Podlesak [ 11/Dec/13 ]

Patch for JTA/CDI integration code: rollback transactions marked for rollback rather then doing commit on each and every transaction.





[GLASSFISH-20794] GF4: Non-working injection of JAX-RS resoures into CDI interceptors Created: 04/Sep/13  Updated: 04/Apr/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: replicant77 Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Win 7 Pro 64Bit
GlassFish Server Open Source Edition 4.0 (build 89)
jdk1.7.0_21


Attachments: Zip Archive GLASSFISH-20794.zip    
Tags: cdi, glassfish4, interceptor, jax-rs, jersey

 Description   

We are currently evaluating glassfish 4 for migration of our enterprise projects from glassfish 3.1.2.2. We are making heavy use of interceptors for our jax-rs based rest services. In glassfish 3.1.2 injection of jax-rs based resources (e.g. @Context private HttpHeaders headers) into those interceptors worked fine. But with GF4 this doesn't work anymore.
Ways to reproduce:


@RequestScoped
@Path("test")
@Test
public class TestService {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String greet()

{ return "Hello World"; }

}

@Test
@Interceptor
public class TestInterceptor {
@Context
private HttpHeaders headers;

@AroundInvoke
public Object intercept(InvocationContext ic) throws Exception

{ System.out.println("httpHeaders: " + headers); return ic.proceed(); }

}

@Inherited
@InterceptorBinding
@Target(

{ ElementType.METHOD, ElementType.TYPE }

)
@Retention(RetentionPolicy.RUNTIME)
public @interface Test {
}

beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<interceptors>
<class>TestInterceptor</class>
</interceptors>
</beans>

On GF3.1.2 the output is something like:
INFO: httpHeaders: com.sun.jersey.spi.container.ContainerRequest@4e7cb67f

On GF4:
INFO: httpHeaders: null



 Comments   
Comment by obfischer [ 05/Sep/13 ]

Did you try to update to CDI 1.1? I also had CDI related issues when migrating my application to GF 4. It was needed to to update all beans.xml to CDI 1.1. At the end I ended with updating to GF 4.0.1-SNAPSHOT.

Comment by replicant77 [ 05/Sep/13 ]

I followed your advice and updated the beans.xml in the example (see below). But the problem stays the same: HttpHeaders stays null.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
<interceptors>
<class>TestInterceptor</class>
</interceptors>
</beans>

Comment by replicant77 [ 05/Sep/13 ]

Note: i was still using 4.0_b89_RC5 for the updated beans.xml

Comment by TangYong [ 10/Sep/13 ]

I made an attachment based on the issue's description, and the issue can be re-produced using 4.0.1-b02.

[Steps]
1 mvn install
2 asadmin deploy ...
3 accessing "http://localhost:8080/glassfish-20794/webapi/test/"

You can see the following in server.log,
...
[2013-09-10T16:16:04.140+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797364140] [levelValue: 800] [[
visiting unvisited references]]

[2013-09-10T16:16:04.140+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797364140] [levelValue: 800] [[
visiting unvisited references]]

[2013-09-10T16:16:04.155+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797364155] [levelValue: 800] [[
visiting unvisited references]]

[2013-09-10T16:16:04.718+0900] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797364718] [levelValue: 800] [[
Registering the Jersey servlet application, named javax.ws.rs.core.Application, with the following root resource and provider classes: [class TestService]]]

[2013-09-10T16:16:04.968+0900] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.server.ApplicationHandler] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797364968] [levelValue: 800] [[
Initiating Jersey application, version Jersey: 2.2 2013-08-14 08:51:58...]]

[2013-09-10T16:16:05.140+0900] [glassfish 4.0] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797365140] [levelValue: 800] [[
Loading application [glassfish-20794] at [/glassfish-20794]]]

[2013-09-10T16:16:05.155+0900] [glassfish 4.0] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=54 _ThreadName=admin-listener(4)] [timeMillis: 1378797365155] [levelValue: 800] [[
glassfish-20794 was successfully deployed in 1,203 milliseconds.]]

[2013-09-10T16:16:26.749+0900] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=29 _ThreadName=Thread-7] [timeMillis: 1378797386749] [levelValue: 800] [[
httpHeaders: null]]
...

So,

1) pl. JJ firstly evaluates whether being a bug from CDI?
2) if not, forwarding to jax-rs comp to evaluate deeply.

Thanks
Tang

Comment by jjsnyder83 [ 10/Sep/13 ]

@Context is not an annotation processed by Weld nor the GF CDI integration. I looked at the call stack for when the interceptor is created and it is created by
org.jboss.weld.bean.ManagedBean#create

This create method calls the following code

T instance = getProducer().produce(creationalContext);

to create the interceptor and then

getProducer().inject(instance, creationalContext);

to do the injection. For this the getProducer() returns an instance of

org.glassfish.jersey.gf.cdi.CdiComponentProvider

I would expect this class to handle the injection of non-CDI annotations. I do not have this source code handy so I can't verify.

I think the Jersey folks should take a look and see if they're handling the @Context annotation correctly.

Comment by TangYong [ 10/Sep/13 ]

Thanks JJ's confirmation and forwards to JAX-RS Comp to evaluate deeply.

Comment by tcke83 [ 04/Apr/14 ]

Is there an easy work around to get the context? I have the same issue.





[GLASSFISH-20885] Jersey 2.4: deployment exception when using @Context HttpServletRequest in ContainerRequestFilter Created: 07/Nov/13  Updated: 19/Sep/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: dobromyslov Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Dependency
depends on HK2-163 Injecting HttpServletContext in Conta... Resolved
Tags: httpservletrequest, jersey-server

 Description   

Downloaded and installed Glassfish 4.0.1 latest nightly version with bundled Jersey 2.4 from http://dlc.sun.com.edgesuite.net/glassfish/4.0.1/nightly/glassfish-4.0.1-b04-11_04_2013.zip

Using ContainerRequestFilter with injected context HttpServletRequest:

@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthRequestFilter implements ContainerRequestFilter {
    @Context
    HttpServletRequest webRequest;

    @Override
    public void filter(ContainerRequestContext requestContext) throws IOException {
        HttpSession session = webRequest.getSession();
        String user = (String)session.getAttribute("USER_ID");
    }
}

And get exception during deployment:

    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
java.lang.IllegalArgumentException: While attempting to create a Proxy for javax.servlet.http.HttpServletRequest in proxiable scope org.glassfish.jersey.process.internal.RequestScoped an error occured while creating the proxy
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2309)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
    at org.glassfish.jersey.internal.inject.ContextInjectionResolver.resolve(ContextInjectionResolver.java:104)
    at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:803)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:832)
    at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.getInstance(CdiComponentProvider.java:203)
    at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.provide(CdiComponentProvider.java:149)
    at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:96)
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
    at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2350)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
    at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
    at org.glassfish.jersey.internal.inject.Providers.getAllRankedProviders(Providers.java:235)
    at org.glassfish.jersey.server.ApplicationHandler.getProcessingProviders(ApplicationHandler.java:617)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:410)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
    at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:287)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    Startup of context  failed due to previous errors]]

[glassfish 4.0] [SEVERE] [AS-WEB-CORE-00108] [javax.enterprise.web.core] [tid: _ThreadID=50 _ThreadName=admin-listener(4)] [timeMillis: 1383814486801] [levelValue: 1000] [[
  ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: interface org.glassfish.hk2.api.ProxyCtl is not visible from class loader
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5954)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
    at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:244)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
    ... 50 more
    ]]

This exception disappears when I remove HttpServletRequest injection.



 Comments   
Comment by dobromyslov [ 07/Nov/13 ]

Question on StackOverflow:
http://stackoverflow.com/questions/19832012/jersey-2-4-on-glassfish-4-0-1-how-to-inject-context-httpservletrequest-into-con

Jersey 2.4 supports HttpServletRequest injection: https://java.net/jira/browse/JERSEY-1960

Comment by cornelius.lilge [ 07/Nov/13 ]

Unfortunately, I can reproduce this D:
I would really like to use this.

Comment by Scott Ellis [ 03/Jan/14 ]

This is a show stopper for me, as I'm trying to inject the HttpServletRequest into a filter and have to work around this by not using a filter at all.

The issue is fixed with the nightly build from 12/25 and possibly onward.

I'm in the position of taking a chance and using that nightly version in production or backing off completely. I don't know how the process works, but I'd like to know when 4.0.1 (or 4.1) will be available as either beta or release.

Comment by dobromyslov [ 14/Feb/14 ]

Tested with nightly build from 2014-02-13: http://dlc.sun.com.edgesuite.net/glassfish/4.0.1/nightly/glassfish-4.0.1-b04-02_13_2014-ml.zip
Works well.





[GLASSFISH-20905] Detach Google Guava from weld-osgi-bundle.jar Created: 20/Nov/13  Updated: 21/Nov/13

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.0
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: haducloc13 Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: Guava, Upgrade

 Description   

Guava API are duplicated
1. It is embedded in weld-osgi-bundle.jar
2. Another lib exists in \glassfish\modules directory

– Provide a way to share Google Guava
– Make sure the lib is upgradable ( Guava 1.5+)



 Comments   
Comment by TangYong [ 21/Nov/13 ]

I did not agree with you and instead, I always suggest Jersery uses Guava in embedded way liking Weld. This way, Guava is only as lib rather than module.

Comment by TangYong [ 21/Nov/13 ]

Firstly pl. jax-rs leader to evaluate it. In reality, maybe the issue should be filed on jersery jira.

Comment by TangYong [ 21/Nov/13 ]

About the issue, also pl seeing the following discussion.

https://java.net/projects/glassfish/lists/dev/archive/2013-09/message/13





[GLASSFISH-20953] OAuth1Provider can't be found Created: 15/Jan/14  Updated: 22/Jan/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: johanvos Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to JERSEY-2358 Jersey HK2 injections using @Inject d... Closed

 Description   

I have a war containing a class implementing org.glassfish.jersey.server.oauth1.OAuth1Provider.
Deploying this to GlassFish 4.0.1 (recent nightly build), deploy fails with
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [OAuth1Provider] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.glassfish.jersey.server.oauth1.internal.RequestTokenResource.provider]

The stacktrace in the server.log is shown below.
Installing oauth1-server-2.5.jar in glassfish/modules didn't solve it either (ClassNotFound for OAuth1Provider).

[2014-01-15T15:23:16.911+0100] [glassfish 4.0] [SEVERE] [] [javax.enterprise.web] [tid: _ThreadID=41 _ThreadName=admin-listener(3)] [timeMillis: 1389795796911] [levelValue: 1000] [[
WebModule[/jersey2oauth-server-1.0.0-SNAPSHOT]Servlet /jersey2oauth-server-1.0.0-SNAPSHOT threw load() exception
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [OAuth1Provider] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.glassfish.jersey.server.oauth1.internal.RequestTokenResource.provider]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:405)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:327)
at org.jboss.weld.bootstrap.Validator.validateProducer(Validator.java:433)
at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:35)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:88)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:77)
at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1061)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.<init>(CdiComponentProvider.java:213)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.<init>(CdiComponentProvider.java:192)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.bind(CdiComponentProvider.java:340)
at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:874)
at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:804)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:414)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:301)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:404)
at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandSimpInMultOut(CommandResource.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:402)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:349)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:363)
at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:173)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:199)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:174)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:212)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:547)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:744)
]]



 Comments   
Comment by Miroslav Fuksa [ 22/Jan/14 ]

See related issue JERSEY-2358 (describes the bug in Jersey which causes this problem).





[GLASSFISH-21033] adding MultiPartFeature to JAX-RS Application throws exception Created: 07/Apr/14  Updated: 19/Sep/14

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: m.zdila Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

glassfish-4.0.1-b04-04_05_2014-ml
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.5) (7u51-2.4.5-2)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)


Tags: 4_0_1-approved

 Description   

2014-04-07T16:41:16.566+0200|SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(@Context Providers, Provider<CloseableService>)]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5954)
at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:215)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:550)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.catalina.LifecycleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(@Context Providers, Provider<CloseableService>)]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5712)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
... 49 more
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(@Context Providers, Provider<CloseableService>)]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:405)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:327)
at org.jboss.weld.bootstrap.Validator.validateProducer(Validator.java:433)
at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:35)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:88)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:77)
at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1061)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.<init>(CdiComponentProvider.java:229)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.<init>(CdiComponentProvider.java:208)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.bind(CdiComponentProvider.java:356)
at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:892)
at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:822)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:432)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:322)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
... 50 more

In Glassfish 4.0 it was working.



 Comments   
Comment by mreichman [ 07/Apr/14 ]

I was just coming here myself to file this, but it already was filed, today!

Glassfish 4.0.1b4, JDK 1.7.0_45 x64 Windows. The distinction seems to happen when the application uses CDI.

I have a very basic webapp test case, just two classes, no XML or anything in the lib directory:

MultipartApplication .java
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;

import javax.ws.rs.ApplicationPath;

/**
 * Created with IntelliJ IDEA.
 * User: mreichman
 * Date: 4/7/2014
 * Time: 8:53 AM
 */
@ApplicationPath("rest")
public class MultipartApplication extends ResourceConfig {
    public MultipartApplication() {
        register(MultiPartFeature.class);
        register(EchoResource.class);
    }
}
EchoResource.java
import org.glassfish.jersey.media.multipart.FormDataParam;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/echo")
//@javax.enterprise.context.RequestScoped
public class EchoResource {

    @GET
    @Path("/{string}")
    public Response echoString(@PathParam("string") String input) {
        return Response.ok(input).build();
    }

    @POST
    public Response echoMultiPart(@FormDataParam("mpData") String input) {
        return Response.ok(input).build();
    }

}

> curl http://localhost:8080/multipart/rest/echo/hello
hello
> curl -X POST -F "mpData=hellomp" http://localhost:8080/multipart/rest/echo
hellomp

Deploys fine as-shown. If you uncomment the @javax.enterprise.context.RequestScoped in EchoResource, it will not deploy, and the following is in the log:

[2014-04-07T10:25:39.638-0500] [glassfish 4.0] [INFO] [] [org.jboss.weld.Version] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884339638] [levelValue: 800] [[
  WELD-000900 2.0.3 (Final)]]

[2014-04-07T10:25:42.034-0500] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884342034] [levelValue: 900] [[
  Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled]]

[2014-04-07T10:25:42.035-0500] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884342035] [levelValue: 900] [[
  Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled]]

[2014-04-07T10:25:42.994-0500] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884342994] [levelValue: 800] [[
  Registering the Jersey servlet application, named MultipartApplication, at the servlet mapping /rest/*, with the Application class of the same name.]]

[2014-04-07T10:25:43.520-0500] [glassfish 4.0] [INFO] [] [org.glassfish.jersey.server.ApplicationHandler] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884343520] [levelValue: 800] [[
  Initiating Jersey application, version Jersey: 2.5.1 2014-01-02 13:43:00...]]

[2014-04-07T10:25:43.721-0500] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bean] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884343721] [levelValue: 900] [[
  WELD-001529 An InjectionTarget is created for a class org.glassfish.jersey.media.multipart.internal.MultiPartWriter which does not have any appropriate constructor.]]

[2014-04-07T10:25:43.749-0500] [glassfish 4.0] [SEVERE] [] [javax.enterprise.web] [tid: _ThreadID=46 _ThreadName=admin-listener(4)] [timeMillis: 1396884343749] [levelValue: 1000] [[
  WebModule[/multipart]StandardWrapper.Throwable
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(@Context Providers, Provider<CloseableService>)]
	at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:91)
	at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:77)
	at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:1061)
	at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.<init>(CdiComponentProvider.java:213)
	at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.<init>(CdiComponentProvider.java:192)
	at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.bind(CdiComponentProvider.java:340)
	at org.glassfish.jersey.server.ApplicationHandler.bindWithComponentProvider(ApplicationHandler.java:874)
	at org.glassfish.jersey.server.ApplicationHandler.bindProvidersAndResources(ApplicationHandler.java:804)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:414)
	at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
	at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:304)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:301)
	at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
	at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1583)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1382)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5704)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:5946)
	at com.sun.enterprise.web.WebModule.start(WebModule.java:691)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:747)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2286)
	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1932)
	at com.sun.enterprise.web.WebApplication.start(WebApplication.java:139)
	at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
	at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
	at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:500)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:356)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:356)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
	at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
	at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:215)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:291)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:209)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:137)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:115)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:550)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:744)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Providers] with qualifiers [@Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide(@Context Providers, Provider<CloseableService>)]
	at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:405)
	at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:327)
	at org.jboss.weld.bootstrap.Validator.validateProducer(Validator.java:433)
	at org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:35)
	at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:88)
	... 73 more
]]
Comment by gdoerr56 [ 08/May/14 ]

Using Jersey 2.8 under Glassfish 4.0b05

I can successfully add MutliPartFeature to a ClientConfig object and create a JerseyClient. All POST/FormDataMultiPart operations from the client work fine.

It would appear that there is a condition (probably in ApplicationHandler ?) where the registered providers are initialized before the Binder resources are available.
Probably not a Glassfish issue since it basically works with the client and the same @Context Providers exists in the MultiPartReaderClientSide class.

I have a simple test environment set up and would be happy to perform any additional tests required.

Comment by gdoerr56 [ 09/May/14 ]

Using Jersey 2.8 under Glassfish 4.0b05 with Jackson 2.3.3

After stepping through the Jersey initialization code it appears that it is trying to instantiate
the classes but the initialization logic seems to expect an empty constructor. I was able to
get this to work by creating my own versions of MultiPartWriter, MultiPartReaderClientSide,
MultiPartReaderServerSide and a version of MultiPartFeature to load them all.

The changes I had to make was to have an empty constructor for each of the classes and remove
the constructor @Inject from MultiPartReaderServerSide.

I'm sure there are negative side effects and I wouldn't do this for production but at least it
works so I can continue on my development project.

Comment by Jakub Podlesak [ 05/Jun/14 ]

Fixed in the Jersey master branch (2.10-SNAPSHOT version of Jersey).
After Jersey 2.10 is released and integrated into the GF trunk, this bug report could be resolved as fixed.

Comment by mreichman [ 14/Aug/14 ]

This appears to be working fine in 4.0.1b8+





[GLASSFISH-21110] cdi tck failures caused by Jersey Created: 27/Jun/14  Updated: 19/Sep/14

Status: Reopened
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: jjsnyder83 Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: 4_0_1-mustfix

 Description   

testDecoratorsInWebInfClasses(org.jboss.cdi.tck.tests.decorators.ordering.global.EnterpriseDecoratorOrderingTest): null: lists don't have the same size expected:<7> but was:<1>
testDecoratorsInWebInfClasses(org.jboss.cdi.tck.tests.decorators.ordering.global.GlobalDecoratorOrderingTest): null: lists don't have the same size expected:<10> but was:<1>
testScopeTypeDeclaredInheritedIsBlockedByIntermediateScopeTypeNotMarkedInherited(org.jboss.cdi.tck.tests.definition.scope.ScopeDefinitionTest)
arquillianBeforeClass(org.jboss.cdi.tck.tests.extensions.lifecycle.bbd.DeploymentTest): exit_code: FAILURE, message: Error occurred during deployment: Exception while loading the app : CDI definition failure:Type org.jboss.cdi.tck.tests.extensions.lifecycle.bbd.lib.Pro not present. Please see server.log for more details. [status: CLIENT_ERROR reason: Bad Request]
arquillianBeforeClass(org.jboss.cdi.tck.tests.implementation.producer.field.lifecycle.ProducerFieldLifecycleTest): exit_code: FAILURE, message: Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001409: Ambiguous dependencies for type Tarantula with qualifiers @Tame
testNonStaticProducerFieldNotIndirectlyInherited(org.jboss.cdi.tck.tests.implementation.producer.field.definition.ProducerFieldDefinitionTest): WELD-001318: Cannot resolve an ambiguous dependency between:
testNonStaticProducerFieldNotInherited(org.jboss.cdi.tck.tests.implementation.producer.field.definition.ProducerFieldDefinitionTest): WELD-001318: Cannot resolve an ambiguous dependency between:



 Comments   
Comment by Jakub Podlesak [ 30/Jun/14 ]

This has been fixed in Jersey 2.10.1 workspace. Michal is actually cutting the 2.10.1 Jersey release and going to integrate the fix into GF.

Comment by Jakub Podlesak [ 21/Jul/14 ]

The original fix caused regression, which needs to be fixed in Jersey 2.10.2.





[GLASSFISH-21141] Missing jackson-module-jaxb-annotations JAR causes error on first Jersey/Jackson JSON response Created: 23/Jul/14  Updated: 02/Mar/16

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1_b08, 4.1_b09
Fix Version/s: None

Type: Bug Priority: Major
Reporter: mreichman Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 18
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows x86-64, Linux x86-64, JDK 7u45


Tags: json-jackson

 Description   

Deployment of a basic webapp, 3 classes, fails to respond with a proper serialized JSON response on the first attempt after deployment.

In the example classes (below), the first call after deployment to GET /myTestApp/rest/myobject yields a 500 in the browser window and this in the server.log:

[2014-07-23T09:17:30.348-0500] [glassfish 4.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=30 _ThreadName=http-listener-1(3)] [timeMillis: 1406125050348] [levelValue: 900] [[
  StandardWrapperValve[MyApplication]: Servlet.service() for servlet MyApplication threw exception
java.lang.ClassNotFoundException: com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector not found by com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider [188]
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
	at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospector(JsonMapperConfigurator.java:109)
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospectors(JsonMapperConfigurator.java:84)
	at com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase._setAnnotations(MapperConfiguratorBase.java:120)
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator.getDefaultMapper(JsonMapperConfigurator.java:45)
	at com.fasterxml.jackson.jaxrs.base.ProviderBase.locateMapper(ProviderBase.java:833)
	at com.fasterxml.jackson.jaxrs.base.ProviderBase.writeTo(ProviderBase.java:576)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:263)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:89)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1154)
	at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:621)
	at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:377)
	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:367)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:274)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
	at java.lang.Thread.run(Thread.java:744)
]]

Second and subsequent calls yield no log message and this (expected) in the browser window:

{"myString":"test","myLong":123}

Putting a version-appropriate jackson-module-jaxb-annotations JAR file in the glassfish4/glassfish/modules directory makes this work on the first try as it should.

Example application (3 classes):

MyApplication.java
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;

import javax.ws.rs.ApplicationPath;

@ApplicationPath("rest")
public class MyApplication extends ResourceConfig {
    public MyApplication() {
        register(JacksonFeature.class);
        register(MyResource.class);
    }

}
MyResource.java
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("/myobject")
public class MyResource {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getMyObject() {
        return Response.ok(new MyObject("test", 123L)).build();
    }
}
MyObject.java
public class MyObject {
    private String myString;
    private Long myLong;

    public MyObject() {
    }

    public MyObject(String myString, Long myLong) {
        this.myString = myString;
        this.myLong = myLong;
    }

    public String getMyString() {
        return myString;
    }

    public void setMyString(String myString) {
        this.myString = myString;
    }

    public Long getMyLong() {
        return myLong;
    }

    public void setMyLong(Long myLong) {
        this.myLong = myLong;
    }
}


 Comments   
Comment by mreichman [ 01/Aug/14 ]

This is still happening under 4.0.1b10. I don't seem to be able to edit the ticket to reflect that.

Comment by mreichman [ 12/Aug/14 ]

Confirmed still happening under 4.1b12

Comment by Sanjeeb Sahoo [ 12/Aug/14 ]

There is no module containing the missing com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.class, so that's causing the CNFE. The bug submitter has already confirmed the following:

> Putting a version-appropriate jackson-module-jaxb-annotations JAR file in the glassfish4/glassfish/modules directory makes this work on the first try as it should.

The reason it has gone unnoticed so far is that the OSGi metadata of jackson-jaxrs-json-provider.jar says that com.fasterxml.jackson.module.jaxb package is an optional requirement. Instead of deploying the missing module to modules/ dir, please deploy it to domains/domain1/autodeploy/bundles/ dir as a work around. That way you are not changing glassfish installation; you are only changing domain configuration.

Thanks,
Sahoo

Comment by mreichman [ 12/Aug/14 ]

Thanks Sahoo.

What needs to happen for this to be fixed for real? It seems that it's being handled, in the sense that subsequent calls work fine, so whatever is throwing this exception is also handling something for later calls.

Does the exception need to be caught higher up and logged as a warning? Or is that outside the scope of this ticket?

It's not clear to me exactly where in the chain this exception is making it out, following to which project has the responsibility to fix.

Thanks,
Marc

Comment by Sanjeeb Sahoo [ 13/Aug/14 ]

Someone familiar with jax-rs/jackson should tell how this works second time. I suspect on subsequent requests, a different code path is exercised possible due to the exception raised during the first invocation. But, someone needs to debug and confirm this theory.

Comment by svenvarkel [ 27/Aug/14 ]

After I copy jackson-module-jaxb-annotations-2.4.2.jar to domain1/autodeploy/bundles I get the following error upon Glassfish start. GF version is 4.1b13

[2014-08-27T12:41:04.287+0300] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=122 _ThreadName=Thread-9] [timeMillis: 1409132464287] [levelValue: 800] [[
  org.osgi.framework.BundleException: Unresolved constraint in bundle com.fasterxml.jackson.module.jackson-module-jaxb-annotations [303]: Unable to resolve 303.0: missing requirement [303.0] osgi.wiring.package; (&(osgi.wiring.package=com.fasterxml.jackson.annotation)(version>=2.4.0)(!(version>=2.5.0)))

If I copy this file to glassfish/modules then GF starts up fine.

However then I still get the original error:

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospector(JsonMapperConfigurator.java:109)
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospectors(JsonMapperConfigurator.java:84)
	at com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase._setAnnotations(MapperConfiguratorBase.java:120)
	at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator.getDefaultMapper(JsonMapperConfigurator.java:45)
	at com.fasterxml.jackson.jaxrs.base.ProviderBase.locateMapper(ProviderBase.java:833)
	at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:752)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:257)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:229)
	at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:149)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1124)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)
	at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:810)
	at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:368)
	at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:122)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:399)
	at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:119)
	at com.mageflow.rest.resources.magento.PingResource.GET(PingResource.java:53)
	at com.mageflow.rest.MagentoRestClient.ping(MagentoRestClient.java:342)
	at com.mageflow.worker.updaters.InstancePinger.pingInstance(InstancePinger.java:119)
	at com.mageflow.worker.updaters.InstancePinger.pingAllInstances(InstancePinger.java:77)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
	at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
	at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:145)
	at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
	at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4051)
	... 8 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector not found by com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider [129]
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
	at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 60 more

Any help would be appreciated.

Comment by svenvarkel [ 27/Aug/14 ]

One solution was to create a MapperProvider:

@Provider
public class RestObjectMapperProvider implements ContextResolver<ObjectMapper> {
.....

and register it when building new client:

 javax.ws.rs.client.ClientBuilder.newBuilder()
                .sslContext(getSSLContext())
                .register(RestObjectMapperProvider.class)
                .register(JacksonFeature.class);
Comment by mreichman [ 27/Aug/14 ]

svenvarkel,

Could you provide the rest of your provider implementation? I'd like to try it with the service side.

Edit The version of the jackson library inside 4.1b13 is still 2.3.2, which you can see looking at the manifest files in the other jars. That's probably causing your startup issue. You may need to clear osgi cache after this change.

Thanks,
Marc

Comment by svenvarkel [ 27/Aug/14 ]

Hi,

it's very basic:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mageflow.mapper;

import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
import com.mageflow.rest.entities.github.Repository;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

/**
 *
 * @author Sven Varkel <sven.varkel@gmail.com>
 */
@Provider
public class RestObjectMapperProvider implements ContextResolver<ObjectMapper> {

    final ObjectMapper defaultObjectMapper;
    final ObjectMapper combinedObjectMapper;

    public RestObjectMapperProvider() {
        defaultObjectMapper = createDefaultMapper();
        combinedObjectMapper = createCombinedObjectMapper();
    }

    @Override
    public ObjectMapper getContext(Class<?> type) {

        if (type == Repository.class) {
            return combinedObjectMapper;
        } else {
            return defaultObjectMapper;
        }
    }

    private static ObjectMapper createCombinedObjectMapper() {

        AnnotationIntrospector ai = new AnnotationIntrospectorPair(
                new JaxbAnnotationIntrospector(),
                new JacksonAnnotationIntrospector()
        );
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
        mapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
        mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
        mapper.setAnnotationIntrospector(ai);

        return mapper;
    }

    private static ObjectMapper createDefaultMapper() {

        ObjectMapper result = new ObjectMapper();

        return result;
    }
}

Its logic is not used by us any more but I just found that it would load the necessary JaxbAnnotationIntrospector class So it's a hack.

Comment by sunpswd [ 30/Sep/14 ]

A quick hack how I managed to overcome this on GlassFish Server Open Source Edition 4.1 (build 13):

0) stopped the server
1) downloaded and copied the jars below into glassfish4\glassfish\modules (version: 2.4.2 for all)
jackson-annotations.jar
jackson-core.jar
jackson-databind.jar
jackson-jaxrs-base.jar
jackson-jaxrs-json-provider.jar
jackson-module-jaxb-annotations.jar
2) deleted the osgi-cache: removed glassfish4\glassfish\domains\domain1\osgi-cache\felix
3) re-started the server

Comment by atrajano [ 10/Oct/14 ]

This is how I did mine without making any changes to the domain directory libraries.

@Override
public Set<Object> getSingletons() {
  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new JaxbAnnotationModule());
  return ImmutableSet
    .<Object> builder()
    .add(new JacksonJaxbJsonProvider(mapper,
             JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS)).build();
}

The disadvantage is you lose the automatic lookup of your classes, but it turned out to be a good thing for me as I can have different API version srunning concurrently from the same web project as I had noted here http://www.trajano.net/2014/10/predictiability-and-versioning-jax-rs-rest-api/

Comment by dyego [ 02/Jul/15 ]

One more vote... this is very bad

Comment by adfore [ 04/Nov/15 ]

The file's still missing as of 4.1.1 (GlassFish Server Open Source Edition 4.1.1 (build 1)).
Edit: The new Jackson version is 2.5.1 (for workaround).

Comment by unwichtich [ 15/Jan/16 ]

For Glassfish 4.1 it is sufficient to put jackson-module-jaxb-annotations-2.3.2.jar into the modules directory, you don't need to replace all Jackson libs.

Comment by pjsb [ 02/Mar/16 ]

This is not working for me, even in the official Glassfish 4.1.1 release, I have to replace all jackson libraries (Jackson Version 2.7.2)





[GLASSFISH-21252] Jaxrs Json encoding default Created: 12/Nov/14  Updated: 18/Nov/14

Status: Open
Project: glassfish
Component/s: jax-rs, json
Affects Version/s: 4.1
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Puls Assignee: Pavel Bucek
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hi,
We are currently working on an application which needs to be deployed on multiple Servers. So far the gf4.1 experience has been pleasant.

The one area where we are encountering problems is the json encoding default of jaxrs in gf. Our gwt frontend cannot work with the encodings of maps and enums cause trouble as root entities.

Jackson encoding is the de-facto Standard. It would simplify things a lot if moxy produced the same Output or if switching to jackson was made easier without introducing API dependencies in a project (e.G. Descriptor).






[GLASSFISH-21340] CDI scope annotation on @Provider makes @NameBinding ignored Created: 26/Mar/15  Updated: 29/Apr/16

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: m-radzikowski Assignee: Marek Potociar
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

1.8.0_40



 Description   

Using CDI scope annotation (e.g. @javax.enterprise.context.RequestScoped) makes annotations with @javax.ws.rs.NameBinding ignored in @javax.ws.rs.ext.Provider.

Sample code:

EnableScopedFilter
@Retention(RUNTIME)
@NameBinding
public @interface EnableScopedFilter {	
}
ScopedFilter
@Provider
@EnableScopedFilter
@RequestScoped
public class ScopedFilter implements ContainerRequestFilter {
	@Override
	public void filter(ContainerRequestContext requestContext) throws IOException {
		System.out.println("Scoped filter triggered on path: " + requestContext.getUriInfo().getPath());
	}
}

This filter is executed on every REST method, not only on these annotated with @EnableScopedFilter. If @RequestScoped is removed everything is ok.

CDI scope annotation is needed is bean-discovery-mode in beans.xml is set to "annotation" and filter needs to @Inject some resources.



 Comments   
Comment by jjsnyder83 [ 30/Mar/15 ]

I don't think this is a CDI issue. I think it is a jax-rs issue. Assigning to jax-rs.

Comment by HeinBloed [ 29/Apr/16 ]

Was this bug resolved in a newer Jersey version? I couldn't find any other information about it. Also facing it with GF 4.1.





[GLASSFISH-21372] jersey 2.0 :: for cdi injection, is beans.xml mandatory? Created: 09/Jun/15  Updated: 19/Aug/15

Status: Open
Project: glassfish
Component/s: hk2, jax-rs
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: vikramalvaj Assignee: jwells
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

glassfish 4.1



 Description   

Resource class

public class UploadFileService {

@Inject public Logger logger;

@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
}
}
Injecting :: Logger class

@Dependent
public final class Loggers {

@Produces
public static final Logger getLogger(final InjectionPoint injectionPoint) {
if (injectionPoint == null)

{ throw new IllegalArgumentException("injectionPoint", new NullPointerException("injectionPoint")); }

}
Injection perfectly works on including beans.xml at

*.war\WEB-INF\classes\META-INF\beans.xml

But is it not beans.xml optional in jersey 2.0 ?

Error reported in the absence of beans.xml

org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=Logger,parent=UploadFileService,
qualifiers={},position=-1,optional=false,self=false,unqualified=null,1642832267)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74)
at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:947)
at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:902)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory$2.getInstance(CdiComponentProvider.java:245)
at org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider$CdiFactory.provide(CdiComponentProvider.java:189)



 Comments   
Comment by vikramalvaj [ 10/Jun/15 ]

My concern is ...Why an empty beans.xml file is required in this particular scenario when its optional in jersey 2.0 ?

Comment by jjsnyder83 [ 10/Jun/15 ]

The stack trace indicates that this is an hk2 exception not a cdi exception.

Comment by vikramalvaj [ 19/Aug/15 ]

Any update on this issue ?





[GLASSFISH-21410] Invalidating Session using POST via JAX-RS creates IOException Created: 09/Aug/15  Updated: 09/Aug/15

Status: Open
Project: glassfish
Component/s: grizzly-kernel, jax-rs, web_container
Affects Version/s: 4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: atrajano Assignee: oleksiys
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Given the following sample code

@Path("session")
@Stateless
public class Resource2 {

@GET
@Path("create")
public Response create(@Context HttpServletRequest req)

{ req.getSession().setAttribute("foo", "bar"); return Response.ok(req.getSession().getAttribute("foo")).build(); }

@POST
@Path("invalidate")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response invalidate(@Context HttpServletRequest req,
@FormParam("foo") String foo)

{ HttpSession session = req.getSession(false); Object foox = session.getAttribute(foo); session.invalidate(); return Response.temporaryRedirect(URI.create("http://slashdot.org/")).build(); }

}

I get the following stack trace

java.io.IOException
at org.glassfish.grizzly.http.io.InputBuffer.skip(InputBuffer.java:721)
at org.glassfish.grizzly.http.server.Request.skipPostBody(Request.java:2078)
at org.glassfish.grizzly.http.server.Request.parseRequestParameters(Request.java:2032)
at org.glassfish.grizzly.http.server.Request.getParameter(Request.java:1066)
at org.apache.catalina.connector.Request.getParameter(Request.java:1552)
at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:448)
at org.jboss.weld.servlet.ConversationContextActivator.determineConversationId(ConversationContextActivator.java:182)
at org.jboss.weld.context.http.LazyHttpConversationContextImpl.checkContextInitialized(LazyHttpConversationContextImpl.java:93)
at org.jboss.weld.context.http.LazyHttpConversationContextImpl.destroy(LazyHttpConversationContextImpl.java:85)
at org.jboss.weld.context.http.HttpSessionContextImpl.destroy(HttpSessionContextImpl.java:59)
at org.jboss.weld.servlet.HttpContextLifecycle.sessionDestroyed(HttpContextLifecycle.java:152)
at org.jboss.weld.servlet.WeldInitialListener.sessionDestroyed(WeldInitialListener.java:133)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:910)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:854)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:842)
at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1603)
at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:204)
at net.trajano.test.Resource2.invalidate(Resource2.java:44)

The invalidation seems to be asynchronous since the redirect still works. And it seems that the POST content stream was already closed by the time it reaches InputBuffer.skip.

Perhaps it shouldn't throw an IOException and instead if it is closed just silently not read any more data?






[GLASSFISH-13165] Jersey uses DynamicImport-Package: * Created: 27/Aug/10  Updated: 22/Oct/12

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1
Fix Version/s: future release

Type: Improvement Priority: Minor
Reporter: Sanjeeb Sahoo Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Dependency
depends on JERSEY-1521 Jersey should stop using OSGi Dynamic... Resolved
blocks GLASSFISH-11780 Specify bundle metadata corretcly. Open
blocks JERSEY-660 NPE in com.sun.jersey.core.impl.provi... Closed
blocks GLASSFISH-16518 Jersey: Allow regular users to run di... Open
Issuezilla Id: 13,165
Tags: ee7ri_cleanup_deferred

 Description   

Jersey should stop using such a poor mechanism to load user classes.



 Comments   
Comment by Jakub Podlesak [ 07/Oct/10 ]

We will fix this after GFv3.1 release.
I am lowering priority of the bug to p4, and setting the 3.1-exclude keyword.

Comment by Jakub Podlesak [ 07/Oct/10 ]

removed 3.1-exclude keyword

Comment by Sanjeeb Sahoo [ 07/Oct/10 ]

This is important for gf3.1, so increasing the priority to p2. I will take
ownership and fix it when we repackage jersey bundles in gf3.1

Comment by Sanjeeb Sahoo [ 12/Oct/10 ]

target 3.1_ms06

Comment by Marek Potociar [ 13/Oct/10 ]

Moving to proper? component

Comment by Chris Kasso [ 27/Oct/10 ]

Changed Target milestone back to not determined. MS6 has sailed.

Comment by Martin Matula [ 16/Dec/10 ]

Won't be done for 3.1. We should work on this early on in the 3.2 release cycle.

Comment by scatari [ 23/Jun/11 ]

To be considered for the release after 3.1.1. Does not affect the required functionality delivered by 3.1.1 release.

Comment by Tom Mueller [ 18/Oct/12 ]

Marking the fix version field as "future-release". This is based on an evaluation by John, Michael, and Tom WRT to the PRD for the Java EE 7 RI/SDK. This issue was deemed to not be a P1 for that release. If this is in error or there are other reasons why this RFE should be targeted for the Java EE 7 RI/SDK release, then change the fix version field back to an appropriate build.





[GLASSFISH-17869] Unable to expose an EJB as a JAX-RS service Created: 01/Dec/11  Updated: 20/Dec/11

Status: Open
Project: glassfish
Component/s: jax-rs
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: atrajano Assignee: Jakub Podlesak
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I created a simple EJB that looks like this

package com.example;

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

@Stateless
@Path("hello")
public class HelloWorld {
@GET
public String getString()

{ return toString(); }

}

And packaged it in an EAR and deployed it, but there was no indicator in the logs as to what the end point URL is.

I have tried

@Path("/hello")

as well

http://localhost:8080/hello yields a 404

I can't find it in the spec whether this is allowed or not.



 Comments   
Comment by atrajano [ 01/Dec/11 ]

It's just morbid curiosity and laziness... I just didn't want to create another package to contain the EJB.





[GLASSFISH-18946] EAR with two CDI Jersey web archives will not deploy Created: 26/Jul/12  Updated: 13/May/16

Status: Reopened
Project: glassfish
Component/s: jax-rs
Affects Version/s: None
Fix Version/s: 4.0

Type: Bug Priority: Minor
Reporter: Ramon Rockx Assignee: Marek Potociar
Resolution: Unresolved Votes: 16
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7


Attachments: Zip Archive JerseyCDITest2.zip     File TestEAR-0.0.1-SNAPSHOT.ear     Java Archive File TestWAR1-0.0.1-SNAPSHOT-sources.jar     Java Archive File TestWAR2-0.0.1-SNAPSHOT-sources.jar    
Tags: req-weld-fix

 Description   

I already filed this issue in the Jersey JIRA (http://java.net/jira/browse/JERSEY-1232), however, after some research by Michal Gajdos, the issue is closed as "invalid", since the problem would by caused by Weld/GlassFish Weld. I also filed an issue at the Weld JIRA (http://issues.jboss.org/browse/WELD-1175), but they think it should be investigated first by the GlassFish team... (from pillar to post).
Hopefully, the GlassFish team can help solving this problem.

So here are the details:
We are experiencing the following issue with Jersey 1.12 in combination with Weld 1.1.4 and Glassfish 3.1.2:
When using an EAR with two WAR's in it, the last WAR doesn't get deployed. Both WAR's are CDI enabled and contains a REST service. When deploying both WAR's without the EAR, they deploy just fine.
I will attach a test case.

Depending on the VM property
com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager we will get another Exception:

com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=false:

java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'com/sun/jersey/config/CDIExtension' in
SerialContext[myEnv=java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
 java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, 
java.naming.factory.url.pkgs=com.sun.enterprise.naming}
[Root exception is javax.naming.NameNotFoundException: CDIExtension not found]	
	at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:177)
	at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:92)
	at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:75)
	at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:574)
	at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)
	at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:606)
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	...

com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

java.lang.NullPointerException
	at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:94)
	at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:75)
	at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:574)
	at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:311)
	at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:606)
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
	at javax.servlet.GenericServlet.init(GenericServlet.java:244)
	...


 Comments   
Comment by jjsnyder83 [ 03/Oct/12 ]

There is a work-around...I removed the WEB-INF/lib/jersey-gf-servlet-1.12.jar from the wars and I was able to deploy the ear successfully and execute http://localhost:8080/rest1_war/service/rest/RestService1 with "Hello world" as the result. I was able to reproduce the NPE above so I'm still looking into it.

Comment by jjsnyder83 [ 05/Oct/12 ]

I have checked in a fix. The application now deploys. However this has uncovered what I believe to be a bug in Weld. See https://issues.jboss.org/browse/WELD-1175.

I have checked in the fix into 3.1.2 and trunk.

Comment by jjsnyder83 [ 05/Oct/12 ]

Reopening due to the bug in Weld

Comment by Ramon Rockx [ 08/Oct/12 ]

Great that this one is fixed!
I'm looking for a way to patch our GlassFish installation (version 3.1.2.2).
jjsnyder83, you mentioned that it is fixed on trunk and 3.1.2. I can only find commits on the trunk (GF 4.0 I assume). Can you help me out patching 3.1.2/3.1.2.2?

Comment by jjsnyder83 [ 08/Oct/12 ]

I made the change to the 3.1.2-SUSTAINING line as well as trunk (4.0).

I will get back to you on the patching.

Please note that even though the app will deploy a fix to Weld (https://issues.jboss.org/browse/WELD-1175) is still required for the app to work correctly. See the Weld issue for details.

Comment by jjsnyder83 [ 08/Oct/12 ]

The next patch due out is 3.1.2.4 (not sure of the date yet.) But until Weld fixes the issue there's no reason to include this in the patch.

Comment by Ramon Rockx [ 09/Oct/12 ]

Can we expect this fix will be included in 3.1.2.4 since WELD-1175 is fixed too?
(3.1.2.3 is skipped for release?)

Comment by jjsnyder83 [ 11/Oct/12 ]

Yes...I made the fix in the patch line and so it should be included in the next patch release. I have also requested that weld 1.1.10.Final be included as this relies on weld to work properly.

Comment by jjsnyder83 [ 22/Oct/12 ]

GlassFish integration with Weld was updated to Weld 1.1.10.Final with revision 56665.

Comment by jjsnyder83 [ 20/Dec/12 ]

I just tested this on trunk with weld 1.1.10.Final and it doesn't work.

Comment by jwells [ 27/Mar/13 ]

I get this error now when I deploy the above ear in GF 4.0:

Exception while loading the app : CDI deployment failure:Error loading class com.sun.jersey.server.impl.cdi.CDIExtension
org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class com.sun.jersey.server.impl.cdi.CDIExtension
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:179)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:190)
at org.jboss.weld.resources.ClassTransformer.getEnhancedAnnotatedType(ClassTransformer.java:224)
at org.jboss.weld.bootstrap.ExtensionBeanDeployer.deployBeans(ExtensionBeanDeployer.java:71)
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:464)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:192)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)

I looked at this a little bit, the class com.sun.jersey.server.impl.cdi.CDIExtension is in the jersey-gf-servlet-1.12.jar included in the WAR files included in the EAR. My guess would be that the old CDIExtension (which no longer exists in the Jersey included in GF 4.0) cannot be loaded properly anymore...

So to me this seems like it is currently a Jersey issue, and may have to do with backwards compatibility...

Comment by Ramon Rockx [ 02/May/13 ]

I'm wondering if this bug will be fixed with the upcoming 4.0 release?
It really makes it impossible for us to use REST in a large modular EAR application properly.

Comment by dbenegiamo [ 03/May/13 ]

As the "double WARs in a EAR" is a common solution for applications that expose a FORM authentication for the web presentation and a BASIC authentication for restful web-services, priority of this bug should - in my opinion - raised.

Comment by Ramon Rockx [ 22/May/13 ]

Like jwells mentioned, the current test case results in ClassNotFoundExceptions.
I downloaded GlassFish 4.0 b88. Tweaked the test case:

  • no Jersey servlet configuration anymore (web.xml is empty)
  • no explicit dependency to Jersey 1.12 anymore (it now depends on Jersey 2.x)
  • used the javax.ws.rs.ApplicationPath annotation to configure the REST path prefix.

Now each REST service does work in both web modules.

However, GlassFish does log warnings like
"[WARNING|glassfish 4.0|javax.enterprise.web.util|_ThreadID=60;_ThreadName=AutoDeployer;_TimeMillis=1369210288543;_LevelValue=900; _MessageID=AS-WEB-UTIL-00035;| Unable to load class nl.asknow.sandbox.RestService1, reason: java.lang.ClassNotFoundException: nl.asknow.sandbox.RestService1|#]".
I'm not sure if this warning can be ignored.

I will attach my new test case.

Comment by Ramon Rockx [ 22/May/13 ]

It seems I cannot add an attachment anymore...

Comment by Jakub Podlesak [ 24/May/13 ]

Ramon, could you please send the test case to my e-mail address (jakub.podlesak at oracle.com)? I will attach it here as well once i get it. Thanks!

Comment by Jakub Podlesak [ 27/May/13 ]

Updated test case from Ramon.

Comment by sebastian2 [ 23/Jul/14 ]

Is there a plan to fix that issue? I am also struggeling with this bug....

Comment by lprimak [ 12/May/16 ]

Payara team is tracking this bug here:
https://github.com/payara/Payara/issues/374

Comment by Jakub Podlesak [ 13/May/16 ]

Re-assigning to Marek, as i am not sure who is in charge with Jersey in GF. I am no longer part of the team.





Generated at Thu Aug 25 02:45:39 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.