2

I use ghost4j GhostScript to manage TIFF and PDF files in a webapp. I included Ghost4J into my project using Maven and installed Ghostscript into C:\Program Files\gs\... but after this I still get an error:

java.lang.UnsatisfiedLinkError: Unable to load library 'gsdll64'

To solve this, I must place the file gsdll64.dll in working directory (usually c:\eclipse) as proposed here.

Till here everything fine, but when I deploy the app in the integration environment (win7 and tomcat7) I get this exception:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary.

I installed Ghostscript into C:\Program Files\gs\... in the host and as in this discussion I wrapped code with try {} catch (Exception e) but does not seem to help.

Any idea where I should place the gsdll64.dll or how to solve the error?

Community
  • 1
  • 1
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109

1 Answers1

2

One solution is to add dll to %JAVA_HOME%/jre/bin as it is usually on the PATH.

Alternatively add the directory that contains the dll to PATH since on Windows, java.library.path is initialised from the PATH environment variable.

Check this thread on StackOverflow for reference.

For Tomcat 7, can copy gsdll64.dll to %TOMCAT_HOME%\bin directory or create setenv.bat under %TOMCAT_HOME%\bin directory with the following entry.

set PATH=%PATH%;C:\gs\gs9.18\bin

where C:\gs\gs9.18 is the installed Ghostscript folder. Check Apache Tomcat Native Library installation document on this.

Dukefirehawk
  • 476
  • 1
  • 3
  • 11
  • This answer makes sense, but actually I already tried both options without success... there is something basic I'm missing for sure... but I'm blind now... – Jordi Castilla Jan 19 '16 at 09:01
  • I downloaded Ghost4j source from github, running "mvn test" gets the UnsatisfiedLinkError error. After copying gsdll64.dll to %JAVA_HOME%/jre/bin, that error went away. My JAVA_HOME is set to "C:\Program Files\Java\jdk1.8.0_66" and has %JAVA_HOME%/bin added to the beginning of Path under System Variables.Could be that your java is running from "C:\Program Files\Java\jre1.8.0_66\bin" instead of "C:\Program Files\Java\jdk1.8.0_66\jre\bin". – Dukefirehawk Jan 19 '16 at 12:16
  • If you read my question, you will see I do this without problem in the development environment, but my problem is in the integration, where host and client machines are different (what should not affect...) and error is also different `NoClassDefFound`.... – Jordi Castilla Jan 19 '16 at 12:23
  • Somehow missed Tomcat7 part. Place gsdll64.dll under Tomcat/bin folder and it should be able to load properly. – Dukefirehawk Jan 19 '16 at 13:38