1

I am trying to add http-client to my maven project, and I have not managed to do so.

I have added the http-core, commons-codec and commons-logging and it is not working.

That is the error I get:

java.lang.IllegalStateException: Can't install feature
onos-testingapp/0.0.0: Could not start bundle
mvn:org.onosproject/onos-testingapp/1.3.0-SNAPSHOT in feature(s)
onos-testingapp-1.3.0-SNAPSHOT: Unresolved constraint in bundle
onos-testingapp [175]: Unable to resolve 175.0: missing requirement
[175.0] osgi.wiring.package; (osgi.wiring.package=org.apache.http)

Here is my POM file:

     <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.scr.annotations</artifactId>
        <version>1.9.8</version>
        <scope>provided</scope>
    </dependency>


    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.json</artifactId>
        <version>1.0.4</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.9</version>
    </dependency>


    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.1</version>
    </dependency>



</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Import-Package>*, !javax.json</Import-Package>
                </instructions>
            </configuration>
        </plugin>

    </plugins>
</build>

I am far from being a Maven expert so the problem might be simple, however I have tried many things unsuccessfully. If anyone has an idea I am listening.

StephenKing
  • 36,187
  • 11
  • 83
  • 112
Nick
  • 11
  • 2
  • You're deploying an OSGi bundle, that needs packages from other bundles (`org.apache.http` here it seems). But these `org.apache.httpcomponents` dependencies might just be plain JARs, not OSGi bundles. Just try using `org.apache.httpcomponents:httpclient-osgi` instead of the plain `http-client` one. Depending on how it is packaged, you might also remove the other `org.apache.httpcomponents` deps. – Tome Aug 31 '15 at 17:33
  • I tried using org.apache.httpcomponents:httpclient-osgi, with and without org.apache.httpcomponents:httpcore-osgi. I also tried using these 2 and adding org.apache.httpcomponents:httpclient-cache. None of this is working, I still have the same error – Nick Aug 31 '15 at 19:11
  • In which container you deploying your bundles ? – shashantrika Sep 01 '15 at 08:49
  • 1
    After some some digging I found out that : "You need[HttpClient OSGI and] HttpCore OSGi bundle and a bundle exporting Commons Logging APIs to satisfy requisite dependencies of HttpClient OSGi bundle." But I don't know how to include a bundle exporting the commons logging API – Nick Sep 02 '15 at 14:59

0 Answers0