Labs64/NetLicensingClient-java

NetLicensing Demo: Class not found error

r-brown opened this issue · 4 comments

After adding NetLicensing dependency to the pom.xml

  <dependency>
    <groupId>com.labs64.netlicensing</groupId>
    <artifactId>netlicensing-client</artifactId>
    <version>2.3.8</version>
  </dependency>

I'm getting following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/jersey/client/ClientConfig
    at com.labs64.netlicensing.provider.RestProviderJersey.getClient(RestProviderJersey.java:119)
    at com.labs64.netlicensing.provider.RestProviderJersey.getTarget(RestProviderJersey.java:137)
    at com.labs64.netlicensing.provider.RestProviderJersey.call(RestProviderJersey.java:80)
    at com.labs64.netlicensing.service.NetLicensingService.request(NetLicensingService.java:204)
    at com.labs64.netlicensing.service.NetLicensingService.delete(NetLicensingService.java:160)
    at com.labs64.netlicensing.service.ProductService.delete(ProductService.java:140)
    at com.labs64.netlicensing.demo.NetLicensingClientDemo.main(NetLicensingClientDemo.java:385)

Using netlicensing-client dependency in IDE

Usually, your IDE (Eclipse or IntelliJ IDEA) is able to resolve all transitive dependencies of netlicensing-client.
Therefore all needed 3pp libraries and classes will be available in the classpath.

Using netlicensing-client dependency with Maven and CLI

Here is a step by step guideline on how to run NetLicensing Demo.

Preconditions

  • Java 1.7 or higher
  • Maven 3

1. Download NetLicensing Demo source code

Open NetLicensing releases and download latest released version.

2. Open project

Extract ZIP file and navigate to the NetLicensingClient-java/NetLicensingClient-demo folder

3. Prepare demo module

In order to isolate demo module from the parent maven module, please modify pom.xml accordingly:

  • add netlicensing-client dependency
  • remove parent module relationship

You can use following POM file as an example:

<?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>com.labs64.netlicensing</groupId>
    <artifactId>netlicensing-client-demo</artifactId>
    <version>2.3.8-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Labs64 :: NetLicensing :: Client :: Demo</name>

    <build>
        <finalName>${project.artifactId}</finalName>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>com.labs64.netlicensing.demo.NetLicensingClientDemo</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.labs64.netlicensing</groupId>
            <artifactId>netlicensing-client</artifactId>
            <version>2.3.8</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

</project>

4. Run demo

Execute following command:

$ mvn clean package
$ java -jar target/netlicensing-client-demo.jar

... execution log will be print in the stdout

Download prepackaged version from sonatype.org

1. Download artefacts

Download NetLicensing Demo packaged version ( netlicensing-client-demo-x.y.z.jar ) from https://oss.sonatype.org/content/repositories/releases/com/labs64/netlicensing/netlicensing-client-demo/ (use latest release version)

for example

$ wget https://oss.sonatype.org/content/repositories/releases/com/labs64/netlicensing/netlicensing-client-demo/2.3.8/netlicensing-client-demo-2.3.8.jar

2. Run demo

Navigate to the download folder and execute the following command:

$ java -jar netlicensing-client-demo-x.y.z.jar
  for instance
$ java -jar netlicensing-client-demo-2.3.8.jar

The Issue cannot be reproduced anymore => close