Announcement

Collapse
No announcement yet.

javascript with my java classes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • javascript with my java classes

    I am using Mirth 1.3.2. I want to use my own java class in the filter/transformer javascripts. I thought I had to place the jar with my classes in lib/custom and the javascript would pick it up. Is this the right way to do it? In the javascript I reference the class by its fully qualified name. I get this error:

    Code:
    ERROR 2007-03-09 07:40:48,250 [ab6510de-4b95-40a8-8c1e-14c4b10330f2_source_connector._fileEndpoint#696631786.receiver.1]
     org.mule.providers.jdbc.JdbcMessageDispatcher: Error at tranformerorg.mule.umo.transformer.TransformerException: Refere
    nceError: "com" is not defined. (00ebc23d-417d-496c-8f06-e6d93ac29d4a#3) (org.mozilla.javascript.EcmaError)
    ERROR 2007-03-09 07:40:48,359 [ab6510de-4b95-40a8-8c1e-14c4b10330f2_source_connector._fileEndpoint#696631786.receiver.1]
     org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in Exception Strategy for: ab6510de-4b95-40a8-8c1e-14
    c4b10330f2: org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type:
     com.webreach.mirth.model.MessageObject
    org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.webreac
    h.mirth.model.MessageObject
            at org.mule.routing.outbound.OutboundMessageRouter.route(OutboundMessageRouter.java:84)
            at org.mule.impl.model.DefaultMuleProxy.onCall(DefaultMuleProxy.java:247)
            at org.mule.impl.model.seda.SedaComponent.doSend(SedaComponent.java:209)
            at org.mule.impl.model.AbstractComponent.sendEvent(AbstractComponent.java:277)
            at org.mule.impl.MuleSession.sendEvent(MuleSession.java:201)
            at org.mule.routing.inbound.InboundMessageRouter.send(InboundMessageRouter.java:161)
            at org.mule.routing.inbound.InboundMessageRouter.route(InboundMessageRouter.java:128)
            at org.mule.providers.AbstractMessageReceiver$DefaultInternalMessageListener.onMessage(AbstractMessageReceiver.j
    ava:492)
            at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:271)
            at org.mule.providers.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:230)
            at org.mule.providers.file.FileMessageReceiver.processFile(FileMessageReceiver.java:183)
            at org.mule.providers.file.FileMessageReceiver.poll(FileMessageReceiver.java:111)
            at org.mule.providers.PollingMessageReceiver.run(PollingMessageReceiver.java:73)
            at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)
            at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    
            at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
            at java.lang.Thread.run(Unknown Source)
    Thanks for your help.

    --Aziz

  • #2
    Re: javascript with my java classes

    Please, could you post your JS code too ?

    Comment


    • #3
      Re: javascript with my java classes

      This is the code in one of the transformer steps. postMessage is a public static method. MessageSender is packaged in a jar in lib/custom.

      Code:
      var msg_txt = "Test: " + globalMap.get("PatientId");
      com.bhi.MirthUtils.MessageSender.postMessage(msg_txt);

      Comment


      • #4
        Re: javascript with my java classes

        Please try with:

        Code:
        var result=com.bhi.MirthUtils.MessageSender.postMessage(msg_txt);

        Comment


        • #5
          Re: javascript with my java classes

          I tried the var result = .... approach. That did not work.

          Any other ideas on what might be wrong?

          Comment


          • #6
            Re: javascript with my java classes

            I'm not 100%, but, pleas try:
            Code:
            importPackage(Packages.com.bhi.MirthUtils.MessageSender.postMessage);

            Comment


            • #7
              Re: javascript with my java classes

              you can also do

              Code:
                 var sender = new Packages.com.bhi.MirthUtils.MessageSender();
                 var result = sender.postMessage(msg_txt);
              We have not confirmed that the class loader for the custom lib folder will extend to the JS...it should (you can use DB drivers from the DB Conn in JS, and all db drivers are loaded from our custom class loader).

              Let me know if this works.
              Chris Lang

              Comment


              • #8
                Re: javascript with my java classes

                That worked! The parameter for importPackage should be the package name without the class name.

                Thank you very much for your help.

                Comment

                Working...
                X