glassfish
  1. glassfish
  2. GLASSFISH-20881

java.lang.NullPointerException at com.sun.enterprise.deployment.util.DOLUtils.isRAConnectionFactory(DOLUtils.java:235)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.2, 4.0
    • Fix Version/s: 4.1
    • Component/s: deployment
    • Labels:
      None
    • Environment:

      All

      Description

      Here's the whole stacktrace about the NPE:

      [2013-10-31T11:14:46.471+0800] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=72 _ThreadName=admin-listener(2)] [timeMillis: 1383189286471] [levelValue: 1000] [[
        Exception while deploying the app [jcaWeb3] : null. Related annotation information: annotation [@javax.annotation.Resource(shareable=true, mappedName=, description=, name=eis/connectionFactory3, type=class java.lang.Object, authenticationType=CONTAINER, lookup=)] on annotated element [private com.sun.work.ksk.ConnectionFactory Sample.cf] of type [FIELD]
      null. Related annotation information: annotation [@javax.annotation.Resource(shareable=true, mappedName=, description=, name=eis/connectionFactory3, type=class java.lang.Object, authenticationType=CONTAINER, lookup=)] on annotated element [private com.sun.work.ksk.ConnectionFactory Sample.cf] of type [FIELD]
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:367)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:271)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:199)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
      	at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
      	at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
      	at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
      	at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
      	at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
      	at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
      	at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
      	at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241)
      	at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:161)
      	at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:203)
      	at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
      	at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
      	at org.glassfish.deployment.admin.InstanceDeployCommand.execute(InstanceDeployCommand.java:213)
      	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.execCommandMultInMultOut(CommandResource.java:256)
      	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$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
      	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.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.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: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.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: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)
      Caused by: java.lang.NullPointerException
      	at com.sun.enterprise.deployment.util.DOLUtils.isRAConnectionFactory(DOLUtils.java:235)
      	at com.sun.enterprise.deployment.annotation.handlers.ResourceHandler.getDescriptors(ResourceHandler.java:313)
      	at com.sun.enterprise.deployment.annotation.handlers.ResourceHandler.processResource(ResourceHandler.java:227)
      	at com.sun.enterprise.deployment.annotation.handlers.ResourceHandler.processAnnotation(ResourceHandler.java:146)
      	at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.processAnnotation(AbstractResourceHandler.java:142)
      	at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148)
      	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344)
      	... 95 more
      ]]
      

        Activity

        Hide
        ceyhun added a comment - - edited

        How can i use this DOLUtils class for starting glassfish on eclipse?

        Show
        ceyhun added a comment - - edited How can i use this DOLUtils class for starting glassfish on eclipse?
        Hide
        Jeremy_Lv added a comment -

        have checked in the changes as revision 62935.

        Show
        Jeremy_Lv added a comment - have checked in the changes as revision 62935.
        Hide
        Hong Zhang added a comment -

        Yeah changes look fine. Please go ahead and check in after running the usual tests.

        Show
        Hong Zhang added a comment - Yeah changes look fine. Please go ahead and check in after running the usual tests.
        Hide
        Jeremy_Lv added a comment - - edited

        Hi, Hong:

        Here's the related code:

        DOLUtils.java
            public static boolean isRAConnectionFactory(ServiceLocator habitat, 
                String type, Application thisApp) {
                // first check if this is a connection factory defined in a resource
                // adapter in this application
                if (isRAConnectionFactory(type, thisApp)) {
                    return true;
                }
        
                // then check if this is a connection factory defined in a standalone 
                // resource adapter
                Applications applications = habitat.getService(Applications.class);
                if (applications != null) {
                    List<com.sun.enterprise.config.serverbeans.Application> raApps = applications.getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
                    ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
                    for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) {
                        ApplicationInfo appInfo = appRegistry.get(raApp.getName());
                        if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) {   
                            return true;
                        }   
                    }
                }
                return false; 
            }
        

        After debugging the code, the appInfo will return the null when the value of raApp.getName() doesn't exist in the appRegistry. This situation cab be true because the raApps can collect all of the application deployed to the server, instance and cluster. However, the appRegistry will just get the attributes only deployed to the related instance or cluster, so the appInfo will return null when executing "ApplicationInfo appInfo = appRegistry.get(raApp.getName());"

        So we need a null check here to avoid the NPE, Here's my patch to fix this particular issue:

        DOLUtils.java
        Index: DOLUtils.java
        ===================================================================
        --- DOLUtils.java	(revision 62812)
        +++ DOLUtils.java	(working copy)
        @@ -232,6 +232,8 @@
                     ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
                     for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) {
                         ApplicationInfo appInfo = appRegistry.get(raApp.getName());
        +                if (appInfo == null)
        +                    continue;
                         if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) {   
                             return true;
                         }   
        

        Please review my changes whether it is fine for me to check in?

        Show
        Jeremy_Lv added a comment - - edited Hi, Hong: Here's the related code: DOLUtils.java public static boolean isRAConnectionFactory(ServiceLocator habitat, String type, Application thisApp) { // first check if this is a connection factory defined in a resource // adapter in this application if (isRAConnectionFactory(type, thisApp)) { return true ; } // then check if this is a connection factory defined in a standalone // resource adapter Applications applications = habitat.getService(Applications.class); if (applications != null ) { List<com.sun.enterprise.config.serverbeans.Application> raApps = applications.getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true ); ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class); for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) { ApplicationInfo appInfo = appRegistry.get(raApp.getName()); if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) { return true ; } } } return false ; } After debugging the code, the appInfo will return the null when the value of raApp.getName() doesn't exist in the appRegistry. This situation cab be true because the raApps can collect all of the application deployed to the server, instance and cluster. However, the appRegistry will just get the attributes only deployed to the related instance or cluster, so the appInfo will return null when executing "ApplicationInfo appInfo = appRegistry.get(raApp.getName());" So we need a null check here to avoid the NPE, Here's my patch to fix this particular issue: DOLUtils.java Index: DOLUtils.java =================================================================== --- DOLUtils.java (revision 62812) +++ DOLUtils.java (working copy) @@ -232,6 +232,8 @@ ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class); for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) { ApplicationInfo appInfo = appRegistry.get(raApp.getName()); + if (appInfo == null ) + continue ; if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) { return true ; } Please review my changes whether it is fine for me to check in?

          People

          • Assignee:
            Hong Zhang
            Reporter:
            Jeremy_Lv
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: