0

I have a LeanFT project, it is working properly, when I execute it from IDE. I generated a jar file with maven-assembly-plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <archive>
            <manifest>
                <mainClass>test.LeanFTest</mainClass>
            </manifest>
        </archive>
        <finalName>${project.artifactId}-fatjar-${project.version}</finalName>
        <appendAssemblyId>false</appendAssemblyId>
        <descriptors>
            <descriptor>src/main/assembly/leanft-assembly.xml</descriptor>
        </descriptors>
    </configuration>
</plugin>

When I try to execute it by TestExportTool(to generate XML file for ALM import) I get various error messages, like:

log4j: WARN JmDNS or serviceInfo not found

java.lang.UnsatisfiedLinkError: no NTEventLogAppender

java.lang.NoClassDefFoundError

I imported all the necessary classes, resolved these issues, but TestExportTool comes with exceptions again and again. I added these dependencies, reported by error messages, but these are not used by project, so not sure why it is asking for.

   <dependency>
        <groupId>org.jmdns</groupId>
        <artifactId>jmdns</artifactId>
        <version>3.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.25</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.11.0</version>
    </dependency>
    <dependency>
        <groupId>org.dblock.log4jna</groupId>
        <artifactId>log4jna-api</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>org.yaml</groupId>
        <artifactId>snakeyaml</artifactId>
        <version>1.21</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

leanft-assembly.xml file:

<id>fat-tests</id>
<formats>
    <format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <useProjectArtifact>true</useProjectArtifact>
        <unpack>true</unpack>
        <scope>test</scope>
    </dependencySet>
</dependencySets>
<fileSets>
    <fileSet>
        <directory>${project.build.directory}/test-classes</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>*.class</include>
        </includes>
        <useDefaultExcludes>true</useDefaultExcludes>
    </fileSet>
</fileSets>

Detailed stack trace of latest error message:

Hewlett-Packard Enterprise LeanFT Test Export Tool. [main] DEBUG javax.jmdns.impl.JmDNSImpl - JmDNS instance created 2018-07-06 11:17:21,741 Exception in thread "main" java.lang.NoClassDefFoundErr or: org/apache/tools/ant/taskdefs/LogOutputStream at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) 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 java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.hp.lft.testexporttool.internal.JarFileLoader.getPublicClassesFrom JarFile(JarFileLoader.java:48) at com.hp.lft.testexporttool.internal.TestsExporter.export(TestsExporter .java:26) at com.hp.lft.testexporttool.ExportTests.main(ExportTests.java:41) Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.taskdefs.LogOu tputStream at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source)

UPDATE 07.09.: I added all the dependencies, requested by TestExportTool. I get following message from Hewlett-Packard Enterprise LeanFT Test Export Tool:

[main] DEBUG javax.jmdns.impl.JmDNSImpl - JmDNS instance created 2018-07-09 13:25:17,419 bshpath.BshClassLoader

plaidshirt
  • 5,189
  • 19
  • 91
  • 181

3 Answers3

2

Sounds like the NTEventLogAppender.dll is not available on the PATH. More details on how and why Log4J might be using it here - it's available in the .zip download file.

However, this only applies to Log4J (v1.2) as opposed to Log4J 2 - it looks like this is what's wanted in those dependencies? For Log4J 2 the SLF4J binding should be org.apache.logging.log4j:log4j-slf4j-impl:2.11.0 (instead of org.slf4j:slf4j-log4j12:1.7.25).

df778899
  • 10,703
  • 1
  • 24
  • 36
  • I downloaded missing dll and put ut to PATH, but after that newer error messages are coming, asking for dependencies. – plaidshirt Jul 05 '18 at 20:49
1

By default maven does not include in the generated jar all the dependencies. It always assumes that those already exist in the target System. You have 2 possibilities:

  1. Paste those jar files to the Target Systems $classpath / libs folder
  2. Configure your maven project to export all dependencies as part of the jar (This will make your jar file explode)
  3. Not recommended: Copy the jar files to the lib\ext folder of your jre running your ALM System. These will be loaded into every application using this jre.
Bela Tamas Jozsa
  • 714
  • 5
  • 10
  • My plugin configuration seems really similar than configuration in your second option. I am not sure what to change to export dependencies properly. – plaidshirt Jul 05 '18 at 20:51
  • ` src/main/assembly/leanft-assembly.xml ` This is your config. You use the LeanFT Descriptor. The one mentioned in my link is a predefined one for creating jars with all dependencies when the target is package / install. Be careful with cahnging the descriptor file - do it only if you are sure about the changes. Maybe a more detailed stack trace or error messages? – Bela Tamas Jozsa Jul 05 '18 at 22:00
  • I added content of xml file and stack trace of current error message. – plaidshirt Jul 06 '18 at 09:24
  • 1
    `java.lang.ClassNotFoundException: org.apache.tools.ant.taskdefs.LogOu tputStream` - this is present [ant](https://mvnrepository.com/artifact/org.apache.ant/ant/1.8.2). I don't see that in your dependencies – Bela Tamas Jozsa Jul 06 '18 at 15:04
  • Yes, it isn't in my pom.xml, but it is not needed when I execute from IDE. If I include a dependency in my pom.xml I get error message, another one is missing. How could I determine list of all the needed dependencies? – plaidshirt Jul 08 '18 at 20:07
  • I added all the dependencies. I updated question with new error message. – plaidshirt Jul 09 '18 at 11:28
0

Problem caused by JAR generation plugin in IntelliJ IDEA. I exported same project to Eclipse and generated JAR file under File -> Export option and file is working fine when executed from ALM.

plaidshirt
  • 5,189
  • 19
  • 91
  • 181