plaidshirt
plaidshirt

Reputation: 5671

log4j class not found in generated jar

I generate jar file with maven-assembly-plugin plugin. I use java -jar to execute jar. I got error message:

log4j: WARN JmDNS or serviceInfo not found

I tried to use path to jar in -classpath, but got same error.

Plugin configuration:

    <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>

Upvotes: 0

Views: 571

Answers (1)

GhostCat
GhostCat

Reputation: 140457

Most likely, this boils down to:

  • Your maven build does not include dependent artefacts into your JAR file. In other words: the JAR you create does not include the logj4 JARs. You can change that with your maven config, see here for details.
  • As your JAR doesn't contain the dependencies, all JARs you depend on must be in your classpath. Meaning: when you run your new JAR on the command line, all elements that might be required for running it must be present on the classpath.

Upvotes: 1

Related Questions