1
votes

I'm testing joss javaswift following this link. I also added JAR files from here to my project. But it provides an error. What am I doing wrong?

package test;

import org.javaswift.joss.client.factory.AccountConfig;
import org.javaswift.joss.client.factory.AccountFactory;
import org.javaswift.joss.model.Account;      

public class Test {

    public static void main(String[] args)
    {
        String username = "user";
        String password = "pwd";
        String authUrl  = "http://...";
        String tenantName = "test";

        AccountConfig config = new AccountConfig();
        config.setUsername(username);
        config.setPassword(password);
        config.setAuthUrl(authUrl);
        config.setTenantName(tenantName);

        Account account = new AccountFactory(config).createAccount();

    }
}

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory at org.javaswift.joss.client.factory.AccountFactory.createClientImpl(AccountFactory.java:38) at org.javaswift.joss.client.factory.AccountFactory.createAccount(AccountFactory.java:28) at test.TestSWIFT3.main(TestSWIFT3.java:23)

Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.scheme.SchemeSocketFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 3 more

1

1 Answers

1
votes

I think that you have a problem with the dependencies of the project.

Generally speaking, you need to create a project and in the project create a pom file for download the dependencies dynamically using maven.

The structure of the project should have a pom.xml file in the general configuration.

The pom file should contain at minimum the next information.

<?xml version="1.0" encoding="UTF-8"?>
<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>groupId</groupId>
    <artifactId>testJoss</artifactId>
    <version>1.0-SNAPSHOT</version>


    <dependencies>
        <dependency>
            <groupId>org.javaswift</groupId>
            <artifactId>joss</artifactId>
            <version>0.9.7</version>
        </dependency>
    </dependencies>

</project>

The first line is the definition required for the pom in the project.

I create an example project with the proper libraries.

https://bitbucket.org/stackoverflowquestion/testjoss/src/b6f930cd02d85ec71c27d5560ca2fe34097ce4d4?at=master

The example project works fine and the issue with the libraries is not present. The example have the debug activated, so, it is possible to see if everything goes well.