In a comment to my posting Deploy task bug in oc4j 10.1.3 dp4, art_usa asked for some help deploying to oc4j using ant. The following example works for me.
First the Ant build.xml file itself:
<?xml version="1.0" encoding="windows-1252" ?>
<project default="all" xmlns:oracle="antlib:oracle"
xmlns="antlib:org.apache.tools.ant"
xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
<property file="build.properties"/>
<!--
============================================================================
== properties
============================================================================
-->
<!-- directories -->
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
<property name="log.dir" value="log"/>
<property name="web.dir" value="public_html"/>
<property name="deploy.dir" value="deploy"/>
<property name="doc.dir" value="doc"/>
<!-- deliverables -->
<property name="webjar.file" value="${app.name}-web.jar"/>
<property name="war.file" value="${app.name}-web.war"/>
<property name="ejbjar.file" value="${app.name}-ejb.jar"/>
<property name="ear.file" value="${app.name}.ear"/>
<!--
============================================================================
== class path
============================================================================
-->
<path id="class.path">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${classes.dir}"/>
</path>
<!--
============================================================================
== init
============================================================================
-->
<target name="init">
<tstamp/>
<mkdir dir="${log.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>
<!--
============================================================================
== compile
============================================================================
-->
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}"
classpathref="class.path"/>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!--
============================================================================
== war
============================================================================
-->
<target name="war" depends="compile">
<war destfile="${deploy.dir}/${war.file}" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${classes.dir}">
<include name="**/*.class"/>
<exclude name="test/**/*.class"/>
</fileset>
<fileset dir="${web.dir}">
<include name="**/*.jspx"/>
<include name="**/*.html"/>
<include name="WEB-INF/*.xml"/>
</fileset>
<lib dir="lib">
<exclude name="ivy-1.1.jar"/>
<exclude name="ejb.jar"/>
<exclude name="ejb30.jar"/>
<exclude name="junit.jar"/>
<exclude name="oc4jclient.jar"/>
</lib>
</war>
</target>
<!--
============================================================================
== ejb jar
============================================================================
-->
<target name="ejb" depends="compile">
<jar destfile="${deploy.dir}/${ejbjar.file}">
<fileset dir="${classes.dir}">
<include name="**/model/**/*.class"/>
<exclude name="test/**/*.class"/>
</fileset>
</jar>
</target>
<!--
============================================================================
== Ear
============================================================================
-->
<target name="ear" depends="war,ejb">
<ear destfile="${deploy.dir}/${ear.file}"
appxml="${classes.dir}/META-INF/application.xml">
<fileset dir="${deploy.dir}/" includes="${war.file}"/>
<fileset dir="${deploy.dir}/" includes="${ejbjar.file}"/>
</ear>
</target>
<!--
============================================================================
== deploy
============================================================================
-->
<target name="deploy" depends="init">
<oracle:deploy moduletype="ear" host="${oc4j.host}"
port="${oc4j.admin.port}" userid="${oc4j.admin.user}"
password="${oc4j.admin.password}"
file="${deploy.dir}/${ear.file}"
deploymentname="${app.name}"
logfile="${log.dir}/deploy-ear.log"/>
<oracle:bindWebApp host="${oc4j.host}" port="${oc4j.admin.port}"
userid="${oc4j.admin.user}"
password="${oc4j.admin.password}"
deploymentname="${app.name}" webmodule="${web.name}"
websitename="${oc4j.binding.module}"
contextroot="/${app.name}"
/>
</target>
<!--
============================================================================
== clean
============================================================================
-->
<target name="clean">
<delete quiet="true">
<fileset dir="lib" includes="**/*.jar" excludes="**/ivy-1.1.jar"/>
<fileset dir="${classes.dir}" includes="**/*"/>
<fileset dir="deploy" includes="*"/>
</delete>
</target>
<!--
============================================================================
== deploy
============================================================================
-->
<target name="all" depends="clean,ear,deploy"/>
</project>
Next the build.properties file:
app.name=test1 web.name=test1-web oc4j.binding.module=default-web-site oc4j.admin.port=23791 oc4j.admin.user=oc4jadmin oc4j.http.port=8888 oc4j.admin.password=admin oc4j.host=localhost java.home=c:\\Program Files\\Java\\jdk1.5.0_01 oracle.home=c:\\programs\\oracle\\oc4j1013-dp4
And finally a shell script to start ant.
set JAVA_HOME=c:\Program Files\Java\jdk1.5.0_01 set ANT_HOME=c:\programs\oracle\oc4j1013-dp4\ant set ORACLE_HOME=c:\programs\oracle\oc4j1013-dp4 set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH% %ANT_HOME%\bin\ant %1 %2 %3

August 18th, 2005 at 02:17:40
Thank you for the posting. I appreciate the response, I tried using the files you have posted. I did have to modify some parameters to reflect my values for them in the property file. But it now comes back with a different error when I do a deploy from the ant build.xml file.
${deploy_message} ${dirbase}/${earfile} to
${oc4j.host}:${oc4j.admin.port} with
${oc4j.admin.user}/${oc4j.admin.password}
property file build.properties has the foll:
oracle.home=${env.ORACLE_HOME}
oc4j.home=${env.ORACLE_HOME}
java.home=${env.JAVA_HOME}
oc4j.host=localhost
oc4j.http.port=7777
oc4j.admin.port=23791
oc4j.admin.user=oc4jadmin
oc4j.admin.password=password1
oc4j.binding.module=default-web-site
db.host=${env.DB_HOST}
db.sid=${env.DB_SID}
db.port=${env.DB_PORT}
project_name=HelloWorldWeb
Now throws the error –
deploy:
[echo] Deploying ear file C:\work\HelloWorldWeb/HelloWorldWeb.ear to
[echo] localhost:23791 with
[echo] oc4jadmin/password1
java.lang.InstantiationException: Error communicating with server: Lookup error: oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
javax.naming.NamingException: Lookup error: oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
oracle.oc4j.security.KeyExchange$KeyExchangeException [Root exception is oracle.oc4j.security.KeyExchange$KeyExchangeException]
at com.oracle.naming.J2EEContext.create(J2EEContext.java:99)
at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getApplicationContext(ApplicationClientInitialContextFactory.java:82)
at oracle.j2ee.naming.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:75)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:197)
at oracle.oc4j.admin.jmx.client.CoreRemoteMBeanServer.fetchMBeanServerEjbRemote(CoreRemoteMBeanServer.java:394)
at oracle.oc4j.admin.jmx.client.CoreRemoteMBeanServer.(CoreRemoteMBeanServer.java:116)
at oracle.oc4j.admin.management.mejb.MEjb.(MEjb.java:108)
at oracle.oc4j.admin.management.mejb.MEjb.getMBeanServer(MEjb.java:153)
at oracle.oc4j.admin.management.mejb.MEjbFactory.getManagement(MEjbFactory.java:54)
at oracle.ant.taskdefs.deploy.JSR88DeployUtil.getMEjb(JSR88DeployUtil.java:42)
at oracle.ant.taskdefs.deploy.JSR88BaseTask.initializeDeploymentManager(JSR88BaseTask.java:265)
at oracle.ant.taskdefs.deploy.JSR88BaseTask.execute(JSR88BaseTask.java:81)
at oracle.ant.taskdefs.deploy.JSR88Deploy.execute(JSR88Deploy.java:56)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: oracle.oc4j.rmi.OracleRemoteException: Lookup error: oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
javax.naming.NamingException: Lookup error: oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
oracle.oc4j.security.KeyExchange$KeyExchangeException [Root exception is oracle.oc4j.security.KeyExchange$KeyExchangeException]
at oracle.oc4j.deployment.ApplicationClientResourceFinder.lookupResourceFinder(ApplicationClientResourceFinder.java:83)
at oracle.oc4j.deployment.ApplicationClientResourceFinder.getFinder(ApplicationClientResourceFinder.java:95)
at oracle.oc4j.deployment.ApplicationClientResourceFinder.getLocation(ApplicationClientResourceFinder.java:60)
at oracle.oc4j.deployment.ApplicationClientResourceFinder.getEjbBinding(ApplicationClientResourceFinder.java:38)
at com.oracle.naming.J2EEContext.addEJBReferenceEntries(J2EEContext.java:519)
at com.oracle.naming.J2EEContext.create(J2EEContext.java:92)
… 23 more
Caused by: javax.naming.NamingException: Lookup error: oracle.oc4j.security.KeyExchange$KeyExchangeException; nested exception is:
oracle.oc4j.security.KeyExchange$KeyExchangeException [Root exception is oracle.oc4j.security.KeyExchange$KeyExchangeException]
at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:54)
at oracle.oc4j.deployment.ApplicationClientResourceFinder.lookupResourceFinder(ApplicationClientResourceFinder.java:81)
… 28 more
Caused by: oracle.oc4j.security.KeyExchange$KeyExchangeException
at oracle.oc4j.security.KeyExchange.toPublicKey(KeyExchange.java:147)
at oracle.oc4j.security.KeyExchange.setRemotePublicKey(KeyExchange.java:82)
at oracle.oc4j.security.ExchangingEncryptor.setRemotePublicKey(ExchangingEncryptor.java:57)
at com.evermind.server.rmi.RMIProtocol$SecureCredentials.initializeEncryptor(RMIProtocol.java:340)
at com.evermind.server.rmi.RMIProtocol$SecureCredentials.send(RMIProtocol.java:329)
at com.evermind.server.rmi.RMIProtocol.sendCredentials(RMIProtocol.java:190)
at oracle.oc4j.rmi.ClientRmiTransport.connectToServer(ClientRmiTransport.java:99)
at com.evermind.server.rmi.RMIClientConnection.connect(RMIClientConnection.java:610)
at com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:150)
at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:231)
at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:44)
… 29 more
Caused by: java.security.NoSuchAlgorithmException: DH KeyFactory not available
at java.security.KeyFactory.(KeyFactory.java:108)
at java.security.KeyFactory.getInstance(KeyFactory.java:135)
at oracle.oc4j.security.KeyExchange.toPublicKey(KeyExchange.java:144)
… 39 more
[oracle:deploy] Unable to create Deployment Manager
BUILD FAILED
C:\work\HelloWorldWeb\build.xml:92: error getting handle to JMX MBean Server
Total time: 2 seconds
August 18th, 2005 at 09:05:45
The last error in your stak is “java.security.NoSuchAlgorithmException: DH KeyFactory not available”. According to JSSE Reference Guide for the JDK 5.0 (http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html) the DH KeyFactory should be in sunjce_provider.jar. (On my system this file is located in c:\Program Files\Java\jre1.5.0_04\lib\ext). Looks like this jar file cannot be found.
August 25th, 2005 at 16:27:05
I’m having trouble running this script from JDeveloper10g. When I try to run the script it complains about the prescence of the xmlns:oracle=”antlib:oracle” attribute at the top of the script. When I run it from the command-line (as I intend to for real) then Ant complains that it can’t create task of type ‘Deploy’ or words to that effect.
Where do I find the necessary task definition, and what do I do about the xmlns problem?
Thanks in advance for your help
Angus
August 26th, 2005 at 09:26:42
You are probably not using the ant version which is included with oc4j 10.1.3 developer preview 4.
* The xmlns:oracle part is supported since ant 1.6, but jdeveloper 10g (10.1.2) ships with ant 1.5.4.
* To be able to create the deploy task you need ant as included with oc4h 10.1.3 dp4.
Hope this helps.
October 11th, 2005 at 18:20:27
I’m experiencing the same problem. I’m using ant-1.6.5 with Oracle Application Server 10g 9.0.4.0.0.
Any workarounds?
April 20th, 2006 at 19:07:36
Hello there! I’m trying to get the ant-oracle to work on the eclipse env. Is it possible, better if no eclipse ant runtime need to be modified.
Best regards
May 8th, 2006 at 11:51:03
Hello.
Thanks for interesting post. I have tried it from Eclipse. I have a problem though. I get the error:
build.xml:39: The type doesn’t support the “moduletype” attribute.
What i have done is import the ant-oracle-classes.jar and wsa.jar into eclipse in “Ant Home Entries (Default)”
The build file I use is the same as here, except I havent tried the creation of war as I dont need a web module and I have left out the xmlns:ivy. And I use the Eclipse installed ant.
Is there something more I need to do?
Thanks
July 14th, 2006 at 08:00:32
If you are using oc4j 10.1.3 R3 you will need to remove the atributes moduletype, host and port from oracle:deploy and host and port from oracle:bindWebApp
January 5th, 2007 at 12:15:54
Good Work
December 19th, 2007 at 05:59:34
I am using JDeveloper and oc4j embedded in it.
I need step by step process of having ant script to run my webapplication.
Please guide me as I am new in using jdev and oc4j
February 8th, 2008 at 02:54:33
Guys,
Please see if the following helps
http://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28951/anttasks.htm
February 14th, 2008 at 18:20:51
Is ther a way to redeploy only the web module of a ear using the ant tasks?
I’m talking about an EAR that was published, and then I just changed the web-module and want to deploy just it.
March 11th, 2008 at 22:32:10
is ant the only way to deploy? I am trying to deploy with an application create for a customer
June 13th, 2008 at 12:47:48
In the oracle application server 10g admin guide you can find a description how to deploy an ear file using ant, or as an alternative using admin.jar
I made a shell script using admin.jar, the correct URI was the most difficult part for me, but everything works fine, we use it a lot, even in a clustered environment with a modified URI
July 23rd, 2008 at 16:01:34
hello Maurits, or whoever knows please.
How can i construct correct deployerURI??? It is making me trouble..
December 19th, 2008 at 22:03:37
Good work.. it was very helpful.
August 21st, 2010 at 10:40:36
Hello,
Any idea why I get error
Could not create task or type of type: antlib:oracle:createJDBCConnectionPool.
Ant could not find the task or a class this task relies upon.
September 2nd, 2010 at 15:50:43
I saw this on another post and it made me smile
Does the noise in my head bother you?