I have a project that was built in FlashDevelop. It is not an AIR application, but because we are using Starling we are compiling with the AIR sdk (v14). Running the project from FlashDevelop is working fine. I'm working on an ANT script that will eventually be used in Hudson. I am getting the following error when running the script:
BUILD FAILED
C:\project\client\build.xml:50: File does not exist: compiler.jar
at com.adobe.flash.compiler.ant.FlexTask.resolveClass(FlexTask.java:404)
at com.adobe.flash.compiler.ant.FlexTask.executeInProcess(FlexTask.java:
300)
at com.adobe.flash.compiler.ant.FlexTask.execute(FlexTask.java:260)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Here is the ANT script
<project name="Flex Ant Build Script" default="init">
<property environment="env"/>
<property name="FLEX_HOME" value="${env.FLEX_HOME}" />
<property name="AIRSDK_HOME" value="C:/Users/user/AppData/Local/FlashDevelop/Apps/ascsdk/14.0.0" />
<taskdef resource="flexTasks.tasks" classpath="${AIRSDK_HOME}/ant/lib/flexTasks.jar"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${env.ANT_HOME}/lib/ant-contrib-0.6.jar" />
</classpath>
</taskdef>
<target name="init">
<property name="INPUT_FILE_NAME" value="Main.as"/>
<property name="OUTPUT_FILE_NAME" value="Main"/>
<property name="OUTPUT_FILE_EXT" value="swf"/>
<property name="SRC_DIR" value="${basedir}/src"/>
<property name="OUTPUT_FOLDER" value="${basedir}/deploy"/>
<property name="DEBUG" value="false"/>
<property name="OPTIMIZE" value="true"/>
<property name="LOCALE" value="en_US"/>
<property name="STATIC_LINK" value="true"/>
<property name="STRICT" value="false"/>
<property name="WARNINGS" value="false"/>
</target>
<target name="clean" depends="init">
<delete includeemptydirs="true" verbose="true">
<fileset dir="${OUTPUT_FOLDER}" includes="**/*"/>
</delete>
</target>
<target name="compile" depends="init">
<echo>output = ${OUTPUT_FOLDER}/${OUTPUT_FILE_NAME}.${OUTPUT_FILE_EXT}</echo>
<echo>${AIRSDK_HOME}</echo>
<property name="AIR_LIB" value="C:/Users/user/AppData/Local/FlashDevelop/Apps/ascsdk/14.0.0/frameworks/libs/air"/>
<mxmlc file="${SRC_DIR}/${INPUT_FILE_NAME}"
output="${OUTPUT_FOLDER}/${OUTPUT_FILE_NAME}.${OUTPUT_FILE_EXT}"
debug="${DEBUG}"
optimize="${OPTIMIZE}"
locale="${LOCALE}"
static-rsls="${STATIC_LINK}"
strict="${STRICT}"
warnings="${WARNINGS}">
<library-path dir="${AIRSDK_HOME}" includes="asc-support.swc" append="true"/>
<library-path dir="${AIRSDK_HOME}" includes="core.swc" append="true"/>
<library-path dir="${AIR_LIB}" includes="aircore.swc" append="true"/>
<library-path dir="${AIR_LIB}" includes="applicationupdater.swc" append="true"/>
<library-path dir="${AIR_LIB}" includes="applicationupdater_ui.swc" append="true"/>
<library-path dir="${AIR_LIB}" includes="servicemonitor.swc" append="true"/>
</mxmlc>
</target>
I've dug through the FlexTasks.jar for both Flex and AIR and they are considerably different (as they should be). I've tried moving the FlexTasks.jar from each ant/lib to ${ANT_HOME}/lib and that didn't work (as I've read in other posts). And now I'm at a total impasse as I'm relatively new ANT. Any help would be greatly appreciated.
Thanks
The ant <mxmlc> task is poorly documented, behaves differently than the CLI version of mxmlc command, and the AIRSDK does not come with mxmlc.jar required for for the task.
I had given up on it, despite trying to do it several times.
Use the command line version, through ANT. I've used your property names in the code below.
<property name="mxmlc.jar" value="${AIRSDK_HOME}/lib/mxmlc-cli.jar"/>
<!-- ${FLEX_SDK}/lib/mxmlc.jar is not used, has issues with AIR related projects -->
<!-- <mxmlc> task is not used, poorly documented and behaves differently than cli -->
<!-- also, AIRSDK does not come with mxmlc.jar required for <mxmlc> task -->
<!-- Prepare command line -->
<property name="argline_compileBuildType"
value="-debug=${DEBUG} -optimize=${OPTIMIZE}"/>
<property name="argline_compileConfig"
value="+flexlib='${AIRSDK_HOME}/frameworks'"/>
<property name="argline_compileFiles"
value="-output=${OUTPUT_FOLDER}/${OUTPUT_FILE_NAME}.${OUTPUT_FILE_EXT} ${SRC_DIR}/${INPUT_FILE_NAME}"/>
<property name="argline_compileLibPath"
value="-library-path+=${AIRSDK_HOME}/asc-support.swc -library-path+=${AIR_LIB}/aircore.swc "/>
<!-- Show command line arguments and execute -->
<echo message="Executing: ${argline_compileBuildType} ${argline_compileConfig} ${argline_compileFiles} ${argline_compileLibPath}"/>
<java jar="${mxmlc.jar}" fork="true" failonerror="true">
<arg line="${argline_compileBuildType}"/>
<arg line="${argline_compileConfig}"/>
<arg line="${argline_compileFiles}"/>
<arg line="${argline_compileLibPath}"/>
</java>
Refer to the following reference for more command line options, for things such as your ${LOCALE} and ${STATIC_LINK}
I am having a difficulty getting the following Apache Ant script to work. The idea is to copy property values from properties with a certain prefix to properties without the prefix.
<project name="scp.result.files">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<property name="prop.a.sub1" value="a" />
<property name="prop.b.extra2" value="b" />
<property name="prop.c.foo" value="c" />
<property name="prop.d.foo" value="not selected" />
<target name="prep-props">
<!-- Select all interesting properties. -->
<propertyselector property="prop.list"
delimiter=","
match="prop\.(a|b|c)\..+"
casesensitive="false"
override="true" />
<echo message="matched properties: ${prop.list}" />
<!-- For each selected property, set a property without the "prop." prefix. -->
<for param="prop" list="${prop.list}" delimiter="," trim="true">
<propertyregex property="dest.prop"
input="#{prop}"
regex="prop\.((a|b|c)\..+)"
select="\1"
overrride="true" />
<propertycopy name="${dest.prop}"
from="prop.${dest.prop}"
override="true" />
<propertycopy name="_pval" from="${dest.prop}" override="true" />
<echo message="${dest.prop} is ${_pval}" />
</for>
</target>
</project>
Unfortunately, the above script produces the following error for me.
BUILD FAILED
C:\test.xml:19: Invalid type class net.sf.antcontrib.property.RegexTask used in For task, it does not have a public iterator method
at net.sf.antcontrib.logic.ForTask$ReflectIterator.<init>(ForTask.java:450)
at net.sf.antcontrib.logic.ForTask.add(ForTask.java:411)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.IntrospectionHelper$13.create(IntrospectionHelper.java:1552)
at org.apache.tools.ant.IntrospectionHelper$Creator.create(IntrospectionHelper.java:1329)
at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:574)
at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:358)
at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:204)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Is it possible to fix this? Is there any other way of iterating over the selected properties list and getting the un-prefixed properties set?
The list of tasks to execute for each iteration of for needs to be placed inside a sequential element, otherwise the propertyregex will be considered as a "list" the for task will iterate on. Also the propertyregex uses regexp instead of regex (checking its documentation).
<for param="prop" list="${prop.list}" delimiter="," trim="true">
<sequential>
<propertyregex property="dest.prop"
input="#{prop}"
regexp="prop\.((a|b|c)\..+)"
select="\1"
overrride="true" />
<propertycopy name="${dest.prop}"
from="prop.${dest.prop}"
override="true" />
<propertycopy name="_pval" from="${dest.prop}" override="true" />
<echo message="${dest.prop} is ${_pval}" />
</sequential>
</for>
I'm looking to introduce Jbehave in my project, and I am preparing a simple POC.
Using: jbehave 3.9.3, ant 1.9.2, IDE eclipse kepler.
I can successfully run the tests from within Eclipse (I've also annotated my test class with #RunWith(JUnitReportingRunner.class) ).
I have, however, some issues when I try running the same via ant.
this is the ant file I'm using:
<property name="src.dir" value="${basedir}/bdd/jbtest"/>
<property name="jbehave.version" value="3.9.3"/>
<target name="clean">
<delete dir="target" />
</target>
<target name="setup">
<artifact:dependencies filesetId="dependency.fileset" useScope="test">
<dependency groupId="org.jbehave" artifactId="jbehave-ant" version="${jbehave.version}"/>
<dependency groupId="org.jbehave" artifactId="jbehave-core" version="${jbehave.version}" classifier="resources" type="zip"/>
<dependency groupId="org.jbehave.site" artifactId="jbehave-site-resources" version="3.1.1" type="zip"/>
</artifact:dependencies>
<mkdir dir="target" />
<mkdir dir="target/classes" />
<mkdir dir="target/lib" />
<copy todir="target/lib">
<fileset refid="dependency.fileset" />
<mapper type="flatten" />
</copy>
<!-- copy todir="${src.dir}">
<fileset dir="../core/src/main/java">
</fileset>
</copy> -->
<copy todir="target/classes">
<fileset dir="${src.dir}">
<include name="**/*.story" />
<include name="**/*.properties" />
<include name="**/*.xml" />
</fileset>
</copy>
<path id="story.classpath">
<fileset dir="${basedir}/lib" includes="**/*.jar" />
<pathelement location="${basedir}/bin" />
</path>
<classloader classpathref="story.classpath" />
<pathconvert targetos="unix" property="story.classpath.unix" refid="story.classpath">
</pathconvert>
<echo>Using classpath: ${story.classpath.unix}</echo>
</target>
<target name="compile" depends="setup">
<javac includeantruntime="false" srcdir="${src.dir}" destdir="bin" debug="on" debuglevel="lines,source" includes="**/*.java,**/*.xml">
<classpath refid="story.classpath" />
</javac>
</target>
<target name="reports-resources" depends="setup">
<unzip src="${org.jbehave:jbehave-core:zip:resources}" dest="${basedir}/target/jbehave/view/" />
<unzip src="${org.jbehave.site:jbehave-site-resources:zip}" dest="${basedir}/target/jbehave/view/" />
</target>
<target name="run-stories-as-embeddables" depends="compile, reports-resources">
<taskdef name="runStoriesAsEmbeddables" classname="org.jbehave.ant.RunStoriesAsEmbeddables" classpathref="story.classpath" />
<runStoriesAsEmbeddables sourceDirectory="${src.dir}" includes="**/Myjb.java" excludes="**/examples*" batch="false" ignoreFailureInStories="true" ignoreFailureInView="true" generateViewAfterStories="true"
systemproperties="java.awt.headless=true,project.dir=${basedir}" />
</target>
<target name="run-stories-as-paths" depends="compile, reports-resources" >
<taskdef name="runStoriesAsPaths" classname="org.jbehave.ant.RunStoriesAsPaths" classpathref="story.classpath" />
<runStoriesAsPaths sourceDirectory="${src.dir}"
includes="**/*.story" batch="false" ignoreFailureInStories="true" ignoreFailureInView="true" generateViewAfterStories="true"
systemproperties="java.awt.headless=true,project.dir=${basedir}"
>
</runStoriesAsPaths>
</target>
<target name="stepdoc" depends="compile">
<taskdef name="reportStepdocs" classname="org.jbehave.ant.ReportStepdocs" classpathref="story.classpath" />
<reportStepdocs embedderClass="org.jbehave.examples.core.CoreEmbedder" />
<taskdef name="reportRenderer" classname="org.jbehave.ant.ReportRendererTask" classpathref="story.classpath" />
<reportRenderer outputDirectory="${basedir}/target/jbehave"
formats="txt,html" templateProperties="defaultFormats=stats"
ignoreFailure="true"/>
</target>
<target name="build" depends="run-stories-as-paths,stepdoc" />
</project>
issue #1: I can't specify the format
run-stories-as-paths:
[runStoriesAsPaths] Running stories as paths using embedder Embedder[storyMapper=StoryMapper,storyRunner=StoryRunner,embedderMonitor=AntEmbedderMonitor,classLoader=EmbedderClassLoader[urls=[],parent=java.net.URLClassLoader#1a8fa0f0],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,failOnStoryTimeout=false,threads=1]],embedderFailureStrategy=<null>,configuration=org.jbehave.core.configuration.MostUsefulConfiguration#5556d74f,candidateSteps=<null>,stepsFactory=<null>,metaFilters=<null>,systemProperties={java.awt.headless=true, project.dir=D:danielewsjbtest},executorService=<null>,executorServiceCreated=false,storyManager=<null>]
[runStoriesAsPaths] Found story paths: [Example.story, Sample.story]
[runStoriesAsPaths] Processing system properties {java.awt.headless=true, project.dir=D:danielewsjbtest}
[runStoriesAsPaths] System property 'java.awt.headless' set to 'true'
[runStoriesAsPaths] System property 'project.dir' set to 'D:danielewsjbtest'
[runStoriesAsPaths] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,failOnStoryTimeout=false,threads=1]]
[runStoriesAsPaths] Generating reports view to 'D:\daniele\ws\jbtest\target\jbehave' using formats '[]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports-with-totals.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
[runStoriesAsPaths] Reports view generated with 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)
I did not find a way to pass the format as I'm doing in the java class and that get's ignored, so it does not generate any report.
issue #2 story finding exception
when I run
ant -f jb_ant.xml -lib lib run-stories-as-paths
just after the output shown above, I get an exception
BUILD FAILED
D:\daniele\ws\jbtest\jb_ant.xml:74: org.jbehave.core.io.StoryResourceNotFound: Story path 'Example.story' not found by class loader EmbedderClassLoader[urls=[],parent=java.net.URLClassLoader#1a8fa0f0]
at org.jbehave.core.io.LoadFromClasspath.resourceAsStream(LoadFromClasspath.java:44)
at org.jbehave.core.io.LoadFromClasspath.loadResourceAsText(LoadFromClasspath.java:29)
at org.jbehave.core.io.LoadFromClasspath.loadStoryAsText(LoadFromClasspath.java:38)
at org.jbehave.core.embedder.StoryRunner.storyOfPath(StoryRunner.java:192)
at org.jbehave.core.embedder.StoryManager.storyOfPath(StoryManager.java:49)
at org.jbehave.core.embedder.StoryManager.runningStoriesAsPaths(StoryManager.java:101)
at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:78)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:203)
at org.jbehave.ant.RunStoriesAsPaths.execute(RunStoriesAsPaths.java:16)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
which is puzzling me because jbehave had just listed the found the story while executing the task.
I can post the both the Java classes and stories if this may help diagnose the problem.
Any ideas what am I doing wrong?
After a while, I found an answer to these issues:
the org.jbehave.core.io.StoryResourceNotFound exception was resolved by implementing a StoryFinder Class (code below)
to generate the reports, I had to implement an Embedder class (code below) and specify the formats there (apparently there is no way to pass this directly to the Ant tasks.
Hope this helps anyone else with similar problems.
StoryFinder
package jbtest;
import org.jbehave.core.io.StoryFinder;
import java.util.*;
public class MyStoryFinder extends StoryFinder {
#Override
protected List<String> scan(String basedir, List<String> includes,
List<String> excludes) {
//List<String> defaultStories = super.scan(basedir, includes, excludes);
//String myStories = System.getProperty("com.sarang.stories");
return Arrays.asList("jbtest/Example.story,jbtest/Sample.story".split(","));
}
}
Embedder
package jbtest;
import java.text.SimpleDateFormat;
import java.util.Properties;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser;
import org.jbehave.core.reporters.CrossReference;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.ParameterConverters;
import org.jbehave.core.steps.SilentStepMonitor;
public class MyEmbedder extends Embedder {
#Override
public EmbedderControls embedderControls() {
return new EmbedderControls().doIgnoreFailureInStories(true).doIgnoreFailureInView(true);
}
#Override
public Configuration configuration() {
Class<? extends MyEmbedder> embedderClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
return new MostUsefulConfiguration()
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
.withViewResources(viewResources).withFormats(Format.CONSOLE, Format.HTML, Format.XML)
.withFailureTrace(true)
) ;
}
#Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new ExampleSteps(), new SampleSteps());
}
}
Then I modified the Ant task as follows:
<target name="run-stories-as-paths" depends="compile, reports-resources" >
<taskdef name="runStoriesAsPaths" classname="org.jbehave.ant.RunStoriesAsPaths" classpathref="story.classpath" />
<runStoriesAsPaths
sourceDirectory="${src.dir}"
includes="**/*.story"
ignoreFailureInStories="true"
ignoreFailureInView="true"
generateViewAfterStories="true"
storyfinderclass="jbtest.MyStoryFinder"
verbosefailures="true"
embedderclass="jbtest.MyEmbedder"
>
</runStoriesAsPaths>
</target>
I want to download an XML file from a Web site using WSO2 ESB. Assume that the URL is static for the sake of simplicity.
I have tried VFS both as a proxy service and an individual sequence without success, and couldn't find any relevant material on the Internet.
Here is the sequence XML:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="download">
<in>
<log level="headers">
<property name="?" value="[download] in: started"/>
</log>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="transport.vfs.ContentType" value="text/xml" scope="transport" type="STRING"/>
<property name="transport.vfs.FileURI" value="http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-2013.xml" scope="transport" type="STRING"/>
<log level="headers">
<property name="?" value="[download] in: sending over vfs"/>
</log>
<send>
<endpoint>
<address uri="http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-2013.xml"/>
</endpoint>
</send>
<log level="headers">
<property name="?" value="[download] in: ended"/>
</log>
</in>
<out>
<log level="headers">
<property name="?" value="[download] out: started"/>
</log>
<send/>
<log level="headers">
<property name="?" value="[download] out: ended"/>
</log>
</out>
</sequence>
So, how to download a large file over HTTP with WSO2 ESB?
I have a similar problem, and by the moment I've solved it with an API and this code:
<api xmlns="http://ws.apache.org/ns/synapse" name="EcoRest" context="/services/ecorest">
<resource methods="GET" uri-template="/{idFile}">
<inSequence>
<send>
<endpoint>
<http method="get" uri-template="http://slx00012001:8888/repositoryfiles/{uri.var.idFile}">
<suspendOnFailure>
<errorCodes>101500,101510,101001,101000</errorCodes>
<initialDuration>10</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>10</maximumDuration>
</suspendOnFailure>
</http>
</endpoint>
</send>
<property name="enableSwA" value="true" scope="axis2"></property>
</inSequence>
<faultSequence>
<log level="custom">
<property name="FAULT GETTING FILE" expression="get-property('uri.var.idFile')"></property>
</log>
<payloadFactory media-type="json">
<format> {"descError":"$1", "error": "true"} </format>
<args>
<arg evaluator="json" expression="$.descError"></arg>
</args>
</payloadFactory>
<property name="HTTP_SC" value="500" scope="axis2" type="STRING"></property>
<respond></respond>
</faultSequence>
</resource>
</api>
This API works perfectly and make a throught-pass with the files. But if I send an id_file doesn't exist, the backend service return an http 400 with a json-message, the process go into the faultsequence, but the payloadFactory in the faultsequence doesn't work, and I don't know why :(
Have a go with this configuration:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="download" transports="https,http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="ClientApiNonBlocking" value="true" scope="axis2" action="remove"/>
<send>
<endpoint>
<address uri="vfs:file://home/secondary/file.xml"/>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.vfs.Streaming">true</parameter>
<parameter name="transport.vfs.FileURI">http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-2013.xml</parameter>
<parameter name="transport.vfs.Locking">disable</parameter>
<description></description>
</proxy>
You can initiate the download using:
curl -v http://localhost:8280/services/download
You can find out more about the VFS Transport specific parameters here: http://docs.wso2.org/wiki/display/ESB460/VFS+Transport. You can also find another VFS example here: http://docs.wso2.org/wiki/pages/viewpage.action?pageId=16846489. Hope this helps.
I'm getting troubles trying to use
<dirsets>
in my junit ant.
This is the snippet of the classpath.
<target name="myTests" >
<junit haltonerror="true" haltonfailure="true" fork="true">
<classpath>
<dirset dir="/my/absolute/root/path/where/I/keep/compiled/classes">
<include name="com/mycompany/mytests"/>
</dirset>
<pathelement location="my/path/to/jars/myjar1.jar" />
<pathelement location="my/path/to/jars/myjar2.jar" />
<!-- and so on -->
</classpath>
<test name="com.mycompany.mytests.MyFirstTest"
outfile="${dir.report.test}/report_MyFirstTest">
<formatter type="xml" />
</test>
</junit>
</target>
when I launch the test, after having successfully compiled all the code, ant complains:
java.lang.ClassNotFoundException: com.mycompany.mytests.MyFirstTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
I tried with absolute, relative paths and it never works. My classpath consists on many jars specified with many and that that is never recognized.
Where is my fault?
thanks
I former times when I used ant I used the nested <classpath> element and specified the classpath with the path-like structure - like this:
<path id="project.test.classpath">
<pathelement location="/my/absolute/root/path/where/I/keep/compiled/classes" />
<fileset dir="/my/path/to/jars">
<include name="**/*.jar" />
</fileset>
</path>
<target name="myTests">
<junit haltonerror="true" haltonfailure="true" fork="true">
<classpath refid="project.test.classpath" />
<test name="com.mycompany.mytests.MyFirstTest" outfile="${dir.report.test}/report_MyFirstTest">
<formatter type="xml" />
</test>
</junit>
</target>
Maybe that fit's also for you.