We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PHP/JavaBridge and java.lang.ClassNotFound (Unresolved external reference error)

I am currently evaluating Aspose Words for Java with a view to using it on Linux via PHP and JavaBridge. Installation of JavaBridge and Tomcat5 went smoothly. However, trying to run the example Hello World PHP code in the documentation is giving me the following error and I am now completely stumped. PLEASE HELP!

**Fatal error**: Uncaught [[o:Exception]:"java.lang.Exception:
CreateInstance failed: new com.aspose.words.Document. Cause:
java.lang.ClassNotFoundException: Unresolved external reference:
java.lang.NoClassDefFoundError: sun.nio.cs.ThreadLocalCoders. – Unable
to call constructor, see the README section "Java platform issues" for
details. VM: 1.4.2@<http://gcc.gnu.org/java/>" at:
#-4 php.java.bridge.Request.handleRequest(Request.java:447)
#0 <http://localhost:8080/JavaBridge/java/Java.inc(300):>
java\_ThrowExceptionProxyFactory->getProxy(1, NULL, ‘Unresolved
exte…’, false)
#1 <http://localhost:8080/JavaBridge/java/Java.inc(454):>
#2 <http://localhost:8080/JavaBridge/java/Java.inc(457):>
#3 <http://localhost:8080/JavaBridge/java/Java.inc(639):>
#4 <http://localhost:8080/JavaBridge/java/J> in [**http://localhost:8080/JavaBridge/java/Java.inc**](http://localhost:8080/JavaBridge/java/Java.inc) on line **263**
$doc = new Java(“com.aspose.words.Document”);
$builder = new Java(“com.aspose.words.DocumentBuilder”);
$builder->write(“Hello world!”);


Thanks for your inquiry. It is hard to tell you why this occurs. Have you tried to put lib folder from Aspose.Words archive to the root folder of you PHP project and use the following code?

// Create a Document object
$doc = new Java("com.aspose.words.Document");
// Create a DocumentBuilder
$builder = new Java("com.aspose.words.DocumentBuilder");
// Set the document
// Write "Hello world!" in word document
$builder->write("Hello world!");
// Save created document

Best regards.

Yes, I’ve tried this and a million other things to try and solve it.

I really want this to work so I can purchase a license. So please, if you or anyone else has any ideas!? I did notice it comes up in the forum that someone else had this issue - but I can’t seem to see if he found a solution.


Thanks for your request. I think there is something wrong with PHP/Java Bridge.

Also you can create some simple class in java, compile it in jar and try to call it from your php code. If this will not work then problem is in your environment.

Best regards.