how to run a remote Enterprise Client Application without ant
September 13, 2014 | Posted by forumadmin under TechQns |
Comments off
|
In Netbeans, I clicked an Enterprise Application Client, added a few source code files and a jndi.properties
file. It runs with the expected output, just echoing the properties file to the console. How would I deploy this application onto a different computer?
This application is intended to invoke an EJB remotely. At the moment, I’m simply trying to understand the packaging. I don’t see an EAR file. In any event, as it’s just a client, I would hope to see just a JAR and specifically not an EAR file.
The application is named RemoteLookup
and seems to result, as I would expect, in RemoteLookup.jar
. What is RemoteLookupClient.jar
? It looks to have the critical sun-application-client.xml
file:
thufir@dur:~/NetBeansProjects/RemoteLookup$
thufir@dur:~/NetBeansProjects/RemoteLookup$ ll dist/
total 36
drwxrwxr-x 3 thufir thufir 4096 Sep 12 23:35 ./
drwxrwxr-x 7 thufir thufir 4096 Sep 12 23:35 ../
drwxrwxr-x 2 thufir thufir 4096 Sep 12 23:35 RemoteLookupClient/
-rw-rw-r-- 1 thufir thufir 12934 Sep 12 23:35 RemoteLookupClient.jar
-rw-rw-r-- 1 thufir thufir 6193 Sep 12 23:35 RemoteLookup.jar
thufir@dur:~/NetBeansProjects/RemoteLookup$
thufir@dur:~/NetBeansProjects/RemoteLookup$ jar -tf dist/RemoteLookup.jar
META-INF/
META-INF/MANIFEST.MF
dur/
dur/bounceme/
dur/bounceme/net/
dur/bounceme/net/remotelookup/
META-INF/application-client.xml
dur/bounceme/net/remotelookup/MyProps.class
dur/bounceme/net/remotelookup/MyRemote.class
dur/bounceme/net/remotelookup/RemoteLookup.class
jndi.properties
thufir@dur:~/NetBeansProjects/RemoteLookup$
thufir@dur:~/NetBeansProjects/RemoteLookup$ jar -tf dist/RemoteLookupClient.jar
META-INF/MANIFEST.MF
META-INF/application-client.xml
META-INF/glassfish-application-client.xml
META-INF/sun-application-client.xml
org/glassfish/appclient/client/AppClientFacade.class
META-INF/javaee.client.policy
META-INF/restrict.client.policy
thufir@dur:~/NetBeansProjects/RemoteLookup$
clean and run:
-do-clean:
[delete] Deleting directory /home/thufir/NetBeansProjects/RemoteLookup/build
[delete] Deleting directory /home/thufir/NetBeansProjects/RemoteLookup/dist
-post-clean:
clean:
BUILD SUCCESSFUL
Total time: 1 second
thufir@dur:~/NetBeansProjects/RemoteLookup$
thufir@dur:~/NetBeansProjects/RemoteLookup$ ant run
Buildfile: /home/thufir/NetBeansProjects/RemoteLookup/build.xml
-pre-init:
-pre-init-am:
-init-private:
-init-user:
-init-project:
-init-macrodef-property:
-do-init:
-post-init:
-init-check:
-init-ap-cmdline-properties:
-init-macrodef-javac-with-processors:
-init-macrodef-javac-without-processors:
-init-macrodef-javac:
-init-macrodef-test-impl:
-init-macrodef-junit-init:
-init-macrodef-junit-single:
-init-macrodef-junit-batch:
-init-macrodef-junit:
-init-macrodef-junit-impl:
Trying to override old definition of task http://www.netbeans.org/ns/car-project/1:test-impl
-init-macrodef-testng:
-init-macrodef-testng-impl:
-init-macrodef-test:
-init-macrodef-junit-debug:
-init-macrodef-junit-debug-batch:
-init-macrodef-junit-debug-impl:
-init-macrodef-test-debug-junit:
-init-macrodef-testng-debug:
-init-macrodef-testng-debug-impl:
-init-macrodef-test-debug-testng:
-init-macrodef-test-debug:
-init-macrodef-java:
-init-debug-args:
-init-macrodef-nbjpda:
-init-macrodef-debug:
-init-taskdefs:
-init-ap-cmdline-supported:
-init-ap-cmdline:
init:
-check-main-class:
-deps-module-jar:
-deps-ear-jar:
deps-jar:
-pre-pre-compile:
[mkdir] Created dir: /home/thufir/NetBeansProjects/RemoteLookup/build/jar
-pre-compile:
-copy-meta-inf:
[copy] Copying 2 files to /home/thufir/NetBeansProjects/RemoteLookup/build/jar/META-INF
-do-compile:
[mkdir] Created dir: /home/thufir/NetBeansProjects/RemoteLookup/build/empty
[mkdir] Created dir: /home/thufir/NetBeansProjects/RemoteLookup/build/generated-sources/ap-source-output
[javac] Compiling 3 source files to /home/thufir/NetBeansProjects/RemoteLookup/build/jar
[copy] Copying 1 file to /home/thufir/NetBeansProjects/RemoteLookup/build/jar
-post-compile:
compile:
-pre-dist:
library-inclusion-in-archive:
-do-dist-without-manifest:
-do-dist-with-manifest:
[mkdir] Created dir: /home/thufir/NetBeansProjects/RemoteLookup/dist
[jar] Building jar: /home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookup.jar
-do-dist:
-post-dist:
dist:
pre-run-deploy:
-pre-nbmodule-run-deploy:
-run-deploy-nb:
-init-deploy-ant:
-init-cl-deployment-env:
-parse-glassfish-web:
-parse-sun-web:
-no-parse-sun-web:
-add-resources:
-deploy-ant:
-deploy-without-pw:
[echo] Deploying dist/RemoteLookup.jar
[get] Getting: http://localhost:4848/__asadmin/deploy?path=/home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookup.jar&force=true&name=RemoteLookup
[get] To: /tmp/gfv328462420
[delete] Deleting: /tmp/gfv328462420
-deploy-with-pw:
-run-deploy-am:
-post-nbmodule-run-deploy:
post-run-deploy:
-do-update-breakpoints:
run-deploy:
-as-retrieve-option-workaround:
[copy] Copying 1 file to /home/thufir/NetBeansProjects/RemoteLookup/dist
[copy] Copying 2 files to /home/thufir/NetBeansProjects/RemoteLookup/dist/RemoteLookupClient
[copy] Warning: /home/thufir/NetBeansProjects/RemoteLookup/dist/gfdeploy/RemoteLookup does not exist.
-init-run-macros:
-run-pregfv3:
-run:
[java] Sep 12, 2014 11:35:54 PM dur.bounceme.net.remotelookup.RemoteLookup run
[java] INFO: java.naming.factory.initial com.sun.enterprise.naming.impl.SerialInitContextFactory
[java] Sep 12, 2014 11:35:54 PM dur.bounceme.net.remotelookup.RemoteLookup run
[java] INFO: java.naming.factory.url.pkgs com.sun.enterprise.naming
[java] Sep 12, 2014 11:35:54 PM dur.bounceme.net.remotelookup.RemoteLookup run
[java] INFO: java.naming.factory.state com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
run:
BUILD SUCCESSFUL
Total time: 13 seconds
thufir@dur:~/NetBeansProjects/RemoteLookup$
which is all well and good, but how do I do that on a computer not running glassfish? I infer that this script depends upon glassfish, whereas I want to strictly do a RMI on a @remote
EJB across the network — that is, remotely. What exactly are the JAR dependencies for this EJB client app? I understand that it may need some classes from Glassfish , but it doesn’t seem to package those dependencies as a JAR in a lib
folder as I would expect.
Why does running the project this way not result in an exception, whereas running the JAR directly gives errors? What’s the difference — “ant run” starts glassfish as well as runs the app?
The client shouldn’t need Glassfish, if this is indeed starting Glassfish…
the ant-deploy.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<project default="-deploy-ant" basedir=".">
<target name="-init-cl-deployment-env" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}" />
<available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
<available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
<available file="${deploy.ant.resource.dir}" property="has.setup"/>
<tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
</target>
<target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
<tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.sun.web}">
<replacetoken><![CDATA[<sun-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.sun.web}" validate="false">
</xmlproperty>
<delete file="${temp.sun.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
<isset property="sun-web-app.context-root"/>
</condition>
</target>
<target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
<tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
<!-- The doctype triggers resolution which can fail -->
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
<replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
</replace>
<replace file="${temp.gf.web}">
<replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
<replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
</replace>
<xmlproperty file="${temp.gf.web}" validate="false">
</xmlproperty>
<delete file="${temp.gf.web}"/>
<condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
<condition property="deploy.context.root.argument" value="&contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
<isset property="glassfish-web-app.context-root"/>
</condition>
</target>
<target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
<property name="deploy.context.root.argument" value=""/>
</target>
<target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
<tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
<mkdir dir="${gfv3.resources.dir}"/>
<mkdir dir="${gfv3.resources.dir}/META-INF"/>
<copy todir="${gfv3.resources.dir}/META-INF">
<fileset dir="${deploy.ant.resource.dir}"/>
</copy>
<jar destfile="${deploy.ant.archive}" update="true">
<fileset dir="${gfv3.resources.dir}"/>
</jar>
<delete dir="${gfv3.resources.dir}"/>
</target>
<target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
<antcall target="-deploy-without-pw"/>
<antcall target="-deploy-with-pw"/>
</target>
<target name="-deploy-without-pw" unless="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&force=true&name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-deploy-with-pw" if="gfv3.password">
<echo message="Deploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&force=true&name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
<antcall target="-undeploy-without-pw"/>
<antcall target="-undeploy-with-pw"/>
</target>
<target name="-undeploy-without-pw" unless="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
<target name="-undeploy-with-pw" if="gfv3.password">
<echo message="Undeploying ${deploy.ant.archive}"/>
<tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
dest="${gfv3.results.file}"/>
<delete file="${gfv3.results.file}"/>
</target>
</project>
When I try to run the JAR directly, I just get:
thufir@dur:~/NetBeansProjects/RemoteLookup$
thufir@dur:~/NetBeansProjects/RemoteLookup$ java -jar dist/RemoteLookup.jar
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: java.naming.factory.initial com.sun.jndi.cosnaming.CNCtxFactory
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: java.naming.provider.url server.local:1199
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: java.naming.factory.url.pkgs org.jboss.naming:org.jnp.interfaces
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: java.naming.security.principal user
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: remote net.bounceme.ix.Foo
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup run
INFO: java.naming.security.credentials password
Sep 12, 2014 11:56:53 PM dur.bounceme.net.remotelookup.RemoteLookup main
SEVERE: Invalid URL: server.local:1199
javax.naming.ConfigurationException: Invalid URL: server.local:1199 [Root exception is java.net.MalformedURLException: unknown protocol: server.local]
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:453)
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:245)
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:105)
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:49)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:192)
at dur.bounceme.net.remotelookup.RemoteLookup.run(RemoteLookup.java:32)
at dur.bounceme.net.remotelookup.RemoteLookup.main(RemoteLookup.java:18)
Caused by: java.net.MalformedURLException: unknown protocol: server.local
at java.net.URL.<init>(URL.java:592)
at java.net.URL.<init>(URL.java:482)
at java.net.URL.<init>(URL.java:431)
at com.sun.jndi.cosnaming.CNCtx.getStringifiedIor(CNCtx.java:440)
... 9 more
thufir@dur:~/NetBeansProjects/RemoteLookup$
Which I interpret to mean that because Glassfish isn’t running that there’s a connection problem. In and of itself, that’s fine, Glassfish isn’t running and there’s nothing deployed to it anyhow.
However, why the inconsistency?
![]() |
Asked By – Thufir | Read Answers |