User Macro Undefined

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi mashers,

I am just trying out the macro function within a couple of mashups, however I keep getting an undefined macro error for anything I have supposedly included in the global.emml-macro file.

Here's the error message:

<Error execution Mashup Script : Macro definition not found : macro:myTestMacro : EMML Line # : 9>
java.lang.RuntimeException: Macro definition not found : macro:myTestMacro : EMML Line # : 9

I've checked the documentation and have made sure that I have added the emml-macro file to the WEB-INF\classes directory and correctly added the <include> statement in the global.emml-macros file. I've even restarted the server several times.

Here's the test emml:

<mashup xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.jackbe.com/2008-03-01/EMMLSchema/ ../src/schemas/EMMLSpec.xsd"
      xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema"
      xmlns:macro="http://www.jackbe.com/2008-03-01/EMMLMacro"
      name = "MacroTest">
      <output name="result" type="string"></output>
     <macro:myTestMacro mystring="test this sucker" outputvariable="$result" />
 </mashup>

the macro file:

<macros xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.jackbe.com/2008-03-01/EMMLSchema/ ../src/schemas/EMMLSpec.xsd"
      xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema"
      name = "ahcmashup">
      <macro name="computeBasicAuth">
        <input name="user" type="string"/>
        <input name="password" type="string"/>
        <output name="basicauth" type="string"/>
        <presto-meta name="macrotype">system</presto-meta>
        <script type="text/javascript" >
               <![CDATA[
               var userPassword = new Packages.java.lang.String(user + ":" + password);
               basicauth = "Basic " + Packages.sun.misc.BASE64Encoder().encode(userPassword.getBytes());
               ]]>
        </script>
     </macro>
      <macro name="myTestMacro">
         <input name="mystring" type="string" />
         <output name="myoutput" type="string" />
         <assign outputvariable="myoutput" fromexpr="concat('Got it: ',$mystring)" />
     </macro>
 </macros>

and the entry in the global.emml.macros file:

<macros xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema"
        xmlns:myfunc="java:com.jackbe.jbp.jems.client.EMMLPrestoFunctions">
    <!-- AHC Business macro libraries -->
    <include file="ahcmashup.emml-macros" />

...

I have checked that all the files are in the correct Presto directories.

Have I missed something?

Cheers, Innes (NZ)

 

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 14 hours 26 min ago. Offline
Joined: 08/29/2008
Points: 34

Innes,

Are you debugging this from Mashup Studio? If so, you also have to add your mashup script into the Launch config for the mashup in Mashup Studio. Look in Eclipse help for the Mashup Studio help -- there is a topic about Launch configurations that should help.

 

Sara, technical writer/jackbe

 

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi Sara,

Thanks for that. Yes you were right, I was trying this in the Mashup Studio. I had tried adding the emml-macro file containing the macro to the Server Classpath in the Debug Configuration, but what I didn't realise was that I actually had to add the Presto Server WEB-INF\Classes folder to the Server Classpath. I'd assumed that the Presto Server Classes directory would have been included automatically.

So by adding C:\Presto2.7.0\server\apache-tomcat-5.5.20\webapps\presto\WEB-INF\classes to the Server Classpath under the Debugs Configurations for the script I was debugging, it worked as I expected.

Cheers, Innes (NZ)