开发者

Where is sun-appserv-ant.jar for Glassfish v3

Where is sun-appserv-ant.jar in Glassfish v3

I have created a small sample EJB project and I want to use ant to deploy the application to Glassfish v3.

Ive spent a lot of time on google trying to achieve this and all ant samples seem to refer to a jar file called "sun-appserv-ant.jar" which is supposed to be located in the mod开发者_Python百科ules directory of the application server install, however, I cannot find it anywhere, nor can I seem to find the reason why, or if there is even an ant based alternative.

Thanks


The sun-appserv-ant.xml file was not brought forward with v3.

You are not completely stuck though.

You can read about the Ant exec task, which you can use to trigger asadmin commands.

If you are very adventurous, you may want to investigate the bp-project framework that is used by the sample projects that ship with the Java EE 6 SDK.

You can get a peek at the bp-project framework by looking at the code in the glassfish-samples repository.


You should add the glassfish-ant-tasks module through the GlassFish Update Tool


After much agony I found an example of how to use the V3.x ant tools here

The downside, for non-French-speakers, is that it's in French. The upside is that the Java parts are still in Java.

From what I can tell, the Ant tasks now differ significantly from what is documented by Sun (Oracle):

  1. You must use the Glassfish server update tool to get the glassfish-ant-tasks module.

  2. This will cause the file *glassfish_dir*/lib/ant/ant-tasks.jar to be downloaded. That must be included on your classpath

  3. Define an as-ant-init target in your build.xml

    <target name="as-ant-init">
        <taskdef name="sun-appserv-deploy"
            classname="org.glassfish.ant.tasks.DeployTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-undeploy"
            classname="org.glassfish.ant.tasks.UndeployTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-component"
            classname="org.glassfish.ant.tasks.ComponentTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-admin"
            classname="org.glassfish.ant.tasks.AdminTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-redeploy"
            classname="org.glassfish.ant.tasks.RedeployTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-start-server"
            classname="org.glassfish.ant.tasks.StartServerTask"
            classpath="${build-lib}/ant-tasks.jar" />
        <taskdef name="sun-appserv-stop-server"
            classname="org.glassfish.ant.tasks.StopServerTask"
            classpath="${build-lib}/ant-tasks.jar" />
    </target>
    
  4. Write the deployment target. The rules are similar to what's in the documentation, EXCEPT

    A. Remove references to the <server> element that was used in older versions.

    B. All of the attributes that would have been attached to <server> in the older version of the API are now attached directly to the containing element, such as <sun-appserv-deploy>, like so:

    <target name="deploy">
        <sun-appserv-deploy
            user="${glassfish.admin-user}"
            passwordfile="${glassfish.passwordfile}}"
            host="${glassfish.host}"
            port="${glassfish.admin-port}"
            installDir="${asinstalldir}"
            upload="true" >
    
            <component
                file="${dist.warfile}"
                name="My application"
                contextroot="${glassfish.context-root}" />
        </sun-appserv-deploy>
    </target>
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜