ant target for junit fails to load spring context xml files - spring

When i run ant target for junit, following error occurs:
Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml] Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml] Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/esw-web-ctx.xml]
Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]
Offending resource: class path resource [esw-web-ctx.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/bgc/ecm/core/tools/exceptions/errorpagehandler-ctx.xml]; nested exception is java.net.UnknownHostException: www.springframework.org
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76).......
......
Ant target:
<target name="junit" depends="buildlocal">
<delete dir="${JUNIT_REPORT}" failonerror="false"/>
<mkdir dir="${BUILD_TEST_DIR}" />
<mkdir dir="${JUNIT_REPORT}" />
<echo message="Launching JUnit tests" />
<copy todir="${BUILD_TEST_DIR}/" overwrite="true">
<fileset dir="${COMP_TESTCONFIG_DIR}">
<exclude name="*.properties.template" />
<exclude name="*.xml.template" />
<exclude name="*.ccf.template" />
<exclude name="**/*.bak" />
<exclude name="**/*.keep" />
<exclude name="**/*.keep.*" />
<exclude name="**/*.contrib" />
<exclude name="**/*.java" />
<exclude name="**/*.class" />
<exclude name="**/*.contrib.*" />
</fileset>
</copy>
<junit printsummary="on" fork="off" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
<classpath>
<path refid="CLASSPATH_JUNIT"/>
</classpath>
<batchtest fork="off" todir="${BUILD_TEST_DIR}">
<fileset dir="${TEST_CLASSES_DIR}">
<include name="**/*Test.class" />
<include name="**/Test*.class" />
<!-- <exclude name="**/EswCacheInitializerTest.class" /> -->
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<echo message="Launching junitreport" />
<junitreport todir="${JUNIT_REPORT}">
<fileset dir="${BUILD_TEST_DIR}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${JUNIT_REPORT}"/>
</junitreport>
<delete dir="${BUILD_TEST_DIR}" failonerror="false"/>
<echo message="**** Junit report generated at the location: ${JUNIT_REPORT} ***"/>
<echo message="==============================================="/>
<echo message="****** JUNIT BUILD ENDS - CORE ****** "/>
<echo message="==============================================="/>
<fail if="junit.failure" message="Unit test(s) failed. See reports at: ${JUNIT_REPORT}"/>
</target>
<path id="CLASSPATH_JUNIT">
<path refid="LIB_JAVAC"/>
<pathelement location="${TEST_CLASSES_DIR}" />
<pathelement location="${BUILD_TEST_DIR}" />
<pathelement location="${APP_DIR}\bgc-esw-core\target\classes" />
<pathelement location="${APP_DIR}\bgc-esw-web\target\classes" />
<pathelement location="${APP_DIR}\bgc-esw-wicket-components\target\classes" />
<fileset dir="${BUILD_LIBS_HOME}">
<include name="*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-web\build" erroronmissingdir="false">
<include name="bgc-esw-*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-services\build" erroronmissingdir="false">
<include name="bgc-esw-service*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-core\build" erroronmissingdir="false">
<include name="bgc-esw-core*.jar" />
</fileset>
<fileset dir="${APP_DIR}\bgc-esw-wicket-components\build" erroronmissingdir="false">
<include name="bgc-esw-wicket-components*.jar" />
</fileset>
</path>

Check the XML namespaces definitions in that application context definition. It typically contains something like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
I bet that some of the spring XSD files are not in the jars on your classpath; all these should be locally on your system and not downloaded from web.

Related

change original payload with wso2 esb

I saved the following structure on a property du wso2:
<ELEMENT>
<ELEMENT_2>
<ELEMENT_3>
<ID> 173993 </ID>
</ELEMENT_3>
</ELEMENT_2>
</ELEMENT>
I want to bring TEMP only to children:
<TEMP>
<NAME>GEORGE</NAME>
<COGNOME>MENDEZ</COGNOME>
<BUSINESSNAME/>
<CHANNEL>X091</CHANNEL>
</TEMP>
I want to add them right after the <ELEMENT_2>
FINAL RESULTS:
<ELEMENT>
<ELEMENT_2>
<NAME>GEORGE</NAME>
<COGNOME>MENDEZ</COGNOME>
<BUSINESSNAME/>
<CHANNEL>X091</CHANNEL>
<ELEMENT_3>
<ID> 173993 </ID>
</ELEMENT_3>
</ELEMENT_2>
</ELEMENT>
Thanks
Can you check if your requirement is achieved with the following proxy configuration.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="enrichProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property name="initial_payload" scope="default">
<ELEMENT xmlns="">
<ELEMENT_2>
<ELEMENT_3>
<ID>173993</ID>
</ELEMENT_3>
</ELEMENT_2>
</ELEMENT>
</property>
<call>
<endpoint>
<http uri-template="http://run.mocky.io/v3/7c578a1d-5427-4325-9f00-4ad7bb80dd04"/>
</endpoint>
</call>
<log level="custom">
<property expression="$body//TEMP/*" name="******"/>
</log>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
Remove external tag with xpath wso2
update
Here I have enriched the second property (..) back to the body using a enrich mediator.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="enrichProxy"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property name="initial_payload" scope="default">
<ELEMENT xmlns="">
<ELEMENT_2>
<ELEMENT_3>
<ID>173993</ID>
</ELEMENT_3>
</ELEMENT_2>
</ELEMENT>
</property>
<property name="second_payload" scope="default">
<TEMP xmlns="">
<NAME>GEORGE</NAME>
<COGNOME>MENDEZ</COGNOME>
<BUSINESSNAME/>
<CHANNEL>X091</CHANNEL>
</TEMP>
</property>
<enrich>
<source clone="true" property="second_payload" type="property"/>
<target type="body"/>
</enrich>
<enrich>
<source clone="true" xpath="$body//TEMP/*"/>
<target action="child" xpath="$ctx:initial_payload//ELEMENT_2"/>
</enrich>
<log level="custom">
<property expression="$ctx:initial_payload" name="******"/>
</log>
<respond/>
</inSequence>
</target>
<description/>
</proxy>

NoSuchMethodError while using MockHttpServletRequest - JUnit

I am getting the following error when I am trying to instantiate a MockHttpServletRequest object like this: MockHttpServletRequest request = new MockHttpServletRequest();
java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createLinkedMapIfPossible(I)Ljava/util/Map;at org.springframework.mock.web.MockHttpServletRequest.(MockHttpServletRequest.java:107)
at org.springframework.mock.web.MockHttpServletRequest.(MockHttpServletRequest.java:187)
My maven code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>Servlet</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
</properties>
<dependencies>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-mock -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
</dependency>
</dependencies>
</project>
the iml file:
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
<sourceRoots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Java EE 6-Java EE 6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-mock:2.0.8" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1" level="project" />
</component>
</module>
My external libraries directories:
I have also added a Java Servlet jar:
I am using Intellij IDEA; thanks in advance.
M. Deinum response worked for me, replace spring-mock with spring-test, additionally take a look at the .iml file and make sure the spring-mock is gone, otherwise remove it manually and re-attempt to execute the test.
Credits to: M. Deinum

cxf rest multiple endpoints

I have generated the java classes from a wadl file with cxf. There are 3 resources definded an so 3 service classes with #PATH annotation are created. Now I want to publish them to the same url but I'm not sure how to achieve this.
Here are the snippets of the classes and wadl. The last part shows the beans.xml - At this point this is the only way I know how to publish the endpoints. Is there anothher way and how can I publish these 3 classes to the base url "/" and then they should match to the paths related to the annotations. Maybe a wrapper class for all but I'm not sure?
classes
#Path("status")
public class Status {
...
#Path("status/{id}")
public class StatusId {
...
#Path("counters")
public class Counters{
...
wadl
<resources base="http:localhost:8080/rest">
<resource path="status/{id}" id="status">
<method name="GET" id="getStatusById">
...
<resource path="status" id="status">
<method name="GET" id="getStatusByQueryParam">
...
</resource>
<resource path="counters" id="counters">
<method name="PUT" id="putCounters">
...
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<!-- do not use import statements if CXFServlet init parameters link to this beans.xml -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="statusService" address="/">
<jaxrs:serviceBeans>
<ref bean="status" />
</jaxrs:serviceBeans>
</jaxrs:server>
<!-- causes error
<jaxrs:server id="statusServiceId" address="/">
<jaxrs:serviceBeans>
<ref bean="statusId" />
</jaxrs:serviceBeans>
</jaxrs:server>
<jaxrs:server id="counterServiceId" address="/">
<jaxrs:serviceBeans>
<ref bean="counters" />
</jaxrs:serviceBeans>
</jaxrs:server>
-->
<bean id="status" class="package.Status"/>
<bean id="statusId" class="package.StatusId"/>
<bean id="counters" class="package.Counters"/>
</beans>
for geting multiple endpoints your
beans.xml should be looks like bellow
<jaxrs:server id="statusService" address="/">
<jaxrs:serviceBeans>
<ref bean="status" />
<ref bean="statusId" />
<ref bean="counters" />
</jaxrs:serviceBeans>
</jaxrs:server>

Why am I getting "HTTP Status 404 - Servlet <servlet name> is not available"

I am going through this Spring web MVC tutorial but am stuck at section 1.12 where I should be seeing a "Hello" page handled by my Controller, but instead get "HTTP Status 404 - Servlet is not available". I have looked at the other stackoverflow questions that have the same error, but none have helped.
Here are the relevant files:
/web/WEB-INF/web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<!--
The "Front Controller" (http://en.wikipedia.org/wiki/Front_Controller_pattern).
that dispatches requests to registered handlers (Controller implementations).
-->
<servlet>
<servlet-name>filth</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>filth</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
/web/WEB-INF/filth-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- the application context definition for the filth DispatcherServlet -->
<context:component-scan base-package="com.filth.controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/web/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
/web/view/hello.jsp:
<html>
<head><title>Hello :: Spring Application</title></head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings.</p>
</body>
</html>
/src/main/java/com/filth/controller/HelloController.java:
package com.filth.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* Controller for the "Hello" page
*/
#Controller
public class HelloController {
private static final Log LOGGER = LogFactory.getLog(HelloController.class);
#RequestMapping(value="/hello.html", method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
LOGGER.info("Returning hello view");
return new ModelAndView("hello");
}
}
/build.properties:
# Ant properties for building FiLTH
appserver.home=${env.WORKSPACE}/tomcat6
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
/build.xml:
<?xml version="1.0"?>
<project name="filth" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." default="usage">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement path="${build.lib.dir}/ant-contrib.jar"/>
</classpath>
</taskdef>
<taskdef name="ivy-configure" classname="org.apache.ivy.ant.IvyConfigure"/>
<taskdef name="ivy-resolve" classname="org.apache.ivy.ant.IvyResolve"/>
<taskdef name="ivy-retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/>
<taskdef name="ivy-deliver" classname="org.apache.ivy.ant.IvyDeliver"/>
<taskdef name="ivy-publish" classname="org.apache.ivy.ant.IvyPublish"/>
<target name="ivy-resolve">
<ivy:configure />
<ivy:resolve file="${ivy.dep.file}" conf="${ivy.configurations}" />
<ivy:retrieve pattern="${ivy.retrieve.pattern}" conf="${ivy.configurations}" />
<echo message="ivy.dep.file: ${ivy.dep.file}"/>
<echo message="ivy.configurations: ${ivy.configurations}"/>
<echo message="ivy.retrieve.pattern: ${ivy.retrieve.pattern}"/>
</target>
<property environment="env"/>
<property file="build.properties"/>
<property file="build.passwords.properties" />
<property name="src.dir" value="src/main/java"/>
<property name="test.dir" value="src/test"/>
<property name="web.dir" value="web/"/>
<property name="build.dir" value="target"/>
<property name="name" value="filth"/>
<property name="resources.dir" value="src/main/resources"/>
<path id="master-classpath">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"/>
</fileset>
<pathelement path="${resources.dir}"/>
<pathelement path="${build.dir}"/>
</path>
<target name="usage">
<echo message=""/>
<echo message="${name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="build --> Build the application"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message="install --> Install application in Tomcat"/>
<echo message="reload --> Reload application in Tomcat"/>
<echo message="start --> Start Tomcat application"/>
<echo message="stop --> Stop Tomcat application"/>
<echo message="list --> List Tomcat applications"/>
<echo message=""/>
</target>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="buildtests" description="Compile test tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" source="1.6" target="1.6" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"/>
<classpath refid="master-classpath"/>
</javac>
</target>
<target name="tests" depends="build, buildtests" description="Run tests">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Test.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}"/>
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"/>
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>
<!-- End Tomcat tasks -->
</project>
/ivy.xml:
<ivy-module version="2.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="org.springframework" name="spring-context" rev="4.1.6.RELEASE"/>
<dependency org="org.springframework" name="spring-webmvc" rev="4.1.6.RELEASE"/>
<dependency org="commons-logging" name="commons-logging" rev="1.2"/>
<dependency org="javax.servlet" name="servlet-api" rev="2.5"/>
<dependency org="junit" name="junit" rev="4.12"/>
</dependencies>
</ivy-module>
I am getting the error when navigating to http://localhost:8080/filth/hello.html.
catalina.out does not give any errors, and I do see the log entry from HelloController.java, but very inconsistently--not sure why that is either.
Note that http://localhost:8080/filth/index.jsp, and http://localhost:8080/filth/view/hello.jsp work--just going through the Controller is not working as expected.
Anyone have any ideas?
Let me know if you need more context/info.
Thanks!
Figured it out. I didn't have the necessary jar dependencies included in the deployment--added a lib/ directory in WEB-INF and had ivy place necessary runtime dependecies there (the "deploy" ant target took it from there). I didn't see this error earlier because I wasn't looking in the right log file--finally saw that logging output was going to [tomcat]/logs/localhost...log.

WSO2- Error Using Clone Mediator to send message to an endpoint

I am working on WSO2 proxy service that invokes a lot of other DSS services. My requirement is to send the response of one of the DSS service on to a jms queue and at the same time continue with the exsiting flow in the proxy service i.e. continue invoking and processing the other DSS services.
I need to get the response of Simple Product Service (sequence key -if4_simpleProduct) and send it back on to the queue, but after that continue with logic that is placed in the proxy service and sequence. I tried using CLONE Mediator for the same. But my prxy service flow stops after coming in to the CLONE Meditaor flow. Below is the snippet for proxy service and sequence.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SPE_Payload"
transports="jms" startOnLoad="true" trace="enable">
<description />
<target>
<inSequence>
<transaction action="new" />
<xslt key="StepToCommon" />
<log level="full" />
<enrich>
<source type="body" clone="true" />
<target type="property" property="MSG_PAYLOAD" />
</enrich>
<sequence key="if4_simpleProduct" />
<filter xpath="boolean (//product/simpleProduct/altPrdCodes/pn_apc_id/text())">
<enrich>
<source clone="true" xpath="//product/simpleProduct/altPrdCodes" />
<target type="property" property="ALT_PRDS" />
</enrich>
<sequence key="if4_alternateProducts" />
</filter>
....
.....
<transaction action="commit" />
</inSequence>
</target>
<parameter name="transport.jms.ContentType">application/xml</parameter>
<parameter name="transport.jms.Destination">test</parameter>
</proxy>
Given below is the code of for sequence while calling Simple Product Service
<sequence xmlns="http://ws.apache.org/ns/synapse" name="if4_simpleProduct"
onError="myErrorHandlerSeq">
<payloadFactory>
<format>
<p:O_SimpleProduct xmlns:p="http://ws.wso2.org/dataservice">
<p:PC_STEP_SKU_ID>$1</p:PC_STEP_SKU_ID>
</p:O_SimpleProduct>
</format>
<args>
<arg xmlns:m="http://wso2.org/services/product" evaluator="xml"
expression="//product/simpleProduct/step_id/text()" />
</args>
</payloadFactory>
<header name="Action" value="urn:O_SimpleProduct" />
<callout serviceURL="local://localhost/services/productEnrichment"
action="urn:O_SimpleProduct" useServerConfig="true">
<source xmlns:ns="http://org.apache.synapse/xsd" xpath="$body/child::*[fn:position()=1]" />
<target xmlns:ns="http://org.apache.synapse/xsd" xpath="$body/child::*[fn:position()=1]" />
</callout>
<clone sequential="false">
<property name="RESPONSE" value="true" />
<header name="To" action="remove" />
<target>
<endpoint>
<address
uri="jms:/step.IF04Output?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue" />
</endpoint>
</target>
<target>
<filter xmlns:ns="http://org.apache.synapse/xsd" xmlns:ds="http://wso2.org/services/product"
source="//ds:result/ds:set/ds:PC_STATUS/text()" regex="0">
<then>
<log level="custom">
<property name="STATUS"
value="************DONE INSERTING SIMPLE ATTRIBUTES***************" />
</log>
</then>
<else>
<log level="full" category="ERROR">
<property name="STATUS"
value="************ERROR OCCURED WHILE INSERTING SIMPLE ATTRIBUTES. ROLLBACKING THE TRANSACTION***************" />
<property name="PC_RP_ID" expression="get-property('GEN_RP_ID')" />
</log>
<transaction action="rollback" />
<drop />
</else>
</filter>
<property xmlns:ds="http://wso2.org/services/product" name="GEN_RP_ID"
expression="//ds:result/ds:set/ds:PC_RP_ID/text()" />
<enrich>
<source type="property" clone="true" property="MSG_PAYLOAD" />
<target type="body" />
</enrich>
</target>
</clone>
</sequence>
I am struggling with the issue since last two days. tried sing Clone meditior in several places. but it does not work. Could you please provide your suggestions soon as I have a demo to go tomorrow and I need to sort it out :(
Cheers,
Aanchal
I think this is the part you are struggling;
<callout serviceURL="local://localhost/services/productEnrichment"
action="urn:O_SimpleProduct" useServerConfig="true">
<source xmlns:ns="http://org.apache.synapse/xsd" xpath="$body/child::*[fn:position()=1]" />
<target xmlns:ns="http://org.apache.synapse/xsd" xpath="$body/child::*[fn:position()=1]" />
</callout>
<clone sequential="false">
<property name="RESPONSE" value="true" />
<header name="To" action="remove" />
<target>
<endpoint>
<address
uri="jms:/step.IF04Output?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue" />
</endpoint>
</target>
Since your requirement is get response form one of the DS service and send that to queue..I think it fails because you are removing "To" header..Use callout mediator inside clone mediator's one of the "Target" configuration after sending to JMS queue drop the message there..In the other target, define your rest of the logic..

Resources