?
Solved

How can I run a J2EE client on a machine other than locahost machine?

Posted on 2003-03-09
45
Medium Priority
?
925 Views
Last Modified: 2013-11-24
I 've developed and deployed a simple J2EE application which can run on localhost where J2EE server(Sun's RI) is running as well as cloudscape. When I run the applicaiton client I have to have both someApp.ear and someClient.jar in one directory and use the command "runclient -client someApp.ear -name -someClient", now I am wondering how I can run the client on other machines, do I need to install the same version of j2sdkee on the other machine? what files should I copy to the other machine? what environment variables should I set up for that? Is there any other way to run the client instead of using "runclient" command provided by J2sdkee?


Thanks a lot! Look forward to any help.
0
Comment
Question by:kindy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 18
  • 17
  • 8
  • +1
45 Comments
 
LVL 2

Expert Comment

by:antonsigur
ID: 8098145
I think you must install J2EE on the client computer.
You must also edit one file:
orb.properties under C:\j2sdkee1.3.1\config (or where you install j2ee)
It probably contains:
port=1050
host=localhost

Localhost should be the server computer

You could create a batch script, and let it run your client. In windows:
@runclient -client someApp.ear -name -someClient inside a cmd file.

The j2ee_home and j2ee\bin directory must be set in the environment.

I have not been running on many computers, but this did work for me, possible someone knows some shortcuts. Like you probably just need j2ee.jar and the config files +runclient batch file... but I'm not sure how to set up like that
0
 

Author Comment

by:kindy
ID: 8098203
Thank you very much for the reply. It looks so tiring to have a J2ee applicaiton/client run.  I am always wondering why there is no any easy way to do that, why do people like Java while they have to set up so many things in different directories/different config files etc. The correct deployment always seem a terrible task for me. I really hate setting up those environment variables manually, also really hate the moment when app. is compiled and deployed, but cannot run, and I don't know what's wrong with it.

You know, usually when we install a software, we just need to run a single command "setup.exe" r "install.exe", then we can use that immediately,  much easier than Java stuff....

Maybe I am just a beginner? so it seems difficult for me?-:)
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8098224
I agree, they might have better installers with theyr packages so these "must be there" environmental variables are setup right.

I'v been working on a J2EE program (running on theweb) and I hate the errors I recive when something is missing/wrong... Hard to debug...without expensive tools...

There must be að better way to run J2EE applications... there must be....
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:kindy
ID: 8098229
Thank you very much for the reply. It looks so tiring to have a J2ee applicaiton/client run.  I am always wondering why there is no any easy way to do that, why do people like Java while they have to set up so many things in different directories/different config files etc. The correct deployment always seem a terrible task for me. I really hate setting up those environment variables manually, also really hate the moment when app. is compiled and deployed, but cannot run, and I don't know what's wrong with it.

You know, usually when we install a software, we just need to run a single command "setup.exe" r "install.exe", then we can use that immediately,  much easier than Java stuff....

Maybe I am just a beginner? so it seems difficult for me?-:)
0
 
LVL 35

Expert Comment

by:girionis
ID: 8098294
 If you just want to run your client you shouldn't have to install J2EE on the client machine as well (although you do need the JVM). You only need the client jar file (and probably the .ear file - this depends on the vendor's application server implementation) and nothing else. Sure you need JNDI libraries in order to locate the EJBs but JNDI is part of the latest J2SE and you do not have to download it seperately.
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8098311
What about J2EE.JAR you will need that, won't you?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8098811
 Yes you will, sorry, I took it for granted. When I said you don't need to install J2EE I meant you do not have to install the whole package that contains the RI and Cloudsape since they are server-side components. I should have clarified it :-)
0
 

Author Comment

by:kindy
ID: 8098852
I 've copied App.ear , AppClient.jar, j2ee.jar, j2ee-ri-svc.jar to the other machine, but how about runclient.bat?
The other machine I want to run client is a Sun solaris not Windows machine, so just a copy doesn't work.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8098908
 Run the client using the "java" command instead:

  java -classpath <path to the j2ee.jar file and to your client jar file> <the client class file name>.

  For example if your client class is called "MyClient.class" and your client jar file is called "MyClientJar.ja" and your j2ee.jar and your "MyClientJar.jar" files are under the /home/kindy folder do a:

  java -classpath /home/kindy/j2ee.jar;/home/kindy/MyClientjar.jar;. Myclient
0
 

Author Comment

by:kindy
ID: 8099114
I used:
java -classpath './j2ee.jar:./myAppClient.jar' myClient -textauth

I am wondering why we didn't use App.ear? The above command failed, the following is the error message. There are tons of error messages which didn't tell us what the real problem is at all! Who designed Java??? (sorry, just feel debug a java app. is so frustrating) Thanks for help!


java.io.FileNotFoundException: .../private/tmp/config/security.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init
...
        at myClient.main(Unknown Source)
java.io.FileNotFoundException: ..../private/tmp/config/ejb.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>
...
  Warning: unable to read transaction.interoperability config property, Caught an exception.
javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/SimpleScenes at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at myClient.main(Unknown Source)

0
 
LVL 35

Expert Comment

by:girionis
ID: 8099170
 Are you trying to read from your client those files missing?
0
 

Author Comment

by:kindy
ID: 8099177
I used:
java -classpath './j2ee.jar:./myAppClient.jar' myClient -textauth

I am wondering why we didn't use App.ear? The above command failed, the following is the error message. There are tons of error messages which didn't tell us what the real problem is at all! Who designed Java??? (sorry, just feel debug a java app. is so frustrating) Thanks for help!


java.io.FileNotFoundException: .../private/tmp/config/security.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init
...
        at myClient.main(Unknown Source)
java.io.FileNotFoundException: ..../private/tmp/config/ejb.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>
...
  Warning: unable to read transaction.interoperability config property, Caught an exception.
javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/SimpleScenes at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at myClient.main(Unknown Source)

0
 

Author Comment

by:kindy
ID: 8099189
what am I missing? I use the same .ear, .jar under windows where I developed and deployed and app.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8099209
 I repeat my question. Are you, anywhere in your client code, trying to process any configuration files?

  And btw your classpaht does not need the single quotes. It should be:

java -classpath ./j2ee.jar:./myAppClient.jar myClient -textauth
0
 

Author Comment

by:kindy
ID: 8099217
what am I missing? I use the same .ear, .jar under windows where I developed and deployed and app.
0
 

Author Comment

by:kindy
ID: 8099250
here are the client code, just modified from savingsaccountclient.java in j2ee tutorial, no idea about
configuration file...

import java.util.*;
import java.math.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class myClient {

   public static void main(String[] args) {

       try {
           Context initial = new InitialContext();
           Object objref = initial.lookup("java:comp/env/ejb/SimpleScenes");

           ScenesHome home =
               (ScenesHome)PortableRemoteObject.narrow(objref,
                                            ScenesHome.class);

           Scenes scene01 = home.create("101", "scence01", "url01");        
           scene01.remove();

           Scenes scene02 = home.create("186", "scene02", "url02");        
           Scenes scene002 = home.findByPrimaryKey("186");
               System.out.println("186' sceneName " + scene002.getSceneName());    
               System.out.println("186' sceneURL " + scene002.getSceneURL());

           Scenes scene03 = home.create("145", "scene03", "sameurl");      
           Scenes scene04 = home.create("158", "scene04", "sameurl");        
           Scenes scene05 = home.create("268", "scene05", "sameurl");
       
           scene05.updateSceneURL("diffurl");

           Collection c = home.findBysceneURL("sameurl");
           Iterator i=c.iterator();

           while (i.hasNext()) {
              Scenes account = (Scenes)i.next();
              String id = (String)account.getPrimaryKey();
       
              System.out.println(id + ": ");
           }
             
           System.out.println("158's sceneName = " + scene04.getSceneName());                  
             scene04.updateSceneName("scene06");
             System.out.println("158's sceneName = " + scene04.getSceneName());    
             
           Scenes pete = home.create("800", "scene06", "url03");              
           Scenes sally = home.create("900", "scene06", "url04");
           
           c = home.findBysceneName("scene06");
           i=c.iterator();

           while (i.hasNext()) {
              Scenes account = (Scenes)i.next();
              String id = (String)account.getPrimaryKey();
       
              System.out.println(id + ": ");
           }
           
           c = home.findAllScenes();
           i=c.iterator();

             System.out.println("id     sceneName     sceneURL");
           while (i.hasNext()) {
              Scenes curscene = (Scenes)i.next();
              String id = (String)curscene.getPrimaryKey();
       
              System.out.println(id + "     " + curscene.getSceneName() + "\t" + curscene.getSceneURL());
           }
           
       
           System.exit(0);
           
           

       }  catch (Exception ex) {
           System.err.println("Caught an exception." );
           ex.printStackTrace();
       }
   }
}
0
 
LVL 35

Expert Comment

by:girionis
ID: 8099262
 I don't know what exactly is going on but it tries to find some files and it's failing. It would be godo to copy these files on the client side as well, under the same structure and try again.
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8102636
I think you need the configuraton files, at least some of them, that installs with J2ee, then you must, I think, set the J2EE_HOME env variable.

See above:
orb.properties under C:\j2sdkee1.3.1\config (or where you install j2ee)
It probably contains:
port=1050
host=localhost

It probably reads this file, when looking up the server (then again, it might also reado other files... too)
0
 

Author Comment

by:kindy
ID: 8104420
my EJB is still running on Windows machine(localhost) where J2EE is installed. qirionis said we don't need to install j2ee on other machine if we just want to run a client. I think orb.properties refer to where server is.
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8104471
Yes, probably it is reading the whole config directory... where all the .properties files are...
0
 
LVL 35

Expert Comment

by:girionis
ID: 8104611
 No you shouldn't need the whole J2EE installed on the client, just the client files (jar & ear) and the j2ee.jar. EJBs should take care fo the rest. I am not sure why it's doing that but I never experienced problems with stand alone clients.
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8104674
Where are informations about wich server to connect to stored?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8105013
 That should be obtained from the JNDI context.
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8105292
this is the lookup:
initial.lookup("java:comp/env/ejb/SimpleScenes");
Here is nothing about any server...
0
 
LVL 35

Expert Comment

by:girionis
ID: 8110069
 Well naturally not. The lookup is not intented to look up a naming service but rather an object residing on that naming service. The above code just locates the EJB, does not indicate the JNDI server to use. The URI for the JNDI service should be provided as a property to the client otherwise it couldn't acquire the InitialContext.

  Most of the application servers provide their own property files which are usually bundled into the client JAR file (if you use a tool to create the JAR file and not create it manually). I guess what happens here is that it tries to find the property file and it's failing.

  The second thing that can be done (no properties file included) is to define such properties into the code using the System.setProperty() method.
0
 

Author Comment

by:kindy
ID: 8123197
it seems that i have no way to let the client run.... I copied config/ejb.properties, security.properties, but it seems not a way to figure out the problem.

Thanks for help
0
 
LVL 35

Expert Comment

by:girionis
ID: 8126374
 What is the problem this time? Still the same error messages?
0
 
LVL 2

Expert Comment

by:antonsigur
ID: 8126402
So it is running when you copy these files?
0
 

Author Comment

by:kindy
ID: 8131135
Now I use:
tmp $ java -classpath ./j2ee.jar:./j2ee-ri-svc.jar:./myScenesAppClient.jar ScenesClient -textauth


Caught an exception.
javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/SimpleScenes
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at ScenesClient.main(Unknown Source)


it seems that errors become less, but this happened when I relog in the machine the other day after I copied config/ejb.properties, security.properties to tmp/


why isn't there any instruction on the web about running j2ee client on different machines? it is said that J2EE is
great for distributed application, Java is portable, but porting is so much trouble....
0
 

Author Comment

by:kindy
ID: 8131329
what should we do with myScenesApp.ear?  maybe that includes sth. we need?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8136150
 Can you post the contents of your ejb.properties file?
0
 

Author Comment

by:kindy
ID: 8136168
Here it is:

audit.log.file=audit.log
repository.directory=repository
applications.directory=applications
http.port=9191

transaction.interoperability=true
transaction.jtsclient-policycheck=false
0
 
LVL 35

Expert Comment

by:girionis
ID: 8136270
 Hmm... it does not help me. Hwo do you obtain the information for the naming service?
0
 

Author Comment

by:kindy
ID: 8136509
i have no idea. almost desperate...
0
 
LVL 35

Expert Comment

by:girionis
ID: 8137118
 Do not worry, we will find a solution. How were you accessing the EJB when client and J2EE were running on the same computer? Did you use a naming sevrice somewhere on the web or did you use the naming service that runs with your J2EE server?
0
 

Author Comment

by:kindy
ID: 8138323
i have no idea. almost desperate...
0
 

Author Comment

by:kindy
ID: 8138350
I just use the naming service that comes with J2EE server, actually, I don't know how to use other naming service.
0
 
LVL 35

Accepted Solution

by:
girionis earned 100 total points
ID: 8138542
 Ok. I assume that your client runs on a differet machine than your application server, i.e. the computer where your EJB is deployed has a different I.P. address from the computer where your client is running.

  Before we proced just do a last thing. In your main method please put the following (just before the "try" statement):

  System.out.println("java.naming.factory.initial: " + System.getProperty("java.naming.factory.initial"));
  System.out.println("java.naming.provider.url: " + System.getProperty("java.naming.provider.url"));

  The first one is to see which class acquires the initial context and the second is to see the provider of the naming service (if any).

  Can you let us know what the output of the two System.out.println statements is?

 
0
 

Author Comment

by:kindy
ID: 8147003
I put the above too lines into client main method, just below this statement:
Object objref = initial.lookup("java:comp/env/ejb/SimpleScenes");

and I redeploy the app. and rerun the client, still on the localhost machine. The results are:

java.naming.factory.initial: null
java.naming.provider.url: null

any clue? seems weird.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8147249
 What happens if you run the same client from the same physical computer as the one that runs the J2EE application server (client and server on the same computer)? What is the output?
0
 

Author Comment

by:kindy
ID: 8147275
that is the result, I can only run client on the same machines where EJB is deployed.
0
 
LVL 35

Expert Comment

by:girionis
ID: 8150813
 Does your EJB Home interface extend EJBHome or EJBLocalHome?
0
 

Expert Comment

by:CleanupPing
ID: 9058834
kindy:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 35

Expert Comment

by:girionis
ID: 9693351
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to antonsigur

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question