Enunciate framework - Not working with Spring Restful project - spring

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

Related

NLog/Elasticsearch writes to DataStream not index

I have NLog configuration that pushes data to Elastic. When the index pattern is static everything works fine. When I change it to be time-based, I can see messages coming to datastream (with the name of the index from configuration), but this datastream is creating .ds-* index which does not follow the name from the pattern. Therefore logs are not visible in Kibana. I have action.auto_create_index even set to true. What am I missing to have this working properly?
Here is NLog.config part related to elastic:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Targets.ElasticSearch"/>
<add assembly="NLog.StructuredLogging.Json"/>
</extensions>
<variable name="AspData" value="${when:when=length('${aspnet-request-url}') > 0:inner=|url\: ${aspnet-request-url}}${when:when=length('${aspnet-mvc-action}') > 0:inner=|action\: ${aspnet-mvc-action}}" />
<variable name="ExceptionLayout" value="${onexception:${newline}EXCEPTION - ${exception:format=type,message,method:maxInnerExceptionLevel=5:innerFormat=shortType,message,method}}" />
<variable name="LoggingLayout" value="${longdate}|EV[${event-properties:item=EventId_Id}]|TH[${threadname:whenEmpty=${threadid}}]|${mdc:userId}|${uppercase:${level}}|${logger}|${message} ${AspData} ${ExceptionLayout}" />
<!-- the targets to write to -->
<targets>
<!--<default-wrapper xsi:type="BufferingWrapper" bufferSize="100"/>-->
<!-- write logs to file -->
<target name="asyncElastic" xsi:type="AsyncWrapper">
<target name="elasticLog" xsi:type="ElasticSearch" index="logs-${configsetting:item=ElasticLog.ServiceName}-${date:format=yyyy-MM-dd}"
uri="${configsetting:item=ElasticLog.ServerUrl}" requireAuth="true" username="${configsetting:item=ElasticLog.User}" password="${configsetting:item=ElasticLog.Password}"
layout ="${LoggingLayout}" >
<field name="data" layout="${structuredlogging.json}" layoutType="System.Object" />
<field name="serviceName" layout="${configsetting:item=ElasticLog.ServiceName}" layoutType="System.String" />
<field name="userId" layout="${mdc:userId}" layoutType="System.String" />
</target>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.EntityFrameworkCore.Database.Command" maxlevel="Debug" final="true" />
<logger name="Microsoft.EntityFrameworkCore.Database.Command" maxlevel="Warning" writeTo="asyncElastic" final="true" />
<logger name="Elastic.Apm" maxlevel="Info" final="true" />
<logger name="*" minlevel="Trace" writeTo="asyncElastic" />
</rules>
</nlog>
Edit:
After further investigation I found out that default Kibana installation has index template called logs with pattern logs-*-*. This template treats this indice with that pattern as datastream and not index. So if I wanted to have indexes all I had to do is change my index name to not follow that pattern.

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>

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

Spring-Ibatis Deployement exception

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"/>

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