drmacro / wordinator

Generate high-quality DOCX files using a simplified XML format (simple word processing XML).
Apache License 2.0
38 stars 8 forks source link

Errors log4j running form command line #17

Closed mattimatti closed 5 years ago

mattimatti commented 5 years ago

Hello I tried to build run wordinator in my ubuntu18, managed to build and run the jar from command line.

The output shows something related to the LogManager.. am i missing something?

thank you in advance,

$ java -jar wordinator.jar -i html/sample_web_page.html -o out -x xsl/html2docx/html2docx.xsl -t docx/Test_Template.dotx
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
+ 2019-12-02 18:37:23,047 [INFO ] Input document or directory='html/sample_web_page.html'
+ 2019-12-02 18:37:23,049 [INFO ] Output directory           ='out'
+ 2019-12-02 18:37:23,049 [INFO ] DOTX template              ='docx/Test_Template.dotx'
+ 2019-12-02 18:37:23,050 [INFO ] XSLT template              ='xsl/html2docx/html2docx.xsl'
+ 2019-12-02 18:37:23,050 [INFO ] Chunk level                ='root'
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.wordinator.xml2docx.MakeDocx.transformXml(MakeDocx.java:212)
    at org.wordinator.xml2docx.MakeDocx.handleCommandLine(MakeDocx.java:168)
    at org.wordinator.xml2docx.MakeDocx.main(MakeDocx.java:69)
Caused by: java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.
    at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:555)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:580)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:567)
    at org.wordinator.xml2docx.generator.DocxGeneratingOutputUriResolver.<clinit>(DocxGeneratingOutputUriResolver.java:27)
    ... 3 more
drmacro commented 5 years ago

I just tried running that command line under macOS and it worked without error, so not sure what the issue on Ubuntu might be. I don't have quick access to an Ubuntu environment so I can't quickly test it.

Can you do "java -v" and post it here?

mattimatti commented 5 years ago

Hello, thanks for replying, here is my version. ( i'm very poor in java just understand the coding, no libs no tools)

$ java --version
openjdk 11.0.4 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)

Tried to add plugin to maven pom.xml as per this post:

https://danieljamesscott.org/all-articles/9-articles/37-missing-classes-when-running-shaded-jars-with-java-9.html

no luck..

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>org.wordinator.xml2docx.MakeDocx</mainClass>
                                <manifestEntries>
                                    <Multi-Release>true</Multi-Release>
                                </manifestEntries>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Tried also to add dependency as per log4j2 migration guides.. no luck

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.11.1</version>
    </dependency>
mattimatti commented 5 years ago

the problem is related with running the jar using java 11. Running with older version is the option .

/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -jar ...

Not elegant but works