Meaning of log4j.properties in EOL Jetty Hightide 7? - ant

Our product is using Jetty to deploy a webapp in which we are triggering the jetty using the ant build target like below
<exec executable="**/jetty.sh" failonerror="true">
<env key="JETTY_CONF" value="***/jetty.conf"/>
<env key="JETTY_LOGS" value="${logs}"/>
<env key="JETTY_PID" value="${logs}/jetty.pid"/>
<env key="TMPDIR" value="${tmp.dir}"/>
<!-- location where jetty will extract the war -->
<env key="JAVA_OPTIONS"
value="-server -d64 ${heapOptions} ${gcOptions} ${sslOptions} ${debugFlags} -Dsettings.path=${settings.path} -Dlog4j.configuration=file:///${xmlFile} -Djetty.secure.port=${*} -Dapp.dir=${*} -Drs.data.dir=${*} -Disutest=${isutest} -Disftest=${ftest} -Disrtest=${rtest} -Disrtestlocal=${rtestlocal} -Dlogs.dir=${logs.dir} -Ddist.dir=${*()} "/>
<env key="JAVA" value="${JAVA_HOME}/bin/java"/>
<arg value="${com}"/>
</exec>
In this I am wondering if the -Dlog4j.configuration=file:///${xmlFile} is it for the Jetty to configure the logs or is it webapp specific .
If it is for jetty to configure log4j I do not see any log4j related libraries in jetty. So, need a little clarification on this.

from Jetty 1.0 thru 9.0 Jetty used an in-house Logging Facade, that wrote to STDERR (System.err), with an optional configuration to use slf4j (since Jetty 6.0).
From Jetty 10.0 on-wards Jetty uses the slf4j logging facade (and has it's own jetty-slf4j-impl that writes to STDERR/System.err).
Not once has Jetty depended on or shipped with log4j.
If you see log4j in your configuration, it's something that you (or your predecessors) have added on top of Jetty.

Related

org.sonar.runner.impl.RunnerException: Unable to execute Sonar

I am trying to integrate Sonar task in Ant build in Eclipse. SonarQube server is running successfully at the default port on localhost. On opening "http://localhost:9000/" in browser, SonarQube web interface is successfully opening.
Problem is when I am running Sonar task from Ant build file it is giving error "org.sonar.runner.impl.RunnerException: Unable to execute Sonar". That's it. No stacktrace is logged on console.
The sonar task in ANt build is defined as below:
<target name="sonar" depends="jcompile">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="<PathToAntPlugin>/lib/sonar-ant-task-2.2.jar" />
</taskdef>
<property name="sonar.projectDescription" value="Example application using Ant and Jacoco" />
<property name="sonar.sources" value="${basedir}/src" />
<property name="sonar.host.url" value="http://localhost:9000"/>
<property name="sonar.surefire.reportsPath" value="${reports.junit.xml.dir}" />
<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.antTargets" value="run-tests" />
<property name="sonar.projectKey" value="<PathToMyProject>" />
<property name="sonar.projectVersion" value="1.0" />
<sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
</target>
Other details:
SonarQube Server 4.5,
sonar-ant-task-2.2.jar,
JDK 1.6.0_21,
Eclipse Kepler
Is there any comptability issue between the jdk, eclipse, sonar server or sonar ant jar? Is there any way to find the detail logs in order to debug the issue?
Apart from above issue, I am having other issue. When I am installing SonarCube plugin in eclipse, in Windows ->Preferences SonarCube is not coming. However, in installed software list in Eclipse it is listed. I have tried to run eclipse with -clean option but no success. Please let me know what could be the problem?
When we are running the build file from eclipse it is not giving full stack trace on console in some cases. Try to run the build file from the command prompt.
For example:
Open command prompt window and go to eclipse ant bin directory path(In my system it is C:\eclipse\plugins\org.apache.ant_1.9.6.v201510161327\bin) and from here run your build file using ant command.
C:\eclipse\plugins\org.apache.ant_1.9.6.v201510161327\bin>ant -buildfile [path_of_build_file]\build-test.xml
I know I am late, but this is to help who visits this with same problem
For the missing preferences, the Installation FAQ of Sonar says to do a restart with -clean argument.

How stop start tomcat service in ubuntu using ant?

I have jenkins on jetty on test server (ubuntu 12.04) and I need stop/start tomcat before deploy my war file.
I can start tomcat over ant with target:
<target name="tomcat-start">
<java jar="${tomcat.home}/bin/bootstrap.jar" fork="true" >
<jvmarg value="-Dcatalina.home=${tomcat.home}"/>
</java> </target>
But if I check /etc/init.d/tomcat6 status i see "* Tomcat servlet engine is not running."
How to stop start tomcat service in ubuntu using ant?
here is the link startup & shutdown tomcat. This will be helpful.
http://fugoconsulting.wordpress.com/tag/startup-and-shutdown-of-tomcat-in-ubuntu/

Run ant task in different jvm

Our ant build is run using Java 1.7.0 for JAVA_HOME. This way javac and all other Java dependent targets use the correct Java by default.
But 1 ant target from an external supplier does not support (or rather has a bug) using Java 1.7.0. And unlike e.g. javac or a forked junit, this target does not support parameters to switch jvm.
Is it possible to run a specific ant target in a different jvm?
To make Jeanne Boyarsky's suggestion of using the exec Ant task concrete, the following example wraps the exec task in a macro to simplify calling targets with various JVMs. Notice that the JVM is set using the Ant environment variable JAVACMD.
Example Project
<?xml version="1.0" encoding="UTF-8"?>
<project name="run-target-with-specified-java-version" default="test">
<macrodef name="exec-target">
<attribute name="antfile" default="${ant.file}" />
<attribute name="target" />
<attribute name="jvm" default="${java.home}/bin/java" />
<sequential>
<exec executable="ant">
<env key="JAVACMD" value="#{jvm}" />
<arg line='-f "#{antfile}"' />
<arg line="#{target}" />
</exec>
</sequential>
</macrodef>
<target name="echo-java-version">
<echo message="Java version: ${java.version}" />
</target>
<target name="test">
<exec-target target="echo-java-version" />
<property name="java1.6"
location="/usr/lib/jvm/jdk1.6/bin/java" />
<exec-target target="echo-java-version" jvm="${java1.6}" />
</target>
</project>
Output
test:
[exec] Buildfile: /home/your/project/build.xml
[exec]
[exec] echo-java-version:
[exec] [echo] Java version: 1.7.0
[exec]
[exec] BUILD SUCCESSFUL
[exec] Total time: 0 seconds
[exec] Buildfile: /home/your/project/build.xml
[exec]
[exec] echo-java-version:
[exec] [echo] Java version: 1.6.0
[exec]
[exec] BUILD SUCCESSFUL
[exec] Total time: 0 seconds
BUILD SUCCESSFUL
Total time: 2 seconds
You can use the exec task to run the build file with that target defined to run as a parameter. It could be running in a different JVM since you can pass the JVM to that exec call.
Note that you'd have to refactor the target to rely on files for communication rather than setting properties. Since it would be in a different JVM, it obviously can't rely on memory.
You can run a target in a different JVM (we do it all the time). You just need to use fork:
<javac srcdir="${src}"
destdir="${build}"
fork="yes"
/>
But I sense you are aware of this, so how about running the external ANT task as it is, and rest of them (lets say you have 3 more javac tasks) in the JVM you want. This can be achieved by setting a property file. See javac task
It is possible to use different compilers. This can be specified by either setting the global build.compiler property, which will affect all tasks throughout the build
So this property will affect your 3 tasks and run them in the JVM you specified (say 1.7) and you can set the default JAVA_HOME to whatever your external library task needs.

Using Gradle to generate jax-ws java sources

I have a wsdl and I'd like to generate jax-ws type Java source from it using IBM Websphere version of wsimport. How can I do this in an easy way? wsimport.bat references com.ibm.ws.jaxws.tools.WsImport to do the code generation.
I solved the problem by calling wsimport directly. Just make sure websphereHome is set to the websphere home folder on your machine. Then genDir is the folder where you want the files to be generated to. Finally, wsdlFile is the path to the wsdl used for generation.
task generateWSDL2Java(type:Exec) {
doFirst{
genDir.mkdirs()
}
cmd = websphereHome + '/bin/wsimport.bat -keep -d '+genDir+' '+wsdlFile
commandLine = ['cmd', '/K', cmd]
}
Here's a simple Ant script, using a WebSphere 6.1 runtime (with the WebSphere Feature Pack, which is required for JAX-WS), which I just tested:
<?xml version="1.0" encoding="UTF-8"?>
<project name="JAX-WS Client">
<property name="was.dir" value="C:\Program Files (x86)\IBM\WebSphere\AppServer"/>
<path id="jaxws.gen.classpath">
<fileset dir="${was.dir}/plugins">
<include name="*com.ibm.wsfp.main_6.1.0.jar" />
<include name="*org.apache.axis2_6.1.0.jar" />
<include name="*com.ibm.jaxws.tools_6.1.0.jar" />
<include name="*com.ibm.jaxb.tools_6.1.0.jar" />
</fileset>
<fileset file="${was.dir}/lib/j2ee.jar"/>
</path>
<!-- Ant task definition for wsimport -->
<taskdef classpathref="jaxws.gen.classpath" name="wsimport" classname="com.sun.tools.ws.ant.WsImport"/>
<target name="wsimport">
<wsimport sourcedestdir="./src" destdir="./build" debug="true" verbose="true"
keep="true" wsdl="${wsdlFile}" />
</target>
</project>
If you have RAD 8, here's the InfoCenter article which describes using the JAX-WS Ant tasks from within that. I'm not sure how other WebSphere development environments compare.
JAX-WS artifacts are portable, which means that you are not required to use IBM's tools. BTW, I think that the wsgen and wsimport tools shipped with WAS actually use code from the Sun/Oracle reference implementation.
Therefore you could use any documented solution for Gradle, even if it is not WebSphere specific.

ant builds running through maven issue

So I'm building a project with maven, and in this maven pom we have a reference to an ant build script. The maven pom triggers this ant build to build a project (an install of alfresco with mysql database and tomcat server packed up with it).
The issue seems to be when you try to set up a database for alfresco to use through the ant build. This is the part of the ant build.
<target name="createDatabase">
<exec spawn="false" executable="${mysql.home}/bin/mysql" failonerror="true">
<arg value="-u" />
<arg value="root" />
<arg value="-e" />
<arg value="source ${alfresco.home}\mysql\db_setup.sql" />
</exec>
</target>
I'm getting 'unknown command '\U' sent back to me as an error on this. Of course you can install the DB manually but I want it as part of this ant script. SOmeone I work with runs this successfully on XP, but I'm getting that error on win7. Any ideas?

Resources