Topic
11 replies Latest Post - ‏2012-02-23T06:32:01Z by U4UE_xie_zhi
MJonker
MJonker
26 Posts
ACCEPTED ANSWER

Pinned topic Creating application failed, dependency on Apache HTTP client 4.1

‏2011-12-24T10:35:46Z |
Hi,

I have an EJB application (in an EAR) that uses Apache HttpClient.

The open-ejbjax.xml contains the references to the jars in the repository

<dep:dependency>
<dep:groupId>HttpDataService</dep:groupId>
<dep:artifactId>httpclient</dep:artifactId>
<dep:version>4.1.2</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>HttpDataService</dep:groupId>
<dep:artifactId>httpcore</dep:artifactId>
<dep:version>4.1.2</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>

The repositories are there, actually I picked them up in Eclipse from the Server...

But when I deploy (in Eclipse or through the WAS CE console) the EAR, I get this error.

2011-12-24 11:28:58,644 ERROR GBeanInstanceState Error while starting; GBean is now in the FAILED state: abstractName="AtriumServiceLaag/ManageDienstverleningEAR/1.0/car?J2EEApplication=AtriumServiceLaag/ManageDienstverleningEAR/1.0/car,j2eeType=appInfoGBean,name=appInfoGBean"
org.apache.openejb.OpenEJBException: Creating application failed: C:\Software\eclipse-jee-indigo-win32\eclipse\AtriumServiceLaag\ManageDienstverleningEAR\1.0\car: Error building bean 'AtriumMonitor'. Exception: class java.lang.NoClassDefFoundError: org/apache/http/HttpEntity: org/apache/http/HttpEntity

I already tried to use the older http commons (3.0.1) for which a repository is available out of the box, but the same error (with a different NoClassdeffoundError) occurs.
The strange thing is, that sometimes the application does get started and seems to be running, but this is not entirely reliable.

Could this be related to the EJB nature ? I am doing a similar thing from a webapp and there this error doesn't occur...

TIA

Michel Jonker
Updated on 2012-02-23T06:32:01Z at 2012-02-23T06:32:01Z by U4UE_xie_zhi
  • SystemAdmin
    SystemAdmin
    2233 Posts
    ACCEPTED ANSWER

    Re: Creating application failed, dependency on Apache HTTP client 4.1

    ‏2011-12-27T02:08:54Z  in response to MJonker
    Hi,
    That would be very useful if you attach the packages or plan.xml (if you have) to this thread.

    And what's the WAS CE version you use?
  • MJonker
    MJonker
    26 Posts
    ACCEPTED ANSWER

    Re: Creating application failed, dependency on Apache HTTP client 4.1

    ‏2011-12-27T08:57:37Z  in response to MJonker
    Thanks QiuXiaoFan

    This is my openejb-jar.xml from my test project. I have attached the Eclipse Project, it contains references to Apache Http Client 4.1.2 on the build path.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <ejb:openejb-jar xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
    <dep:environment>
    <dep:moduleId>
    <dep:groupId>default</dep:groupId>
    <dep:artifactId>TestCL</dep:artifactId>
    <dep:version>1.0</dep:version>
    <dep:type>car</dep:type>
    </dep:moduleId>
    <dep:dependencies>
    <dep:dependency>
    <dep:groupId>DominoDataService</dep:groupId>
    <dep:artifactId>httpclient</dep:artifactId>
    <dep:version>4.1.2</dep:version>
    <dep:type>jar</dep:type>
    </dep:dependency>
    <dep:dependency>
    <dep:groupId>DominoDataService</dep:groupId>
    <dep:artifactId>httpcore</dep:artifactId>
    <dep:version>4.1.2</dep:version>
    <dep:type>jar</dep:type>
    </dep:dependency>
    </dep:dependencies>
    </dep:environment>
    </ejb:openejb-jar>
    • MJonker
      MJonker
      26 Posts
      ACCEPTED ANSWER

      Re: Creating application failed, dependency on Apache HTTP client 4.1

      ‏2011-12-27T09:00:00Z  in response to MJonker
      I added (two) jars to the WAS CE repository using the WAS CE admin console.
      I uploaded the jar and only specified the DominoDataService as group-id.

      What I did find out, is that the httpclient.jar is linked (imports) the out of the box HTTP Core (4.0.1) jar.
      I don't know how to change this dependency/import..
    • MJonker
      MJonker
      26 Posts
      ACCEPTED ANSWER

      Re: Creating application failed, dependency on Apache HTTP client 4.1

      ‏2011-12-27T13:22:02Z  in response to MJonker
      I am using WAS CE 3.0.0

      When I use the same code in a web-app (I have put the jars in WEB-INFlib folder) it deployes and runs fine.

      So now I am considering to move the EJB into the web-app (3.1 EJB should make this possible).
      • MJonker
        MJonker
        26 Posts
        ACCEPTED ANSWER

        Re: Creating application failed, dependency on Apache HTTP client 4.1

        ‏2011-12-27T14:39:58Z  in response to MJonker
        Too bad, still some classloading errors when moving to a dynamic WebApp.

        This happens only when I have an EJB in my project.

        java.lang.ClassCastException: org.apache.http.message.BasicNameValuePair cannot be cast to org.apache.http.NameValuePair

        And after some more troubleshooting:

        java.lang.LinkageError: loader constraint violation: when resolving method

        "org.apache.http.client.methods.HttpPost.setEntity(Lorg/apache/http/HttpEntity;)V"
        the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, nl/mic/test/PostIt, and

        the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class,
        org/apache/http/client/methods/HttpPost, have different Class objects for the type org/apache/http/HttpEntity used in the signature
        • SystemAdmin
          SystemAdmin
          2233 Posts
          ACCEPTED ANSWER

          Re: Creating application failed, dependency on Apache HTTP client 4.1

          ‏2011-12-28T00:46:06Z  in response to MJonker
          Try to put your dependent packages to WAS CE installation path\lib\endorsed
          • MJonker
            MJonker
            26 Posts
            ACCEPTED ANSWER

            Re: Creating application failed, dependency on Apache HTTP client 4.1

            ‏2011-12-28T08:11:02Z  in response to SystemAdmin
            Thanks again QiuXiaoFan

            I also tried this, but no luck.

            For now I have taken plan B: using the java.net package .
            • Forrest_Xia
              Forrest_Xia
              82 Posts
              ACCEPTED ANSWER

              Re: Creating application failed, dependency on Apache HTTP client 4.1

              ‏2012-01-06T08:08:03Z  in response to MJonker
              Hi MJonker,

              Option 1 should be a supported way to work, can you please help open a jira in https://issues.apache.org/jira/browse/GERONIMO with your test app attached?

              Thank you for your reporting in advance!

              Forrest
              • MJonker
                MJonker
                26 Posts
                ACCEPTED ANSWER

                Re: Creating application failed, dependency on Apache HTTP client 4.1

                ‏2012-01-09T09:29:27Z  in response to Forrest_Xia
                I have opened an issue here

                https://issues.apache.org/jira/browse/GERONIMO-6258
  • Shawn_Jiang
    Shawn_Jiang
    154 Posts
    ACCEPTED ANSWER

    Re: Creating application failed, dependency on Apache HTTP client 4.1

    ‏2012-01-19T14:38:49Z  in response to MJonker
    You might want to put

    <dep:dependency>
    <dep:groupId>HttpDataService</dep:groupId>
    <dep:artifactId>httpclient</dep:artifactId>
    <dep:version>4.1.2</dep:version>
    <dep:type>jar</dep:type>
    </dep:dependency>

    in your geornimo-application.xml instead of the openejb-jar.xml and try it again.