BatchEE
  1. BatchEE
  2. BATCHEE-59

Invoking JobOperator#start() using BatchEEJAXRS2Client always produces NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.2-incubating
    • Fix Version/s: 0.3-incubating
    • Component/s: batchee-jaxrs
    • Labels:
      None
    • Environment:

      WildFly 8.2.0.Final (I'm using only JAX-RS modules in BatchEE. using JBeret as JSR352 runtime)

      Description

      Reproducer: https://github.com/lbtc-xxx/batcheetest

      Step to reproduce:

      1. Deploy the app
      2. Run myjob.MyJobIT

      Stacktrace on server side:

      17:53:47,927 ERROR [io.undertow.request] (default task-16) UT005023: Exception handling request to /batcheetest/jbatch/batchee/execution/start/myjob: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
      	at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
      	at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
      	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
      Caused by: java.lang.NullPointerException
      	at org.apache.batchee.jaxrs.common.RestProperties.unwrap(RestProperties.java:46) [batchee-jaxrs-common-0.3-incubating-SNAPSHOT.jar:]
      	at org.apache.batchee.jaxrs.server.JBatchResourceImpl.start(JBatchResourceImpl.java:114) [batchee-jaxrs-server-0.3-incubating-SNAPSHOT.jar:]
      	at org.apache.batchee.jaxrs.server.JBatchResourceImpl$Proxy$_$$_WeldClientProxy.start(Unknown Source) [batchee-jaxrs-server-0.3-incubating-SNAPSHOT.jar:]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_20]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_20]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_20]
      	at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_20]
      	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.10.Final.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:]
      	... 31 more
      
      1. BATCHEE-59.patch
        0.7 kB
        Kohei Nozaki
      2. BATCHEE-59-test.patch
        14 kB
        Kohei Nozaki
      3. BATCHEE-59-test-withEmbeddedTomcat-rev2.patch
        8 kB
        Kohei Nozaki

        Activity

        Hide
        Romain Manni-Bucau added a comment -

        Hi

        patch looks good.

        we need to harness it adding a test in https://github.com/apache/incubator-batchee/blob/master/gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/ClientTestBase.java. Do you want to have a try as well before we push your patch?

        Show
        Romain Manni-Bucau added a comment - Hi patch looks good. we need to harness it adding a test in https://github.com/apache/incubator-batchee/blob/master/gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/ClientTestBase.java . Do you want to have a try as well before we push your patch?
        Hide
        Kohei Nozaki added a comment -

        Hi thanks for the response. I don't know if I can do it but I'll give it a try.

        Show
        Kohei Nozaki added a comment - Hi thanks for the response. I don't know if I can do it but I'll give it a try.
        Hide
        Kohei Nozaki added a comment -

        I guess the test case should assert request body which sent by client, but can FeaturedHttpServer assert request body? will introducing some new mocking framework such as WireMock be acceptable?

        Show
        Kohei Nozaki added a comment - I guess the test case should assert request body which sent by client, but can FeaturedHttpServer assert request body? will introducing some new mocking framework such as WireMock be acceptable?
        Hide
        Romain Manni-Bucau added a comment -

        Not sure I follow you but here 2 (hopefully useful) notes:

        • about dependencies we have to stick to asf v2 compliant
        • about your check on body I agree but we shouldn't need any lib to do it, I mean we can just check the job is behaving correctly and we don't have a failure, would be enough IMO.

        Side note: issue you'll get - and why it was not tested I think - is you'll need to reset the storage after your start test to avoid other tests to be affectedbut that's not very hard.

        Feel free to ping us on #batchee (on freenode) if you want some help or on the mailing list

        Show
        Romain Manni-Bucau added a comment - Not sure I follow you but here 2 (hopefully useful) notes: about dependencies we have to stick to asf v2 compliant about your check on body I agree but we shouldn't need any lib to do it, I mean we can just check the job is behaving correctly and we don't have a failure, would be enough IMO. Side note: issue you'll get - and why it was not tested I think - is you'll need to reset the storage after your start test to avoid other tests to be affectedbut that's not very hard. Feel free to ping us on #batchee (on freenode) if you want some help or on the mailing list
        Hide
        Kohei Nozaki added a comment -

        OK, thanks. I would submit here an another patch in a few days. I'm planning to use com.sun.net.httpserver.HttpServer for mocking the server.

        But I don't know what "reset the storage" means. I couldn't found any use of storage in the test class...

        Show
        Kohei Nozaki added a comment - OK, thanks. I would submit here an another patch in a few days. I'm planning to use com.sun.net.httpserver.HttpServer for mocking the server. But I don't know what "reset the storage" means. I couldn't found any use of storage in the test class...
        Hide
        Romain Manni-Bucau added a comment -

        well not sure what httpserver will bring compared to FeaturedHttpServer. This last one is really about having mocked answer in resources/ and keep it easy.

        about storage I meant JBatch repository. Other test methods are testing predefined jobs so since we don't control method execution order if start runs before getJobNames you can get a failure just because of the ordering.

        Using batchee ServicesManager should allow you to get persistence storage (in memory by default IIRC) and remove the job you just started

        Show
        Romain Manni-Bucau added a comment - well not sure what httpserver will bring compared to FeaturedHttpServer. This last one is really about having mocked answer in resources/ and keep it easy. about storage I meant JBatch repository. Other test methods are testing predefined jobs so since we don't control method execution order if start runs before getJobNames you can get a failure just because of the ordering. Using batchee ServicesManager should allow you to get persistence storage (in memory by default IIRC) and remove the job you just started
        Hide
        Kohei Nozaki added a comment -

        I'm planning HttpServer because I don't know how to assert request body with FeaturedHttpServer. I agree that it's better to use FeaturedHttpServer if I can, or extending FeaturedHttpServer might be a better approach.

        Does ClientTestBase actually manipulate JBatch repository or invoke real jobs? they looks like just send HTTP request and receive mocked results that placed under test/resources/batchee. am I wrong?

        Show
        Kohei Nozaki added a comment - I'm planning HttpServer because I don't know how to assert request body with FeaturedHttpServer. I agree that it's better to use FeaturedHttpServer if I can, or extending FeaturedHttpServer might be a better approach. Does ClientTestBase actually manipulate JBatch repository or invoke real jobs? they looks like just send HTTP request and receive mocked results that placed under test/resources/batchee. am I wrong?
        Hide
        Romain Manni-Bucau added a comment -

        you are right

        my idea was to keep it simple, start a job then set in the batch a static variable with the parameters and assert this static variable once the job is done - we still are in a single classloader so it would work. This way no need to check anything in http server. FeaturedHttpServer can get a handler as well but if we want to go with this kind of test using a real server is a better option - easier to understand. I don't think it is needed for what we propose at the moment (actually you don't care of the body, you just want to check the job is started correctly ).

        Show
        Romain Manni-Bucau added a comment - you are right my idea was to keep it simple, start a job then set in the batch a static variable with the parameters and assert this static variable once the job is done - we still are in a single classloader so it would work. This way no need to check anything in http server. FeaturedHttpServer can get a handler as well but if we want to go with this kind of test using a real server is a better option - easier to understand. I don't think it is needed for what we propose at the moment (actually you don't care of the body, you just want to check the job is started correctly ).
        Hide
        Kohei Nozaki added a comment -

        OK I will take the approach that you suggested - invoking real job, set and assert some static variable. thanks

        Show
        Kohei Nozaki added a comment - OK I will take the approach that you suggested - invoking real job, set and assert some static variable. thanks
        Hide
        Kohei Nozaki added a comment -

        I created a new JUnit test class, because ClientTestBase is TestNG test class and all of Arquillian tests are wrote with JUnit.

        Show
        Kohei Nozaki added a comment - I created a new JUnit test class, because ClientTestBase is TestNG test class and all of Arquillian tests are wrote with JUnit.
        Hide
        Romain Manni-Bucau added a comment -

        I'd like to avoid arquillian to test the client part for now to keep contributions/patches easy.

        IIRC our tests should mainly be testng excepted arquillian ones cause testng support is not at junit level - junit tests are surely "too fast completion" issues I think

        Do you care reworking your test a bit to comply to these few rules? (BTW good work!)

        Show
        Romain Manni-Bucau added a comment - I'd like to avoid arquillian to test the client part for now to keep contributions/patches easy. IIRC our tests should mainly be testng excepted arquillian ones cause testng support is not at junit level - junit tests are surely "too fast completion" issues I think Do you care reworking your test a bit to comply to these few rules? (BTW good work!)
        Hide
        Kohei Nozaki added a comment -

        How about this one? I have no idea how to achieve testing against real server anymore.

        Note that now a test on CxfClientTest failed because I added a test to ClientTestBase.

        Show
        Kohei Nozaki added a comment - How about this one? I have no idea how to achieve testing against real server anymore. Note that now a test on CxfClientTest failed because I added a test to ClientTestBase.
        Hide
        Kohei Nozaki added a comment -

        License header was missing.

        Show
        Kohei Nozaki added a comment - License header was missing.
        Hide
        Kohei Nozaki added a comment -

        Changed invocation of Tomcat.addServlet() class method to instance method.

        Show
        Kohei Nozaki added a comment - Changed invocation of Tomcat.addServlet() class method to instance method.
        Hide
        Romain Manni-Bucau added a comment -

        Pushed a fix - not 100% your patch cause I would like to avoid server as dependency in client mainly + I would love to keep the client with a 100% mocked server to keep the contract explicit - that said I think we'll need to enhance it with a tomcat as you did or with arquillian but surely in an IT module).

        I'm still waiting featured mock release to add the server assert you spoke about cleanly

        Show
        Romain Manni-Bucau added a comment - Pushed a fix - not 100% your patch cause I would like to avoid server as dependency in client mainly + I would love to keep the client with a 100% mocked server to keep the contract explicit - that said I think we'll need to enhance it with a tomcat as you did or with arquillian but surely in an IT module). I'm still waiting featured mock release to add the server assert you spoke about cleanly
        Hide
        Hudson added a comment -

        SUCCESS: Integrated in batchee #549 (See https://builds.apache.org/job/batchee/549/)
        BATCHEE-59 patch from Kohei Nozaki (thanks a lot) fixing properties parameter for start method in jaxrs-client + starting to test it (still need an assert on server side but waiting featured mock upgrade) (rmannibucau: rev 9868a839d21fb9966905ca00b576cdb7227ba68b)

        • gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/SimpleBatchlet.java
        • gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/ClientTestBase.java
        • gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/ClientConfiguration.java
        • gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/CxfClientConfiguration.java
        • gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/BatchEEJAXRS1CxfClient.java
        • gui/jaxrs/jaxrs-client/src/test/resources/batchee/execution/start/simple.json
        • gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/BatchEEJAXRS2Client.java
        • gui/jaxrs/jaxrs-client/pom.xml
        Show
        Hudson added a comment - SUCCESS: Integrated in batchee #549 (See https://builds.apache.org/job/batchee/549/ ) BATCHEE-59 patch from Kohei Nozaki (thanks a lot) fixing properties parameter for start method in jaxrs-client + starting to test it (still need an assert on server side but waiting featured mock upgrade) (rmannibucau: rev 9868a839d21fb9966905ca00b576cdb7227ba68b) gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/SimpleBatchlet.java gui/jaxrs/jaxrs-client/src/test/java/org/apache/batchee/jaxrs/client/ClientTestBase.java gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/ClientConfiguration.java gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/CxfClientConfiguration.java gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/BatchEEJAXRS1CxfClient.java gui/jaxrs/jaxrs-client/src/test/resources/batchee/execution/start/simple.json gui/jaxrs/jaxrs-client/src/main/java/org/apache/batchee/jaxrs/client/BatchEEJAXRS2Client.java gui/jaxrs/jaxrs-client/pom.xml
        Hide
        Kohei Nozaki added a comment -

        I agree that mocked testcase is better so far. thank you for feedbacks

        Show
        Kohei Nozaki added a comment - I agree that mocked testcase is better so far. thank you for feedbacks
        Hide
        Mark Struberg added a comment -

        shipped with batchee-0.3-incubating

        Show
        Mark Struberg added a comment - shipped with batchee-0.3-incubating

          People

          • Assignee:
            Romain Manni-Bucau
            Reporter:
            Kohei Nozaki
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development