Getting error like weblogic.home env variable must be set to create osb12 config jar while executing ant script Following is the script I am using - ant

config.xml (build file)
Ant script to create An Oracle Service Bus Config Jar from file system.
<target name="run">
<taskdef name="configjar" classname="com.bea.alsb.tools.configjar.ant.ConfigJarTask"/>
<property name="task.failonerror" value="true" />
<property name="task.errorproperty" value="" />
<property name="settingsFile" value="C:\Oracle\Middleware\Oracle_Home\osb\tools\configjar\config.xml"/>
<property name="WL_HOME" value="C:\Oracle\Middleware\Oracle_Home\wlserver" />
<property name="MW_HOME" value="C:\Oracle\Middleware\Oracle_Home\" />
<property name="OSB_HOME" value="C:\Oracle\Middleware\Oracle_Home\osb" />
<!--configjar failonerror="${task.failonerror}" errorProperty="${task.errorproperty}" settingsFile="${settingsFile}" -->
<configjar settingsFile="${settingsFile}" >
</configjar>
</target>
my settings file :
<?xml version="1.0" encoding="utf-8"?>
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="D:\JDeveloper\mywork\ServiceBusApplication2" />
<!--extensionMapping>
<mapping type="str1234" extensions="str1234" />
</extensionMapping-->
<!--fileset>
<include name="str1234" />
<exclude name="str1234" />
</fileset-->
</source>
<configjar jar="SBProject.jar" overwrite="false">
<projectLevel includeSystem="true">
<project>SBProject</project>
</projectLevel>
</configjar>
</configjarSettings>
I have set weblogic environment variable on command prompt , globally using environment variable section of Windows but still not luck.
I am stuck at this point.Need solution on the same.
I am using soa12c.And this is osb script for creation of configuration jar file for osb application.

Go to D:\Oracles\Middleware12c\osb\tools\configjar and run setenv.cmd. On the same cmd try running your ant script. It might ask for MW_HOME, set that also.

Related

JBoss remote deploy using ANT script

Is it possible to do remote deploy of application (jar file) on JBoss using ANT script?
I found only few suggestions to do copy, but that can be done only on local server.
Mainly there are two approaches to do remote JBOSS deploy.
Cargo
This tool providing the ant scripts to do the remote deploy/control JBOSS instance
Copy approach. The main steps are copy the application files to the jboss deploy folder and then start the jboss by remote command.
For example, you can use SCP task to copy the application file to remote host, and then use the SSHEXEC task to remove control the JBOSS_BIN/ shell to start/stop jboss instance.
To deploy remote you can use the jboss-cli, which is included in jboss. To make this approach work you have to have a local jboss install, because it includes the jboss-cli jar. Then you will need a jboss-user on the remote host, which you can create with the add-user.(sh|bat) on the remote box. Then you can use the following ant-tasks to deploy:
<!-- local installation to find the correct jar -->
<property name="local.jboss.home" value="/path/to/jboss/install/dir" />
<!-- remote parts -->
<property name="remote.jboss.host" value="some.ip" />
<property name="remote.jboss.port" value="9999" />
<property name="remote.jboss.user" value="user" />
<property name="remote.jboss.password" value="password" />
<!-- supposedly this is built by a seperate task -->
<property name="my.deployment" value="${basedir}/build/foo.war" />
<!-- preset to run jboss-cli, this can be used to push any command to a running
jboss instance -->
<presetdef name="jboss-cli">
<java jar="${jboss.home}/jboss-modules.jar" fork="true">
<arg line="-mp ${jboss.home}/modules org.jboss.as.cli" />
<arg value="--controller=${jboss.host}:${jboss.port}" />
<arg value="--user=${jboss.user}" />
<arg value="--password=${jboss.password}" />
<arg value="--connect" />
</java>
</presetdef>
<!-- the exec some command on cli command -->
<target name="exec-jboss">
<jboss-cli failonerror="true">
<arg value="${jboss.command}" />
</jboss-cli>
</target>
<target name="deploy" description="deploys to a running jboss instance">
<antcall target="exec-jboss">
<param name="jboss.home" value="${local.jboss.home}" />
<param name="jboss.host" value="${remote.jboss.host}" />
<param name="jboss.port" value="${remote.jboss.port}" />
<param name="jboss.command" value="deploy ${my.deployment}" />
</antcall>
</target>

Ant build for multiple servers

I need suggestions for creating Ant build for multiple servers. I have about 25 servers. If possible, I would like to implement deployment war file for all the servers by running ant once. I have the following issues to consider
The configuration parameters are not the same for all servers.
Some configuration parameters I have to set server host ip on which app is deployed. With 25
servers, want some suggestions on how to deal with this.
You could hand code the logic to do this in Ant, but it might be lot of work depending on how different your server configurations are. Instead, I'd recommend looking at using a proper configuration management tool such as Chef or Puppet to automate your deployments and just use Ant to build the files that are deployed.
I had the same objectives.
You can either code a maven script in order to set up the continuous integration on Jenkins as mentionned by Jayan
or you can create an ANT script like you mentionned.
<!-- Define custom properties -->
<property name="build.dir" location="${basedir}/target" />
<property name="host.dev" value="YOUR IP" />
<property name="host.live" value="YOUR IP 2" />
<property name="ssh.timeout" value="60000" />
<property name="username.dev" value="username" />
<property name="username.live" value="username 2" />
<property name="password.dev" value="password" />
<property name="password.live" value="password 2" />
Create you own ssh macrodef task in order to use ssh commands:
<!-- Define ssh commands sshexec -->
<macrodef name="ssh_cmd">
<attribute name="host" />
<attribute name="command" />
<attribute name="usepty" default="false" />
<attribute name="username" />
<attribute name="password" />
<sequential>
<echo>Executing command : #{command} on #{username}###{host}</echo>
<sshexec host="#{host}" failonerror="true" username="#{username}" password="#{password}" timeout="${ssh.timeout}" command="#{command}" usepty="#{usepty}" trust="true" />
</sequential>
</macrodef>
Send a command to your server like :
<ssh_cmd host="${host.dev}" command="YOUR COMMAND (ex: sudo start yourservice onlinux)" username="${username.dev}" password="${password.dev}"/>
Don't forget to import sshexec / scp ant tasks with something like :
<property environment="env" />
<taskdef resource="net/jtools/classloadertask/antlib.xml">
<classpath>
<fileset dir="${ant.home}/lib" includes="ant-classloader*.jar" />
</classpath>
</taskdef>

Configure Sonar for Delphi with sub-modules

I can get Delphi analysis working on single projects, so the plugin works.
I can get Submodules analysis set up as per my previous question but no delphi analysis is performed.
refer to Configuration of build.xml file for Sonar modules with Ant for reference.
If I include the (I believe) required delphi configuration in the master build file it only works if I include the sonar.sources line.
BUT, when I include that line it is attempting to analyse all delphi code and is ignorning the submodules.
How (assuming it can be done) do I configure this to work or do I have to run each project completely separately?
Master Build File
<?xml version="1.0" encoding="UTF-8"?>
<project name = "EXO" default = "sonar" basedir = "." xmlns:sonar="antlib:org.sonar.ant">
<echo>Root Project</echo>
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="c:/ANT/lib" />
</taskdef>
<property name="sonar.host.url" value="http://localhost:9000" />
<property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />
<target name="sonar">
<sonar:sonar key="EXO.key" version="0.1">
<property key="sonar.sources" value="." />
<property key="sonar.language" value="delph" />
</sonar:sonar>
</target>
</project>
Sub Project Build File
<?xml version="1.0" encoding="UTF-8"?>
<project name="CRM" default="all" basedir=".">
<echo>CRM Module</echo>
<property name="sonar.language" value="delph" />
<property name="sonar.projectKey" value="EXO:CRM" />
<property name="sonar.sources" value="." />
<target name="all" />
</project>

sonar ant build.xml file for running default Sun checks on Java project

I am a beginner to SONAR , i just need a help for a sample ant build file for running my java project name 'Hello World' with SONAR 's default Sun checks Quality profile .I have not found anywhere any proper ant guide for sonar. I am using SONAR 2.10 .
Please help me in starting with SONAR .
<project name="Example" default="Sonar" basedir=".">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="C:\Program Files\Apache Software Foundation\ant\lib\sonar-ant-task-1.0.jar" />
</taskdef>
<!-- Out-of-the-box those parameters are optional -->
<property name="sonar.jdbc.url" value="jdbc:mysql://localhost:3309/sonar" />
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<property name="sonar.jdbc.username" value="root" />
<property name="sonar.jdbc.password" value="root" />
<!-- Additional Sonar configuration (PMD need 1.5 when using annotations)-->
<property name="sonar.java.source" value="1.5"/>
<property name="sonar.java.target" value="1.5"/>
<property name="sonar.projectName" value="Example"/>
<property name="sonar.binaries" value="C:\Documents and Settings\tausif\Feature2\Example\bin"/>
<!-- SERVER ON A REMOTE HOST -->
<property name="sonar.host.url" value="http://localhost:8080/sonar" />
<target name="Sonar">
<!-- The workDir directory is used by Sonar to store temporary files -->
<sonar:sonar workDir="C:\Documents and Settings\tausif\Feature2\Sonar" key="com.example:example" xmlns:sonar="antlib:org.sonar.ant" >
<!-- source directories (required) -->
<sources>
<path location="C:\Documents and Settings\tausif\Feature2\Example" />
</sources>
</sonar:sonar>
</target>
</project>
The above two answers were realy helpful for me to create this xml file .
This is my sample build.xml . Can you please check what i am missing in it?
I have made Sun checks as default.My project name is Example.
You might find this (Sonar 2.6: Adds Continuous Inspection Support for Ant Community) or this (Analyse with Ant Task 1.0) documentation helpful.
You can refer below ant script which is specific to the sonar.
You can add it in your build.xml.
Below is the script with the details
<!-- Here you need to set the path which contains sonar specific jars required for ant e.g. path which contains sonar-ant-task-2.1.jar -->
<path id="sonar.classpath">
<fileset dir="${basedir}/sonar" includes="**/*.jar" />
</path>
<!-- This taskdef represents your ant lib for sonar you have to specify jar location along with jar name in class path no need to change the uri and resource-->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${basedir}\sonar\sonar-ant-task-2.1.jar" />
</taskdef>
<!-- This is the target we use to run sonar "depends" property is optional -->
<target name="sonar" depends="clean, compile">
<!-- specify your build version -->
<property name="build.version" value="0.0.0.1-Sonar"/>
<!-- specify your organization name its optional -->
<property name="mysonar.organizationName" value="XYZ"/>
<!-- specify your project Name -->
<property name="sonar.projectName" value="${project.name}" />
<!-- database url which is used by the sonar -->
<property name="sonar.jdbc.url" value="jdbc:mysql://<IP>:<Port>/sonar?useUnicode=true&characterEncoding=utf8" />
<!-- Driver name-->
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<!-- database user name -->
<property name="sonar.jdbc.username" value="test" />
<!-- database password -->
<property name="sonar.jdbc.password" value="test" />
<!-- url on which sonar is running-->
<property name="sonar.host.url" value="http://<IP>:<Port>" />
<!-- project key -->
<property name="sonar.projectKey" value="${mysonar.organizationName}:${sonar.projectName}" />
<!-- project version-->
<property name="sonar.projectVersion" value="1.0" />
<!-- location source files -->
<property name="sonar.sources" value="${src.home}/main/java" />
<!-- location of binaries after compilation-->
<property name="sonar.binaries" value="${basedir}/output"/>
<!-- location of sonar library-->
<sonar:sonar xmlns:sonar="antlib:org.sonar.ant">
</sonar:sonar>
</target>
Note: Make sure that location you specify are correct you can give absolute path as well.

Blackberry Apps - Importing a code-signed jar into an application project

I'm working on a library project that Blackberry Java developers can import into their projects. It uses protected RIM APIs which require that it be code-signed, which I have done. But, I can't get my Jar imported and working with a simple helloWorld app. I'm using the eclipse plug-in Blackberry-JDE.
EDIT : Solution found....
since I found the solution I removed the things I've tried, leaving only the solution ...
BUILDING THE SDK/Libary (use BB-ANT-TOOLS, either in eclipse or standalone)
steps:
A) I had to build my SDK's jar as an 'cldc' application not as a 'library'
project, using BB-ANT-TOOLS. This solved most of the issues I had above.
B) I then added an ANT task to take the resulting JAR from step A and
do the following:
unzip it,
edit the manifest file to remove the line "MicroEdition-Profile: MIDP-2.0" -- This line causes an error when you try to mark the jar for export.
then re-zipped the jar.
NOTE: I wrote a chopped down BB-ANT-TOOLS ant script to show how you could use
it to do these two steps above. The script is included below.
Consuming the SDK jar as an end-user or in your own project.
Then to integrate the jar in bb-eclipse you do the following:
A) Add the jar to the BuildPath
B) under "Java Build Path" on the "Order and Export" tab, Select the jar for
export. This causes rapc to build the jar into the COD file, so that you only
have one COD at the end.
now when a user builds this project the jar become integrated into the final
cod file, and it's very easy to deliver to the phone or sim.
<?xml version="1.0" encoding="UTF-8"?>
<project name="XXXXXMobileLib" default="full" basedir=".">
<description>
Description: Builds the BBLIB. Uses bb-ant-tools to build, sign and package for blackberry.
</description>
<taskdef resource="bb-ant-defs.xml" classpath="BIN/BB_ANT_lib/bb-ant-tools.1.x.x.jar" />
<property environment="env" />
<!-- User defined Vars -->
<property name="builderRoot" value="." />
<property name="SIG_PASSWORD" value="XXXXXXXXX" />
<property name="javaHome" value="${env.JAVA_HOME}" />
<echo>${javaHome}</echo>
<property name="jdehome" value="${env.BBJDE_HOME}\" />
<property name="simulator" value="${jdehome}\simulator" />
<property name="bin" value="${jdehome}\bin" />
<property name="releaseBuildOut" value="${builderRoot}\release_out\" />
<property name="srcBuildOut" value="${builderRoot}\srcBuild_out\" />
<property name="JarFixTemp" value="${builderRoot}\.tempZip\" />
<property name="buildVersion" value="${env.BUILD_VERSION}" />
<property name="application_id" value="com.XXXXX.foo.bar.${buildVersion}" />
<property name="application_name" value="XXXXX BBLIB v${buildVersion}" />
<property name="application_desc" value="XXXXX BBLIB v${buildVersion}" />
<property name="application_vendor" value="XXXXX" />
<property name="applicaiton_filename" value="XXXXXBBLIB${buildVersion}" />
<property name="applicaiton_srcs" value="${builderRoot}/src_in_location/" />
<property name="zipOutName" value="XXXXX-${buildVersion}BBLIB.zip" />
<property name="zipOutNameJavadocs" value="XXXXX-${buildVersion}BBLIBjavadoc.zip" />
<property name="jde.home" location="${jdehome}" />
<!--
MAIN ENTRY TARGET.
-->
<target name="full" depends="clean,javadoc,buildRIM,FixJarManifest,sign,distribute" />
<target name="FixJarManifest">
<tstamp/>
<mkdir dir="${JarFixTemp}"/>
<unzip src="${builderRoot}/release_out/${applicaiton_filename}.jar" dest="${JarFixTemp}"/>
<delete dir="${builderRoot}/release_out/${applicaiton_filename}.jar"/>
<!-- For some reason rapc puts this line into the manifest file, but it breaks the JDE plug-in when you try to
set the jar for export. Giving an error like this "Project {0} missing......"
To avoid having an empty line in the manifest, Im just injecting a new attribute BuildTime-->
<replace file="${JarFixTemp}/META-INF/MANIFEST.MF" token="MicroEdition-Profile: MIDP-2.0" value="Build-Time: ${DSTAMP}-${TSTAMP}"/>
<zip destfile="${builderRoot}/release_out/${applicaiton_filename}.jar"
basedir="${JarFixTemp}"
/>
<delete dir="${JarFixTemp}"/>
</target>
<!-- Cleanup any existing files in the outdir -->
<target name="clean">
<delete>
<fileset dir="${releaseBuildOut}" includes="**" />
</delete>
</target>
<!-- Generate the Javadocs -->
<target name="javadoc">
<javadoc access="public" destdir="${releaseBuildOut}/JavaDocs" author="true" version="true" use="true" defaultexcludes="yes" excludepackagenames="net.rim.*" windowtitle="FOO_BAR">
<fileset dir="${applicaiton_srcs}/XXXXXMobileLib">
<include name="src/**/*.java" />
</fileset>
</javadoc>
<zip destfile="${releaseBuildOut}/${zipOutNameJavadocs}" basedir="${releaseBuildOut}/JavaDocs" />
<delete dir="${releaseBuildOut}/JavaDocs"/>
</target>
<target name="buildRIM" description="Builds Project">
<rapc jdehome="${jdehome}" jdkhome="${javaHome}" destdir="${releaseBuildOut}" output="${applicaiton_filename}" quiet="false">
<!-- Building as a cldc applicaiton, so it can be packaged up with our final cod, as a single cod -->
<jdp type="cldc"
title="${application_desc}"
vendor="${application_vendor}"
version="${buildVersion}"
description="${application_desc}"
arguments=""
systemmodule="false"
runonstartup="false"
startuptier="7"
ribbonposition="0">
</jdp>
<src>
<fileset dir="${applicaiton_srcs}/MobileLib">
<include name="src/**/*.java" />
</fileset>
</src>
</rapc>
</target>
<target name="sign" depends="clean,buildRIM">
<sigtool password="${SIG_PASSWORD}">
<fileset dir="${releaseBuildOut}" includes="*.cod" />
</sigtool>
<echo>Contents of the signingtool's logfile: </echo>
<echo file="LogFile.txt" />
</target>
<!-- build and distribute the jar -->
<target name="distribute" depends="buildRIM" description="generate the distribution">
<alx destdir="${releaseBuildOut}" filename="${applicaiton_filename}.alx">
<application id="${application_id}" name="${application_name}">
<codset>
<fileset dir="${releaseBuildOut}" includes="*.cod" />
</codset>
</application>
</alx>
<!-- Create release zip -->
<delete file="${releaseBuildOut}/${zipOutName}" />
<zip destfile="${releaseBuildOut}/${zipOutName}">
<!-- zip up the BB jar and drop it for distribution -->
<zipfileset dir="${releaseBuildOut}" includes="**/*.jar" />
</zip>
<move todir="${releaseBuildOut}/UNUSED_BUILD_OUTPUT_FILES/"><!-- move unwanted files, leaving the zip behind -->
<fileset dir="${releaseBuildOut}">
<include name="**/*.*"/>
<exclude name="**/*.zip"/>
</fileset>
</move>
</target>
</project>
I have used your steps A & B to create a 'library' - thanks.
The latest Eclipse plugin for Blackberry (1.3.0.201102031007-19) has a "Blackberry | Package Project" command. I used this to create the jar file (it put it in a 'deliverables' folder in the project).
I then changed the manifest as you suggest to remove MIDP line (which apparently is a known bug). Finally, I followed the steps to add and deploy the lib to my project. (These, btw, are the same steps to adding the Banner / advertising library - very easy.)
I too have a stand-alone / external build script process that uses bb-ant-tools. I recently added the 'external library jar' feature to accommodate this. But using the new feature in Eclipse makes me question if I need to maintain my command-line build scripts as the GUI now does it for me.
The key for me was to switch the build of my library project to a "Blackberry Application" (e.g. CDLC app) as per your instructions. With it set as a 'Library' I was getting that "eviscerated" error.
Thanks for your post.

Resources