Tech Forum Network

Programming, technical solutions and hot scripts
Home » TechQns » how to run a remote Enterprise Client Application without ant

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="&amp;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="&amp;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}&amp;force=true&amp;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}&amp;force=true&amp;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    

More Related Questions

  • javax.naming.NameNotFoundException: MyBean#MyBean not found I have a multi module maven project which contains a jar module (models), two EJB modules (repository, service) and a web module. The first thing that may cause the problem is that I don't […]
  • Glassfish schedule(timer) exception i am trying repeat this tutorial on Glassfish 4 and java EE7. So i created simple WebApp with maven in Netbeans. I created simple class: import java.util.Date; import […]
  • Thread in App Server I have a Java program/thread that I want to deploy into an App Server (glassfish). The thread should run as a "service" that starts when the App server starts and stops when the App […]
  • How do I access Glassfish V3 Administration Console Website from a remote host I have installed Glassfish v3 on a standalone server running ubuntu-server 9.10. I can open the Admin website if I use a browser running on the server by browsing to: http:// […]
  • How to upgrade JDK 1.6 to a higher version to run Glassfish? I have NetBeans IDE 7.3.1 installed on my mac and trying to start Glassfish server but it shows the following error, GlassFish server could not be started with JDK 1.6 (Default). Please […]
  • EJB Local/Remote interface within separate applications in a single application server instance Assume a single application server instance that has two EARs deployed. The first EAR invokes EJBs from the second EAR using remote EJB interfaces. It is rumored that even if the […]
  • SOAP web service not working for EJB calls I am trying to create a SOAP based web service, which will call stateless EJB in other project. My configuration is Server: WAS 8.5,IDE: RAD 8.5,Java 1.6, EJB 3.1, and SOAP 1.1. When I […]
  • Determine whether class is an EJB or not – bytecode analysis I am working on a bytecode analysis project. I am using ASM library for the same. For one of the requirement, I need to determine whether .class is a EJB or Non-EJB. Since EJB has various […]
  • How to deploy multiple copies of same application on Glassfish server? I have a war and an ejb deployed on my Glassfish V3. I need to deploy another copies of these for testing purpose, how I do I go about this? I am sorry, if this question looks too […]
  • CDI inside OSGI – it doesnt see bean I have two OSGI bundles: The first contains: service, servlet, pojo The second contains: consumer (of the service). FACTS: A) I inject service (bundle 1) to consumer (bundle 2) via CDI […]
0
  
Email
Tags: ant, ejb, glassfish, java, java-ee

Comments are closed.

« Using of Spring Security in Cloud & autoscaling of web application
How to make Nvidia logo always visible before login screen? »
Tech Forum Network powered by WordPress and The Clear Line Theme