I’m trying to use Aspose.Words within a java web application but it is not finding the license file Aspose.Words.lic.
I have followed the licensing code examples in the Aspose help and have put my Aspose.Words.lic file into the same dir as my Aspose.Words.jdk15.jar, i.e. the WEB-INF/lib directory of my web application.
If I use no path in the call to license.setLicense(“Aspose.Words.lic”) then it fails. If I put in an absolute path, then it works fine. But I can’t use an absolute path because I don’t know the location the app will be installed in.
Here’s my code:
com.aspose.words.License license = new com.aspose.words.License();
try {
log.debug("Applying license for Aspose.Words");
license.setLicense("Aspose.Words.lic");
log.debug("Successfully applied license for Aspose.Words");
}
catch (Exception e) {
log.error("There was an error applying the license for Aspose.Words: " + e);
}
…
…
Document doc = new Document(… … … );
The exception code is always hit.
After some more investigation using the SysInternals File Monitor on Windows 2000, the Aspose.Words is firstly looking in the current directory - which is the main directory of Tomcat, and this fails because the license is below that, within my web application.
Secondly, Aspose.Words checks the WEB-INF/lib directory - but if the path contains a space, this space appears to be translated to a %20 by Aspose.Words (i.e. C:\Program%20Files…) which fails with a Path Not Found error.
I’ve had this problem on both Windows 2000 Pro and Mandriva Linux 2007.1 using both Jetty and Tomcat as servlet containers. I’m using Sun Java 5 and 6.
Do you have any suggestions?
Thanks,
Paul