Pregunta

To help solve another problem I have, I'm testing the following code in the postGenerationProcess event of the POI Word widget:

var jce:writeXWPFDocument = new writeXWPFDocument();
var newString3 = jce.doSomething3(xwpfdocument);
print("newString3 = " + newString3);

doSomething3 is defined in a Java class contained in the .nsf.

public class writeXWPFDocument {

public String doSomething3(XWPFDocument xwpfdocument) {
    return "DO SOMETHING - xwpfdocument";
}}

When I run this code, I get the error:

Java method 'doSomething3(org.apache.poi.xwpf.usermodel.XWPFDocument)' 
on java class 'AZGPackage.writeXWPFDocument' not found

What could be causing this error? @Knut Hermann - this is a test which relates to the other problem you have been helping me with.

¿Fue útil?

Solución

Edit to make the correct answer easier to find:

I have used poi in a few applications. I've encountered similar problems twice: First, usually when I accidentally import a class with the same name from the wrong package (like lotus.local.domino.Database instead of lotus.domino.Database). The other time I encountered this (and the only time the package name was identical) was when I had poi in a plug-in that I had added to the build path and also had it installed by a poi extension library I had built. If you can't cast an object as itself, there is an issue with the ClassLoader, and I don't know what would cause that other than a class being listed twice.

Otros consejos

SSJS seems to pass a different object type to the function. Try to change the class of the parameter to Object and for testing return the class name.

In a production code you could check with instanceof if the parameter has the right data type.

In General: consider using a facade pattern, so you keep your complex Java classes away from SSJS

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top