Download [#JERSEY-2626] Glassfish / Jersey throws NPE on startup

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
[JERSEY-2626] Glassfish / Jersey throws NPE on startup of versioned app Created:
24/Aug/14 Updated: 10/Sep/15 Resolved: 24/Jun/15
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Closed
jersey
None
2.10.1
Type:
Reporter:
Resolution:
Labels:
Σ Remaining
Estimate:
Σ Time Spent:
Σ Original
Estimate:
Environment:
Bug
lprimak
Fixed
None
Not Specified
Issue Links:
Cloners
is cloned by
2.19
Priority:
Assignee:
Votes:
Critical
Michal Gajdos
3
Not Specified
Remaining
Estimate:
Not Specified
Not Specified
Time Spent:
Not Specified
Not Specified
Original
Estimate:
Initiating Jersey application, version Jersey: 2.10.4 2014-08-08 15:09:00…]]
Glassfish 4.1 promoted build downloaded August 20th, 2014
Duplicate
is duplicated
by
JERSEY2629
CLONE - Glassfish / Jersey throws
NPE...
Closed
JERSEY2807
Glassfish / Jersey throws NPE on
star...
Closed
Sub-Tasks:
Key
JERSEY-2752
Tags:
jersey, pull-request
Summary
Type
This critical issue Sub-task
still exists
Status
Closed
Assignee
Description
Application fails to start in a Availability-enabled clustered environment.
The application works in the same domain when not deployed in a cluster.
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:1
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:40
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 [ 24/Aug/14 ]
I believe (this is just a guess) this is due to my application named 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
Comment by lprimak [ 24/Aug/14 ]
Yup. This is confirmed. Same application runs fine when not versioned,
i.e. deployed as my_app as opposed to my_app:20140824
Application versioning is broken.
Comment by Jakub Podlesak [ 01/Sep/14 ]
This is probably related to how Jersey uses GF internal API to get EJB info. The issue should be reproducible
also in a standalone server deployment (no cluster needed IIUC).
final EjbContainerUtil ejbUtil = EjbContainerUtilImpl.getInstance();
final ApplicationInfo appInfo =
ejbUtil.getDeployment().get((String)initialContext.lookup("java:app/AppName"));
Above we need to make sure the version suffix is trimmed out if present.
Comment by Jakub Podlesak [ 01/Sep/14 ]
Hmmm, new InitialContext().lookup("java:app/AppName") works fine, the problem is in getting applica
as there
apparently the version info is required.
Comment by Jakub Podlesak [ 02/Sep/14 ]
Here is a link to application versioning doc: http://docs.oracle.com/cd/E18930_01/html/821-2417/gihzx.html#gk
Moving this issue to backlog.
Comment by lprimak [ 08/Jan/15 ]
This is still an issue. Any updates are appreciated.
This prevents deployment of version applications using jersey on glassfish.
Comment by lprimak [ 27/Feb/15 ]
I am very surprised by lack of activity on this issue.
I even have a private patch for it.
It's hard for me to believe that no one is using Jersey versioned applications on GlassFish.
Comment by Andybailey [ 17/Mar/15 ]
We need to use versioned deployment too, this is broken as described and is critical to our deployment scenario.
Comment by Michal Gajdos [ 17/Mar/15 ]
@lprimak - Can you provide your patch as a GitHub pull request?
Comment by lprimak [ 23/Mar/15 ]
I am not very well familiar with git / github (I use Mercurial)
but here is the patch pasted here, it's not very large.
The only need is to compile / replace jersey-gf-ejb directory with this patch
VersionBug.patch
diff --git a/containers/glassfish/jersey-gfejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
b/containers/glassfish/jersey-gfejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
index f08c81a..7d429be 100644
--- a/containers/glassfish/jersey-gfejb/src/main/java/org/glassfish/jersey/gf/ejb/internal/EjbComponentProvider.java
+++ b/containers/glassfish/jersey-gfejb/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(ResourceMethodInvocationHandlerProvide
configuration);
configuration.commit();
}
+
+
private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingExc
+
{
+
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)) {
+
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 [ 23/Mar/15 ]
I just figured out how to do pull requests:
https://github.com/jersey/jersey/pull/154
I did not test it against the current code, but it didn't change much so it should work just as well as with productio
release
Comment by Jakub Podlesak [ 24/Mar/15 ]
Thanks for the patch! After you sign the OCA, we can proceed further. Please see my comment on your pull req
details.
Comment by lprimak [ 24/Mar/15 ]
Done
Comment by lprimak [ 17/Apr/15 ]
OCA has been approved
Comment by lprimak [ 24/May/15 ]
New Pull request - https://github.com/jersey/jersey/pull/167
Comment by lprimak [ 09/Jun/15 ]
It's ready to go. Please integrate the pull request - thanks!
Generated at Sun Apr 30 12:00:57 UTC 2017 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.
Related documents