Spring-Ibatis Deployement exception - spring

Exception:
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: ServletContext resource [/WEB-INF/SqlMapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: java.io.IOException: Could not find resource WEB-INF/ADCampaignDetailsSQLMap.xml
SqlMapConfig.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL MAP Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings useStatementNamespaces="true"/>
<sqlMap resource="WEB-INF/ADCampaignDetailsSQLMap.xml"/>
</sqlMapConfig>
ADCampaignDetailsSQLMap.xml is placed inside WEB-INF of my project folder
And the Above exception is raised when i copied the war file to webapps folder ..
Can any one give me solution for this?
thanks in advance
Edit:
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project
name="adblendservice"
default="war" >
<property environment="env" />
<property
name="builddir"
value="build/" />
<property
name="srcdir"
value="src/main/java/" />
<property
name="deploydir"
value="deploy/" />
<property
name="wardir"
value="src/main/webapp/" />
<property
name="libdir"
value="${wardir}/WEB-INF/lib/" />
<property file="build.properties" />
<path id="project-classpath" >
<fileset
dir="web/WEB-INF/lib"
includes="*.jar" />
<fileset
dir="${tomcat-home}/lib"
includes="*.jar" />
<!--
<fileset dir="${tomcat-home}/common/lib" includes="*.jar" />
<fileset dir="${tomcat-home}/server/lib" includes="*.jar" />
-->
</path>
<target name="clean" >
<delete
dir="${builddir}"
failonerror="true" />
<echo message="Creating build directories" />
</target>
<target name="war" >
<mkdir dir="${builddir}" />
<mkdir dir="${builddir}/adblendservice/WEB-INF/classes" />
<mkdir dir="${deploydir}" />
<path id="basepath" >
<fileset dir="${wardir}/WEB-INF/lib" >
<include name="**/*.jar" />
</fileset>
</path>
<javac
destdir="${builddir}/adblendservice/WEB-INF/classes"
includeantruntime="false"
srcdir="${srcdir}" >
<classpath refid="basepath" />
</javac>
<war
update="update"
warfile="${builddir}/adblendservice.war"
webxml="${wardir}/WEB-INF/web.xml" >
<classes dir="${builddir}/adblendservice/WEB-INF/classes" />
<fileset dir="${srcdir}" >
<include name="**/*.xml" />
</fileset>
<lib dir="${wardir}/WEB-INF/lib" />
<fileset dir="${wardir}" >
<include name="**/*.xml" />
</fileset>
</war>
</target>
<target
name="deploy"
depends="clean, war" >
<copy
file="${builddir}/adblendservice.war"
todir="${deploydir}" >
</copy>
</target>
</project>

The root of the classpath where iBatis searches for xml files is WEB-INF/classes, not the root of the public web site.
Try to move your xml into the classes directory and point to it without path.

Move your XML files to class path or if it is outside class path, then specify path like <sqlMap resource="../WEB-INF/ADCampaignDetailsSQLMap.xml"/>

Related

Tycho plugin for eclipse product is not creating launcher.ini file

I am in the process of Maven-izing an existing Eclipse plugin product build, using Tycho. Unfortunately, it is not packaging the launcher ini file.
However, this is present when I export the product from Eclipse.
Is there any configuration in the pom or elsewhere that I need to mention something?
Product File
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="Eclipse Product" uid="Product" id="prod-plugin.Product1" application="org.eclipse.ui.ide.workbench" version="4.0.0" useFeatures="false" includeLaunchers="true">
<aboutInfo>
<image path="/prod-plugin/icons/prod128.png"/>
<text>
An Eclipse Application
</text>
</aboutInfo>
<configIni use="default">
</configIni>
<launcherArgs>
<programArgs>-consoleLog-Xss512m
</programArgs>
<vmArgs>-Xms1G -Xmx3G -Xss1G -Dfile.encoding=UTF-8
</vmArgs>
</launcherArgs>
<windowImages i16="/prod-plugin/icons/prod16.png" i32="/prod-plugin/icons/prod32.png" i48="/prod-plugin/icons/prod48.png" i64="/prod-plugin/icons/prod64.png" i128="/prod-plugin/icons/prod128.png" i256="/prod-plugin/icons/prod256.png"/>
<splash
location="prod-plugin"
startupProgressRect="2,277,655,10"
startupMessageRect="7,259,590,18"
startupForegroundColor="FFFFFF" />
<launcher name="prod">
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
<windows include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8</windows>
</vm>
<plugins>
<plugin id="prod-plugin"/>
.....
</plugins>
<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.felix.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.felix.event" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.felix.simpleconfigurator" autoStart="true" startLevel="1" />
</configurations>
<preferencesInfo>
<targetfile overwrite="false"/>
</preferencesInfo>
<cssInfo>
</cssInfo>
</product>

Enunciate framework - Not working with Spring Restful project

I have integrated enunciate framework to generate the API document for the Spring RESTful project. I have followed the steps from https://github.com/stoicflame/enunciate/wiki/Executables and deployed the war created from the enunciate configuration in the tomcat server(http://localhost:8080/sample_enunciate) but its displaying the empty document. Here I have provided the configuration details used in the sample project.
NOTE: But the similar configuration is working with Jersey restful project. I really stuck here. Please let me know, is this bug with the enunciate framework integration with Spring project. Thanks in advance.
Project configuration:
java -1.7.0
tomcat -6.0 &7.0
ant -1.9.4
spring -4.0.5
enunciate -1.30
jars:
enunciate-core-1.30-RC1.jar
enunciate-core-annotations-1.30-RC1.j
enunciate-core-rt-1.30-RC1.jar
enunciate-java-client-1.30-RC1.jar
enunciate-docs-1.30-RC1.jar
enunciate-rt-1.30-RC1.jar
enunciate-spring-app-rt-1.30-RC1.jar
enunciate-spring-jaxws-rt-1.30-RC1.ja
spring-aop-4.0.5.RELEASE.jar
spring-beans-4.0.5.RELEASE.jar
spring-context-4.0.5.RELEASE.jar
spring-context-support-2.5.4.jar
spring-core-4.0.5.RELEASE.jar
spring-expression-4.0.5.RELEASE.jar
spring-jdbc-4.0.5.RELEASE.jar
spring-test-4.0.5.RELEASE.jar
spring-tx-4.0.5.RELEASE.jar
spring-web-4.0.5.RELEASE.jar
spring-webmvc-4.0.5.RELEASE.jar
This is my enunciate.xml.
enunciate.xml
<?xml version="1.0"?>
<api-classes>
<include pattern="com.sample.controller.*" />
</api-classes>
<modules>
<!-- Docs -->
<docs title="example" copyright="Example.com"/>
<webapp mergeWebXML="WebContent/WEB-INF/web.xml" />
<spring-app disabled="false" springVersion="4.0.5">
<springImport file="resources/dev/applicationContext.xml" />
<springImport file="WebContent/WEB-INF/rest-servlet.xml" />
</spring-app>
<c disabled="true" />
<csharp disabled="true" />
<java-client disabled="false" />
<cxf disabled="false" />
<gwt disabled="false" />
<jaxws-client disabled="true" />
<jaxws-ri disabled="true" />
<jaxws-support disabled="true" />
<jersey disabled="true" />
<xml disabled="false" />
<obj-c disabled="true" />
<rest disabled="false" />
</modules>
properties file for build.xml
enunciate_build.properties
JAVA_HOME=C:/Java/jdk1.7.0/
tomcat.home=D:/xampp/tomcat
This is my build.xml
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default = "enunciate">
<property file ="enunciate_build.properties"/>
<property name="lib.dir" value="../libs" />
<property name="src.dir" value="src"/>
<target name = "enunciate">
<path id= "enunciate.classpath">
<fileset dir = "${lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir ="${lib.dir}/modules/spring">
<include name="*.jar"/>
</fileset>
<fileset dir = "${JAVA_HOME}">
<include name = "lib/tools.jar"/>
</fileset>
</path>
<taskdef name="enunciate" classname = "org.codehaus.enunciate.main.EnunciateTask">
<classpath refid = "enunciate.classpath"/>
</taskdef>
<enunciate javacSourceVersion="1.7" javacTargetVersion="1.7" basedir = "${src.dir}" configFile="enunciate.xml">
<include name = "**/*.java"/>
<classpath refid= "enunciate.classpath"/>
<export artifactId="war.file" destination="${tomcat.home}/webapps/sample_enunciate.war"/>
</enunciate>
</target>
</project>
Enunciate only recognizes JAX-RS annotations right now. For further information follow this link.https://github.com/stoicflame/enunciate/issues/60

getting error in sonar task while executing build.xml

I have configured sonar in my build xml as shown below but upon execution of my build.xml i am getting the error below..can u plas advise how to overcome from this error
target name="sonar">
<echo message="**** thirdparty.lib.dir -- > ${thirdparty.lib.dir}/sonar ****"/>
<sonar:sonar workDir="${build.dir}" key="gtr_61.all.rules:dev" version="1.0" xmlns:sonar="antlib:org.sonar.ant">
<!-- source directories (required) -->
<sources>
<path location="${pps.dir}/src" />
<path location="${pn.dir}/src" />
</sources>
<property key="sonar.host.url" value="https://abc/" />
<property key="sonar.jdbc.url" value="jdbc:oracle:thin:abc" />
<property key="sonar.jdbc.driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property key="sonar.jdbc.username" value="=AAA" />
<property key="sonar.jdbc.password" value="BBB" />
<property name="sonar.scm.url" value="https://svn.ats" />
<property name="sonar.java.source" value="1.5" />
<property name="sonar.language" value="java"/>
<property name="sonar.projectVersion" value="1.0"/>
<tstamp prefix="build-info">
<format property="current-date" pattern="dd-MMM-yyyy" locale="en" />
<format property="current-time" pattern="HH:mm:ss z" locale="en" />
<format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>
<!-- cobertura -->
<property key="sonar.cobertura.reportPath" value="cobertura-report/coverage.xml" />
<property key="sonar.dynamicAnalysis" value="reuseReports" />
<!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
<binaries>
<path location="${ps.dir}/build/classes" />
<path location="${omm.dir}/build/classes" />
</binaries>
<!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin -->
<libraries>
<path location="${lib.dir}" />
</libraries>
<property key="sonar.profile" value="abc Rule" />
<!--property key="sonar.profile" value="Custom Rules" -->
</sonar:sonar>
the error i am getting is ..
onar
[06:56:15]echo
[06:56:15]**** thirdparty.lib.dir -- > /opt/app//buildAgent-8.0.3/work/pla/lib/thirdparty/sonar ****
[06:56:15]sonar:sonar
[06:56:15]property doesn't support the "name" attribute
If my feeling is correct you're using a very old version of the SonarQube Ant task. Here is the way to configure this SonarQube Ant task: http://docs.codehaus.org/display/SONAR/Analyzing+with+SonarQube+Ant+Task
Here is a latest documentation on the new syntax:
http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Ant+Task

hibernatetools ant task - hbm2java - creates pojo without package statement

I'm exporting my mapping (hbm.xml) to pojo classes using ant task.
It generates the POJO files in the mapped directory. But the Classes miss the Package statement. It simply creates all files in default package
// default package
// Generated Aug 23, 2012 12:34:40 PM by Hibernate Tools 3.2.2.GA
Here is my ant build file for the task.
<project name="Hibernate Tools for Ant - hbm2java" default="gensrc">
<path id="tools">
<path location="lib/hibernate-tools-3.2.3.GA.jar"/>
<path location="lib/hibernate3.6.10.jar"/>
<path location="lib/freemarker-2.3.8.jar"/>
<path location="lib/hsqldb-2.2.4.jar"/>
<path location="lib/commons-logging.jar"/>
<path location="lib/dom4j-1.6.1.jar"/>
<path location="lib/slf4j-api-1.6.1.jar"/>
<path location="lib/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
</path>
<taskdef name="gen-src" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="tools"/>
<target name="gensrc">
<gen-src destdir="src/main/java">
<configuration
configurationfile="src/main/resources/hibernate.cfg.xml">
<fileset dir="src/main/java/com/kee/example/domain/maps">
<include name="Event.hbm.xml"/>
</fileset>
</configuration>
<hbm2java destdir="src/main/java/com/kee/example/domain"/>
</gen-src>
</target>
</project>
the default Pojo.ftl (inside hibernate-tools.jar) has the declaration as below
${pojo.getPackageDeclaration()}
// Generated ${date} by Hibernate Tools ${version}
what should i be changing in order to have correct package declaration in the generated POJO.
Update:
Here is my Mapping file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.kee.example.domain">
<meta attribute="generated-class">EventBase</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="scope-field">protected</meta>
<class name="com.kee.example.domain.Event" table="event">
<id name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="eventDate" type="timestamp"/>
<property name="eventString" type="java.lang.String"/>
</class>
</hibernate-mapping>
I was getting the same problem in maven and not sure about the reason but it was resolved once I started using annotationconfiguration instead of jdbcconfiguration.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>${db.src.dir}</outputDirectory>
</component>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<drop>true</drop>
<create>true</create>
<export>false</export>
<format>true</format>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<outputfilename>${ddl.file}</outputfilename>
<templatepath>src/main/resources/hibernate-template</templatepath>
<delimiter>;</delimiter>
<configurationfile>src/main/resources/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
I did not want the annotated pojo classes so I had commented codes in *.ftl files.

Could not resolve placeholder

When i run junit test cases, getting following error:
Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'CacheRegionManagerFactory' defined in class path resource [com/bgc/ecm/core/caching/cacheRegionManager-ctx.xml]: Could not resolve placeholder 'appRoot'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
cacheRegionManager-ctx.xml file:
<bean id="CacheRegionManagerFactory" class="com.bgc.ecm.core.caching.CacheRegionManagerFactory">
<property name="diskStoreCachePath" value="${diskStoreCacheRootPath}/${appRoot}/was/var/elnino/${appName}/${cloneNumber}"/>
<property name="defaultRegion" ref="DefaultRegion"/>
<property name="regionInfos" ref="CustomRegions"/>
</bean>
propertyContext.xml:
<context:property-placeholder
location="classpath:/property/globalContext.properties,
classpath:/property/globalContext-${app.env}.properties,
classpath:/property/globalContext-${app.env}-${app.module}.properties,
classpath:/property/applicationContext.properties,
classpath:/property/applicationContext-${app.module}.properties,
classpath:/property/applicationContext-${app.env}.properties,
classpath:/property/applicationContext-${app.env}-${app.module}.properties"/>
and applicationContext-DEV-FNT.properties contains:
appName=bgc-elnino-core-cluster
appRoot=ecm
cloneNumber=1
site=elnino-core
Junit target:
<target name="junit" depends="init-junit">
<copy todir="${TEST_BUILD_DIR}/" overwrite="true">
<fileset dir="${COMP_TESTCONFIG_DIR}">
<exclude name="*.properties.template" />
</fileset>
</copy>
<junit printsummary="on" fork="yes" forkmode="perBatch" haltonfailure="false" failureproperty="junit.failure" showoutput="false">
<classpath>
<path refid="CLASSPATH_JUNIT"/>
</classpath>
<batchtest fork="no" todir="${TEST_BUILD_DIR}">
<fileset dir="${COMP_TEST_SRC}" erroronmissingdir="false">
<include name="**/*Test.java" />
<include name="**/Test*.java" />
</fileset>
</batchtest>
<formatter type="xml" />
</junit>
<junitreport todir="${JUNIT_REPORT}">
<fileset dir="${TEST_BUILD_DIR}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${JUNIT_REPORT}"/>
</junitreport>
<delete dir="${TEST_BUILD_DIR}" />
</target>
env variable is:
public final void setupEnvironmentPropertiesIfNeeded()
{
String address = (new StringBuilder()).append("#").append(Integer.toHexString(System.identityHashCode(this))).toString();
if(StringUtils.isEmpty(System.getProperty("app.env")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env will be set to DEV").toString());
System.setProperty("app.env", "DEV");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.env already set to:'").append(System.getProperty("app.env")).append("'").toString());
}
if(StringUtils.isEmpty(System.getProperty("app.module")))
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module will be set to FNT").toString());
System.setProperty("app.module", "FNT");
} else
{
LOG.info((new StringBuilder()).append(address).append(" Environment property app.module already set to:'").append(System.getProperty("app.module")).append("'").toString());
}
}
It appears that your properties file is not getting loaded. Try explicitly loading the properties file using:
<property file="applicationContext-DEV-FNT.properties" />
issue can be solved by passing "-DappRoot=ECM" parameter and other required parameters.

Resources