Hi,

 

I need to call my own Java application from MarkLogic. Obviously, MLJAM
looked like the way to go, so I installed and tested the MLJAM system (using
Tomcat because I could not get Jetty to work), including testing that the
FOP example worked, so I know that everything is working OK with the JAR
files that came with the package.  The problem came when trying to add my
own JAR file and refer to the class within it from MarkLogic. 

 

I started by created a very simple test Java application (it just converts a
string to upper-case):

 

    package neil.test;

 

    final public class UpperCase {

 

    String _TheString = "";

 

    public UpperCase(String TheString) {  _TheString =
TheString.toUpperCase(); }

 

    public String GetUpperCase() {  return _TheString;  }

    }

 

I compiled this then created a JAR file as follows:

 

    \jdk160\bin\jar cvf MyJar.jar neil/

 

I tested that the JAR worked OK by writing another Java application that
used it to convert strings to upper-case.

 

I then put the JAR file in the same location as the other MLJAM JARs:

 

    D:\Tomcat60\webapps\mljam\WEB-INF\lib\UpperCase.jar

 

Finally, I stopped and re-started Tomcat, then tried the following code from
MarkLogic:

 

    jam:eval-get('{

      import neil.test.UpperCase;

      UpperCase UC = new UpperCase();

      String U = "hello: " + UC.GetUpperCase("Testing Testing"); 

      return U;    

    }')

 

But I got the following error message:

 

    xdmp:eval("error('bsh.EvalError: Sourced file: inline evaluation of: ``{
...") -- bsh.EvalError: 
    Sourced file: inline evaluation of: ``{ import neil.test.UpperCase;
UpperCase XX = new UpperCase(); . . . '' : 
    Typed variable declaration : Constructor error: Can't find default
constructor for: class neil.test.UpperCase  on line 1,

 

I know that the JAR file is being recognised, because I get a different
error if the JAR is not present.

 

Can anyone help me to understand what I need to do to get this simple
example working?  Am I failing to put something in the JAR file that is
needed?

 

Thanks.

 

Neil.

 

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to