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:
#-6
php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException(JavaBridge.java:433)
#-5
php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:504)
#-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):>
java\_Arg->getResult(false)
#2 <http://localhost:8080/JavaBridge/java/Java.inc(457):>
java\_Client->getWrappedResult(false)
#3 <http://localhost:8080/JavaBridge/java/Java.inc(639):>
java\_Client->getInternalResult()
#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**
<?php
require_once(“http://localhost:8080/JavaBridge/java/Java.inc”);
java_require(“JavaBridge/WEB-INF/lib/Aspose.Words.jdk14.jar”);
$doc = new Java(“com.aspose.words.Document”);
$builder = new Java(“com.aspose.words.DocumentBuilder”);
$builder->setDocument($doc);
$builder->write(“Hello world!”);
$doc->save(“tmp/chris.doc”);
?>

Hi

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?

<?php 
require\_once("http://localhost:8080/JavaBridge/java/Java.inc"); 
java\_require("lib/Aspose.Words.jdk15.jar");
// Create a Document object
$doc = new Java("com.aspose.words.Document");
// Create a DocumentBuilder
$builder = new Java("com.aspose.words.DocumentBuilder");
// Set the document
$builder->setDocument($doc);
// Write "Hello world!" in word document
$builder->write("Hello world!");
// Save created document
$doc->save("tmp/out.doc");
?>

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.

Hi

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.