How do I run the appclient
outside of the IDE? While it seems possible to run stand-alone JNDI lookup apps from the CLI with appclient
, it doesn't appear to work for ACC clients. However, it should be possible:
Running an Application Client
Using the appclient Script To run an application client, you can launch the ACC using the appclient script, whether or not Java Web Start is enabled.
GlassFish Server Open Source Edition Application Development Guide Release 4.0 Developing Java Clients 10-15 page 186
Steps:
1.) created an
@Remote
interface as a Java SE library API2.) created an Enterprise Application with an ejb module; add the interface API
3.) in the ejb module, implement the
@Remote
interface4.) create an ACC app; add the interface API; add to the Enterprise Application
5.) insert the ejb from the IDE
6.) deploy the EAR and then run the ACC client from the IDE
This is adapted from Creating and Running an Application Client on the GlassFish Server.
running with ant, "ant run" from the CLI:
-run:
[java] 2
run:
BUILD SUCCESSFUL
Total time: 28 seconds
thufir@dur:~/NetBeansProjects/SingletonACC$
which is the correct output, in this case. (Each time the client runs, the integer increases by one.)
I've looked through the ant files, but wasn't able to decipher what "ant run" does in this case:
<!--
=================
EXECUTION SECTION
=================
-->
<target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros,-run-pregfv3,-run" description="Run a main class." name="run"/>
<target if="j2ee.appclient.tool.args" name="-run-pregfv3">
<carproject:run-appclient-pregfv3/>
</target>
<target name="-run" unless="j2ee.appclient.tool.args">
<carproject:run-appclient/>
</target>
<target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros,-run-single-pregfv3,-run-single" description="Run a single class." name="run-single"/>
<target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros" name="-run-single" unless="j2ee.appclient.tool.args">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<carproject:run-appclient serverparams="${j2ee.appclient.tool.jvmoptions.class}${run.class}"/>
</target>
<target depends="dist,run-deploy,-as-retrieve-option-workaround,-init-run-macros" if="j2ee.appclient.tool.args" name="-run-single-pregfv3">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<carproject:run-appclient-pregfv3/>
</target>
<target depends="init" name="-init-run-macros">
<macrodef name="run-appclient" uri="http://www.netbeans.org/ns/car-project/1">
<attribute default="${application.args.param}" name="args"/>
<attribute default="${j2ee.appclient.tool.jvmoptions}${client.jar}" name="serverparams"/>
<element name="customize" optional="true"/>
<sequential>
<java dir="${basedir}" fork="true" jar="${client.jar}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="@{serverparams}"/>
<jvmarg line="${run.jvmargs.param}"/>
<arg line="@{args}"/>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper from="run-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<env key="APPCPATH" path="${javac.classpath}"/>
<sysproperty key="java.system.class.loader" value="org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"/>
<customize/>
</java>
</sequential>
</macrodef>
<macrodef name="run-appclient-pregfv3" uri="http://www.netbeans.org/ns/car-project/1">
<element name="customize" optional="true"/>
<sequential>
<java classname="${j2ee.appclient.tool.mainclass}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${j2ee.appclient.tool.jvmoptions}"/>
<jvmarg line="${run.jvmargs.param}"/>
<arg line="${j2ee.appclient.tool.args}"/>
<arg line="-client ${client.jar}"/>
<arg line="${application.args.param}"/>
<classpath>
<path path="${j2ee.platform.classpath}:${j2ee.appclient.tool.runtime}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper from="run-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>
<target if="j2ee.appclient.mainclass.args" name="-as-retrieve-option-workaround" unless="j2ee.clientName">
<property name="client.jar" value="${dist.dir}/SingletonACCClient.jar"/>
<sleep seconds="3"/>
<copy failonerror="false" file="${wa.copy.client.jar.from}/SingletonACC/SingletonACCClient.jar" todir="${dist.dir}"/>
<copy failonerror="false" flatten="true" todir="${dist.dir}/">
<fileset dir="${wa.copy.client.jar.from}/SingletonACC" includes="**/SingletonACCClient.jar"/>
</copy>
<copy flatten="true" todir="${dist.dir}/SingletonACCClient">
<fileset dir="${wa.copy.client.jar.from}/SingletonACC" includes="**/*.*ar"/>
</copy>
<copy failonerror="false" flatten="false" todir="${dist.dir}/SingletonACCClient">
<fileset dir="${dist.dir}/gfdeploy/SingletonACC" includes="**/*.jar"/>
</copy>
</target>
<target name="pre-run-deploy">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="post-run-deploy">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-pre-nbmodule-run-deploy">
<!-- Empty placeholder for easier customization. -->
<!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. -->
</target>
<target name="-post-nbmodule-run-deploy">
<!-- Empty placeholder for easier customization. -->
<!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. -->
</target>
<target name="-run-deploy-am">
<!-- Task to deploy to the Access Manager runtime. -->
</target>
<target depends="init,compile,dist,pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,post-run-deploy,-do-update-breakpoints" name="run-deploy"/>
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
<target name="-init-deploy-ant" unless="netbeans.home">
<property name="deploy.ant.archive" value="${dist.jar}"/>
<property name="deploy.ant.resource.dir" value="${resource.dir}"/>
<property name="deploy.ant.enabled" value="true"/>
</target>
<target depends="init,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant" name="run-undeploy"/>
<target if="netbeans.home" name="-run-undeploy-nb">
<fail message="Undeploy is not supported from within the IDE"/>
</target>
<target depends="run-deploy,-init-display-browser,-display-browser-nb,-display-browser-cl" name="run-display-browser"/>
<target if="do.display.browser" name="-init-display-browser">
<condition property="do.display.browser.nb">
<isset property="netbeans.home"/>
</condition>
<condition property="do.display.browser.cl">
<and>
<isset property="deploy.ant.enabled"/>
<isset property="deploy.ant.client.url"/>
</and>
</condition>
</target>
<target if="do.display.browser.nb" name="-display-browser-nb">
<nbbrowse url="${client.url}"/>
</target>
<target if="do.display.browser.cl" name="-get-browser" unless="browser">
<condition property="browser" value="rundll32">
<os family="windows"/>
</condition>
<condition else="" property="browser.args" value="url.dll,FileProtocolHandler">
<os family="windows"/>
</condition>
<condition property="browser" value="/usr/bin/open">
<os family="mac"/>
</condition>
<property environment="env"/>
<condition property="browser" value="${env.BROWSER}">
<isset property="env.BROWSER"/>
</condition>
<condition property="browser" value="/usr/bin/firefox">
<available file="/usr/bin/firefox"/>
</condition>
<condition property="browser" value="/usr/local/firefox/firefox">
<available file="/usr/local/firefox/firefox"/>
</condition>
<condition property="browser" value="/usr/bin/mozilla">
<available file="/usr/bin/mozilla"/>
</condition>
<condition property="browser" value="/usr/local/mozilla/mozilla">
<available file="/usr/local/mozilla/mozilla"/>
</condition>
<condition property="browser" value="/usr/sfw/lib/firefox/firefox">
<available file="/usr/sfw/lib/firefox/firefox"/>
</condition>
<condition property="browser" value="/opt/csw/bin/firefox">
<available file="/opt/csw/bin/firefox"/>
</condition>
<condition property="browser" value="/usr/sfw/lib/mozilla/mozilla">
<available file="/usr/sfw/lib/mozilla/mozilla"/>
</condition>
<condition property="browser" value="/opt/csw/bin/mozilla">
<available file="/opt/csw/bin/mozilla"/>
</condition>
</target>
<target depends="-get-browser" if="do.display.browser.cl" name="-display-browser-cl">
<fail unless="browser">
Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
</fail>
<property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/>
<echo>Launching ${browse.url}</echo>
<exec executable="${browser}" spawn="true">
<arg line="${browser.args} ${browse.url}"/>
</exec>
</target>
<target depends="dist" name="verify">
<nbverify file="${dist.jar}"/>
</target>
<target depends="init,compile-single" name="run-main">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<carproject:java classname="${run.class}"/>
</target>
<target depends="init" if="netbeans.home" name="-do-update-breakpoints">
<carproject:nbjpdaappreloaded/>
</target>
How can I replicate "ant run" outside of the IDE?
note that SingletonAcc
is deployed individually, even though it's also part of the SingletonQueue
Enterprise Application, which also has an appclient
.
thufir@dur:~/NetBeansProjects/SingletonACC$
thufir@dur:~/NetBeansProjects/SingletonACC$ /home/thufir/glassfish-4.1/glassfish/bin/asadmin list-applications
SingletonQueue <ear, appclient, ejb>
SingletonACC <appclient>
Command list-applications executed successfully.
thufir@dur:~/NetBeansProjects/SingletonACC$