ANT job to invoke JDeveloper to create EAR file with specified deploy file - ant

I was asked about the possibility of creating an ANT script that could be use to copy property files (associated to target environment), create an EAR file (perhaps using JDeveloper deploy file), and deploy that EAR file to target OC4J container.
I am asking if anyone ever successfully invoking JDeveloper automatically to create the EAR file by using specified 'deploy' file by using ANT? OR is it possible to by pass invoking JDeveloper at all. Is there any sample ANT code snippet to do so, or any information/hint that could be useful.
Thanks.

If you use ADF Business Components (BC) then you must use ojdeploy. Otherwise your BC will not get validated and your deployment will fail.
ojdeploy requires JDeveloper installation (ouch!) and will produce an EAR based on JDeveloper's deployment profiles .
(Although it's an old thread, I added something cos you never know.)

I would advise against using JDevelopers for creating an EAR file because I strongly believe that a build process must be autosufficient (i.e. as few external dependencies as possible).
Using Ant, you can simply use the Ear task (remember that the Ear task is a subtask of the Zip task, i.e. you can also use zipfileset inside the ear task).
I've never used OC4J but usually the deployment of an EAR file is just a matter of copying the file into the right directory (so a simple copy task would suffice).

Check out the ojdeploy command in the jdev\bin directory it will let you use JDeveloper's depoyment profiles from a command line.

I found that all the ant tasks used by jDeveloper are in the (default) directory: C:\Oracle\Middleware\jdeveloper\bin
I believe you can copy them to a build server and use them directly
They are the files it uses when you right click and select Deploy from the interface

You can build your own JDeveloper Deployment Profile Interpreter program and generate a Ant file from the Deployment Profile. I have done it before. Tim

Related

Why is org-netbeans-modules-java-j2seproject-copylibstask.jar required failed ant build

When doing an ant build (thought jenkins) for a test project, I get the below error. As this test project will be deployed in tomcat why does the build require a netbeans specific module
Obviously I can add the jar file to a path in jenkins and then continue the build, but want to know why it needs a netbeans specific jar?
Is it because the project setup in Netbeans is wrong?
Thanks in advance.
Tony
======Error below here =========
var/lib/jenkins/workspace/DeployTest2/nbproject/build-impl.xml:797: The libs.CopyLibs.classpath property is not set up.
This property must point to
org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
of NetBeans IDE installation and is usually located at
/java/ant/extra folder.
Either open the project in the IDE and make sure CopyLibs library
exists or setup the property manually. For example like this:
ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar

Create war without manifest

I need to create a war file through ant build without a manifest file. I want the war to me created without the manifest file.
I am using tag in build.xml to create the war.
you can use <zip/> task with .war extension for destfile attribute to achieve the same result as the <war/> task (without manifest.mf).
<zip destfile="..\...\WarFile.war"basedir="..\basedir" update="true"/>
in case WarFile.war already exists, although you've written I need to create a war file , the attribute update="true" will be of use (by only updating and not overwriting the file).
All a war file is is a zip file in a specific format. That is libraries go in a particular place, class files go elsewhere, etc. The <war> task has sub-entities like <classes/> and <lib> that make configuring a war file correctly without knowing exactly where everything has to go.
However, you can correctly format the war yourself, and use <zip/>.
Why don't you want a manifest file? A manifest, if you don't specify anything, will contain nothing but the Java version used for the build, and the Ant version and won't affect the execution of your war at all.
What you can do is put useful information into the manifest. For example, we use Jenkins for our builds, and we put in the Jenkins project name and the build number which helps us understand what was included in the war.
There's no reason not to use a manifest file. And, a manifest file can contain useful information (which is accessible to the Java program too).

Deployment of Jar using Ant and OJDeploy for packaging ADF

I'm trying to Deploy a Jar File from an ANT script (with OjDeploy), which compiles successfully. But when I run the main project (Which has the Jar dependency), I get a huge incident, when I analysed the incident log, it says
"Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist"
I analysed both the jar files (One generated by the ANT script and the other generated from Jdev). I couldn't find any difference b/w Manifest of those two jars. The other folders are also the same, In other words, both are almost the same, or I'm not able to figure out the difference between the two jar files generated.
I know, I'm missing something, config of build.xml or something, but not able to figure out the exact problem.
Thanks,
Shiva Shankar
My guess is that the problem is not in the JAR file but rather in the project that consumes it.
Seems like the DB connection in that project is different than the one in your JAR project - which causes one of the tables that is needed in the DB not be found.
I figured out a way to solve the problem. Not sure what was the cause of this issue, but a couple of changes made both to JAR/EAR build scripts set the things right
While building JAR files:
Uncheck "Make this the project build file" while creating the ANT build file, while the "Include Packaging Tasks (uses OjDeploy)" must be checked.
Remove "nocompile" parameter from tag in the OjDeploy.
While Building EAR files:
Create EAR in the view controller project.
Go to the View Controller Project Properties-> Project Source Path -> Resources, remove the newly created build file dependency, which specifies that the build file is for the whole project and not for the individual project.
Remove "Project" parameter from tag in the OjDeploy. (Ensures to build for the whole application)
Remove "nocompile" parameter from tag in the OjDeploy.
These are the exhaustive set of changes, which I made to ensure the ANT files are building correctly, if you get any other errors after this EAR is deployed, then its definitely due to code, EO/VO or DB related.
Thanks for all the help!!
Shiva Shankar

cannot be found: com/jcraft/jsch/UserInfo

I am trying to use the Ant <scp> task in my buildfile. It gives me an error every time I run the target:
cannot be found: com/jcraft/jsch/UserInfo
I have read some posts that talk about having this issue with Ant 1.7. Some of the posts are talking about removing the ant-jsch.jar files from the ant_home lib. Unfortunately I can't do that as the ant_home is common across lot of other projects and I can't remove or update any jar files from the lib directory.
Is there a way that I can solve this issue purely using Ant configuration?
ant-jsch.jar contains ssh related tasks developed by Apache Ant team, while jsch.jar contains the jsch library which is the dependency of those ssh tasks.
So do a little check: check if jsch.jar is in your $ANT_HOME/lib and also check if the jar contains UserInfo.class.
If one of above happens, download the latest version of jsch.jar and put it in $ANT_HOME/lib.
I am currently using Ant 1.8.4 with a jsch.jar downloaded last year without any problem.
Update:
Check this page first:
http://ant.apache.org/manual/install.html#optionalTasks
Please note that <scp> and other ssh tasks (the ant-jsch.jar) are included in the Ant binary distribution by default. You don't need to write <taskdef> to use <scp> because it is included in Ant's lib directory by default. I recommend you to put jsch.jar in that directory with the following points:
These ssh tasks don't support classpath def, that is to say, you can't define a <classpath> pointing to jsch.jar and then reference to it in an ssh task.
Also you can put jsch.jar in any directory included in your system's CLASSPATH environment variable, but it is not a good practice.
We usually put a task and its dependency in the same directory.

TeamCity: How To enable FTP in ANT?

I have to copy files after build on a TeamCity-Agent via FTP. The orndinary buildjob works itself works fine. The triggering of a custom script finish successfull, too.
The step "copy files via ftp" fails with the following error:
[15:34:31]: copyFiles
[15:34:31]: [copyFiles] ftp
[15:34:31]: [ftp] Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig
I searched the web for a while and found many times the same answer: "You have to put commons-net.jar and jakarta-oro.jar in your ANT-plugin directory." So I downloaded these two files and copied it into C:\TeamCity\buildAgent\lib, but the error still exists.
Now the question:
Where do I have to copy these files to make FTP work? Or am I on the wrong track?
You've put the jar into the wrong place, it must be in the classpath of Ant, not in the classpath of the build agent.
You should find ant.zip file (TeamCity\WEB-INF\plugins\ant-tool\agent\ant.zip) and put the required jar (commons-net-1.4.1.jar, for example) inside ant\lib directory of the ant.zip file.
After the zip is re-packaged, TeamCity will update build agents with the new Ant version and commons-net dependency will be automatically available for Ant via its own classpath.
Note that you will have to repeat this step every time you update TeamCity to a new version.
Another option is to install Ant on build agent machines manually and configure TeamCity to use custom Ant installation (with all the required custom dependencies in the Ant's lib directory), however it's inconvenient if you have many build agents, but you will not have to repeat this step when updating TeamCity server.
Ant-net-task tool is bundled with TeamCity. This tool has jar files necessary for FTP, sshexec, scp and mail.
To use it Additional Ant command line parameters: -lib "%teamcity.tool.ant-net-tasks%" should be added.

Resources