wooio / htmltopdf-java

An HTML to PDF conversion library written in Java, based on wkhtmltopdf.
MIT License
173 stars 97 forks source link

java.lang.IllegalArgumentException: name error throwing when running jar using java -jar myapp.jar but when running from intellij it works #36

Open sushiljic opened 4 years ago

sushiljic commented 4 years ago

I am stuck with strange problems.

after packing project in jar and running java -jar app.jar it is showing such error.

java.lang.IllegalArgumentException: name
        at java.base/jdk.internal.loader.URLClassPath$Loader.findResource(URLClassPath.java:600) ~[na:na]
        at java.base/jdk.internal.loader.URLClassPath.findResource(URLClassPath.java:291) ~[na:na]
        at java.base/java.net.URLClassLoader$2.run(URLClassLoader.java:655) ~[na:na]
        at java.base/java.net.URLClassLoader$2.run(URLClassLoader.java:653) ~[na:na]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
        at java.base/java.net.URLClassLoader.findResource(URLClassLoader.java:652) ~[na:na]
        at org.springframework.boot.loader.LaunchedURLClassLoader.findResource(LaunchedURLClassLoader.java:57) ~[core-0.0.1.jar:0.0.1]
        at java.base/java.lang.ClassLoader.getResource(ClassLoader.java:1400) ~[na:na]
        at com.sun.jna.Native.extractFromResourcePath(Native.java:1019) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:286) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at com.sun.jna.Library$Handler.<init>(Library.java:179) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at com.sun.jna.Native.loadLibrary(Native.java:569) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at com.sun.jna.Native.loadLibrary(Native.java:544) ~[jna-4.5.2.jar!/:4.5.2 (b0)]
        at io.woo.htmltopdf.wkhtmltopdf.WkHtmlToPdfLoader.load(WkHtmlToPdfLoader.java:39) ~[htmltopdf-1.0.8.jar!/:na]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]

but when running from intellij run error It is running very well.

Below is my pom.

 <dependency>
            <groupId>io.woo</groupId>
            <artifactId>htmltopdf</artifactId>
            <version>1.0.8</version>
            <scope>compile</scope>
        </dependency>

My code is

            boolean success = HtmlToPdf.create()
                    .object(HtmlToPdfObject.forHtml(processedHtml))
                    .convert(outputFile.getPath());
aiwandexiaoer commented 11 months ago

您好,后来解决了嘛,我现在也是这个问题