11 Replies Latest reply: Sep 10, 2013 11:51 AM by Aslak Knutsen RSS

Container adapter for a Java EE5 certified AS

Kristiyan Marinov Newbie

Hi all,

 

I'm trying to implement a container adapter for SAP NetWeaver. I have the following running end-to-end:

  • create shrinkwrap archive
  • auto deploy before test
  • run test
  • auto undeploy

 

The problem is that the test itself fails because the EJB injection does not work. The most probable problem identified so far is that because the Java EE5 spec does not mandate a standard JNDI name, injection fails because the container uses its own custom name. I tried overriding the test enricher to account for that, but the problem is that I cannot seem to get it to load & be used. I tried making the enricher always throw an exception when called, just to verify that it is indeed my implementation that gets called but to no avail.

 

Could you guys take a look at the code and see if I missed anything? I have the feeling that it is something very obvious ..

 

Code is located at: https://github.com/pnt/arquillian-container-netweaver

  • 1. Re: Container adapter for a Java EE5 certified AS
    Andrew Rubinger Master

    Do you also have a test you could put in that repo which would illustrate the problem?  Then we can simply fork it, see the issue, and move from there.

     

    S,

    ALR

  • 2. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    The simple test app is also in the git repo.
    Also, you will notice that there are hard-coded JNDI names and such, please assume they are correct and only for test purposes

     

    Kristiyan

  • 3. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    I'm still unable to see why my test enricher does not get loaded & used .. SPI looks okay.

  • 4. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    Current status of investigation:
    The NWExtension class gets loaded & called via SPI to register the service provider. However, it appears that the provider itself (extension of ejb injection enricher), although registered, doesn't get used. Is it possible that the standard one gets used instead?

     

    Can anyone who's implemented container adapters help with debugging/getting it running?

  • 5. Re: Container adapter for a Java EE5 certified AS
    Aslak Knutsen Master

    The EJB Enricher Extension use the wrong impl class name in the Service registration:

    https://github.com/pnt/arquillian-container-netweaver/blob/master/nw-testenricher-ejb/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension

     

    That should be the fully qualified classname, not file path. (without the main.java part :)

  • 6. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    Hi Aslak,

     

    (With some delay) The fully classified name has been fixed, the project structure was a bit messed up. Nevertheless, the situation is still the same - ejb test enricher does get registered & loaded but not utilized. I'm currently trying ot debug why doesn't it get called but I still have no idea. So far my findings are that the getFieldsWithAnnotations method (form the base EJBTestEnricher) is called on the enricher implementation class itself, not on my test class.

  • 7. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    Okay, with some input by Aslak on Twitter, namely this guide https://github.com/VineetReynolds/arquillian.github.com/blob/4397795dc14df2adc158b2c33d30695adef15ee4/guides/developing_a_container_adapter.textile, I got a little further and now I'm stuck with what I see is a somewhat common problem. Sadly, I haven't managed to apply any of the known solutions to my case.

    Exception:

     

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

    Test set: com.sap.nw.arquillian.test.FirstTest

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

    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.167 sec <<< FAILURE!

    shouldReturnString(com.sap.nw.arquillian.test.FirstTest)  Time elapsed: 0.914 sec  <<< ERROR!

    java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

              at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:160)

              at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:111)

              at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:97)

              at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)

              at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)

              at org.junit.runner.JUnitCore.run(JUnitCore.java:152)

              at org.junit.runner.JUnitCore.run(JUnitCore.java:131)

              at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

              at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

              at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

              at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              at com.sap.engine.services.servlets_jsp.server.Invokable.invoke(Invokable.java:152)

              at com.sap.engine.services.servlets_jsp.server.Invokable.invoke(Invokable.java:38)

              at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:457)

              at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:210)

              at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:441)

              at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:430)

              at com.sap.engine.services.servlets_jsp.filters.DSRWebContainerFilter.process(DSRWebContainerFilter.java:38)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.servlets_jsp.filters.ServletSelector.process(ServletSelector.java:81)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.servlets_jsp.filters.ApplicationSelector.process(ApplicationSelector.java:278)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.WebContainerInvoker.process(WebContainerInvoker.java:81)

              at com.sap.engine.services.httpserver.chain.HostFilter.process(HostFilter.java:9)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.ResponseLogWriter.process(ResponseLogWriter.java:60)

              at com.sap.engine.services.httpserver.chain.HostFilter.process(HostFilter.java:9)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.DefineHostFilter.process(DefineHostFilter.java:27)

              at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.MonitoringFilter.process(MonitoringFilter.java:29)

              at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.SessionSizeFilter.process(SessionSizeFilter.java:26)

              at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.MemoryStatisticFilter.process(MemoryStatisticFilter.java:57)

              at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.filters.DSRHttpFilter.process(DSRHttpFilter.java:43)

              at com.sap.engine.services.httpserver.chain.ServerFilter.process(ServerFilter.java:12)

              at com.sap.engine.services.httpserver.chain.AbstractChain.process(AbstractChain.java:78)

              at com.sap.engine.services.httpserver.server.Processor.chainedRequest(Processor.java:475)

              at com.sap.engine.services.httpserver.server.Processor$FCAProcessorThread.process(Processor.java:269)

              at com.sap.engine.services.httpserver.server.rcm.RequestProcessorThread.run(RequestProcessorThread.java:56)

              at com.sap.engine.core.thread.execution.Executable.run(Executable.java:122)

              at com.sap.engine.core.thread.execution.Executable.run(Executable.java:101)

              at com.sap.engine.core.thread.execution.CentralExecutor$SingleThread.run(CentralExecutor.java:328)

    Caused by: java.lang.reflect.InvocationTargetException

              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

              at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:156)

              ... 51 more

    Caused by: java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.core.impl.ManagerImpl

              at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:160)

              at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:111)

              at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:97)

              at org.jboss.arquillian.core.spi.ManagerBuilder.create(ManagerBuilder.java:77)

              at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:55)

              ... 56 more

     

     

    Container adapter pom:

     

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

              <modelVersion>4.0.0</modelVersion>

              <groupId>org.jboss.arquillian.container</groupId>

              <artifactId>arquillian-nw-remote-7.3</artifactId>

              <version>0.0.1-SNAPSHOT</version>

              <name>arquillian-nw-remote-7.3</name>

              <description>Arquillian container support for a remote SAP NetWeaver 7.3 and above container</description>

              <build>

                        <sourceDirectory>src</sourceDirectory>

                        <plugins>

                                  <plugin>

                                            <artifactId>maven-compiler-plugin</artifactId>

                                            <version>2.3.2</version>

                                            <configuration>

                                                      <source>1.6</source>

                                                      <target>1.6</target>

                                            </configuration>

                                  </plugin>

                        </plugins>

              </build>

              <dependencies>

                        <dependency>

                                  <groupId>org.jboss.arquillian.container</groupId>

                                  <artifactId>arquillian-container-spi</artifactId>

                        </dependency>

                        <dependency>

                                  <groupId>org.jboss.arquillian.container</groupId>

                                  <artifactId>arquillian-container-test-spi</artifactId>

                        </dependency>

                        <dependency>

                                  <groupId>axis</groupId>

                                  <artifactId>axis</artifactId>

                                  <version>1.4</version>

                        </dependency>

                        <dependency>

                                  <groupId>org.apache.axis</groupId>

                                  <artifactId>axis-jaxrpc</artifactId>

                                  <version>1.4</version>

                        </dependency>

                        <dependency>

                                  <groupId>org.jboss.arquillian.testenricher</groupId>

                                  <artifactId>arquillian-testenricher-nw-ejb</artifactId>

                                  <version>0.0.1-SNAPSHOT</version>

                                  <scope>runtime</scope>

                        </dependency>

                        <dependency>

                                  <groupId>org.jboss.arquillian.protocol</groupId>

                                  <artifactId>arquillian-protocol-servlet</artifactId>

                        </dependency>

              </dependencies>

              <dependencyManagement>

                        <dependencies>

                                  <dependency>

                                            <groupId>org.jboss.arquillian</groupId>

                                            <artifactId>arquillian-bom</artifactId>

                                            <version>1.0.3.Final</version>

                                            <type>pom</type>

                                            <scope>import</scope>

                                  </dependency>

                        </dependencies>

              </dependencyManagement>

    </project>

     

     

     

    Test project pom:

     

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

              <modelVersion>4.0.0</modelVersion>

              <groupId>testapp</groupId>

              <artifactId>testapp</artifactId>

              <version>0.0.1-SNAPSHOT</version>

              <build>

                        <sourceDirectory>src</sourceDirectory>

                        <testSourceDirectory>test</testSourceDirectory>

                        <plugins>

                                  <plugin>

                                            <artifactId>maven-compiler-plugin</artifactId>

                                            <version>2.3.2</version>

                                            <configuration>

                                                      <source>1.6</source>

                                                      <target>1.6</target>

                                            </configuration>

                                  </plugin>

                                  <plugin>

                                            <artifactId>maven-surefire-plugin</artifactId>

                                            <version>2.12</version>

                                  </plugin>

                        </plugins>

              </build>

              <dependencyManagement>

                        <dependencies>

                                  <dependency>

                                            <groupId>org.jboss.arquillian</groupId>

                                            <artifactId>arquillian-bom</artifactId>

                                            <version>1.0.3.Final</version>

                                            <type>pom</type>

                                            <scope>import</scope>

                                  </dependency>

                        </dependencies>

              </dependencyManagement>

              <dependencies>

                        <dependency>

                                  <groupId>javax.mail</groupId>

                                  <artifactId>mail</artifactId>

                                  <version>1.4.5</version>

                        </dependency>

                        <dependency>

                                  <groupId>org.jboss.arquillian.junit</groupId>

                                  <artifactId>arquillian-junit-container</artifactId>

                                  <scope>test</scope>

                        </dependency>

     

     

                        <dependency>

                                  <groupId>org.jboss.arquillian.container</groupId>

                                  <artifactId>arquillian-nw-remote-7.3</artifactId>

                                  <version>0.0.1-SNAPSHOT</version>

                                  <scope>runtime</scope>

                        </dependency>

                        <dependency>

                                  <groupId>junit</groupId>

                                  <artifactId>junit</artifactId>

                                  <version>4.11-20120805-1225</version>

                                  <scope>test</scope>

                        </dependency>

                        <dependency>

                                  <groupId>javaee</groupId>

                                  <artifactId>javaee-api</artifactId>

                                  <version>5</version>

                                  <scope>compile</scope>

                        </dependency>

     

     

              </dependencies>

    </project>

     

     

     

    The question is what's missing for the ManagerImpl to be created. Is it some part of the context which I'm not returning during deploy? (currently I don't return everything) Or something else?

  • 8. Re: Container adapter for a Java EE5 certified AS
    Aslak Knutsen Master

    hmm, you don't have any more 'cause's in that StackTrace? Or possible some server log where you can see the real cause?

     

    If not, then try to set a debug break point in the EventTestRunnerAdaptor.java and see what the cause of the Exception is

  • 9. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    Hi Aslak,

     

    There's nothing more in the stack trace client side (that's why I wasn't able to use some of the solutions I found online). Server side, I see nothing else as well. Will try with the debug now.

     

    Otherwise, a list of frequent reasons for this to fail or a list of prerequisites that need to be met would be helpful to get me looking in the right direction. I might come up with some more information based on that.

     

    *edit* During debug, the ManagerBuilder.create() method passess succesfully, and so does the Manager.start(). After that, continuing the test the same result is returned after what looks like a  "clean" execution until the end. Any other ideas?

  • 10. Re: Container adapter for a Java EE5 certified AS
    Kristiyan Marinov Newbie

    Any idea on how to check the actual cause of the exception? During debug, everything surprisingly executes fine (including the methods from the stack trace, which aledgedly throw it), yet the exception is still generated.

  • 11. Re: Container adapter for a Java EE5 certified AS
    Aslak Knutsen Master

    Oops.. seems I dropped this thread.. Did you get any further on this one?