Get a jar for my heavy container connecting to EJB in Netbeans

Nargzul
Nargzul used Ask the Experts™
on
Hi!

I've done a small program that connect to my EJB server, It works on debugging under Netbeans but now I want to test it on a serveur that hasn't netbeans.

I've viewed that netbeans generate two jar for this container. I've deployed the one that doesn't have a -client.

After this I've try to launch the program but it appears it don't know which class he must start. But in the netbeans properties it's specified.

So my question is simple:
What is the good way to create a .jar(or the two jars) that will connect to my EJB server.

Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
a_b
Top Expert 2009

Commented:
I am not to sure if you need to deploy the second jar at all. When you deploy the jar containing the the beans all you need is a stand alone client to do the lookup of that bean and that functions independently. So I am not sure why you need the second jar.

Author

Commented:
Okay, so how I generate this stand alone client?
a_b
Top Expert 2009

Commented:
No need to generate it. You can write a java bean/pojo as a client and use that. Do the lookup and access the ejb.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Author

Commented:
So how I run it?? I've tried to make a javac, etc, but I've missing library(javax.ejb by exemple).

a_b
Top Expert 2009

Commented:
You can run it through the javac but make sure you include the right libs in the class path by using the javac flags.

Author

Commented:
I've watched in my Netbeans project, the only imported lib is my EJB project.

If we do a javac, are you sure it use J2EE and not J2SE? Because I think this missing lib is in the J2EE and not J2SE.
a_b
Top Expert 2009

Commented:
Yes I am sure..........the netbeans lib link the required libs internally and generate the classpath.

Author

Commented:
Okay, so what is this library? Where can I found it?
a_b
Top Expert 2009

Commented:
What webserver are yo using?

Author

Commented:
Glassfish V2U2
a_b
Top Expert 2009

Commented:
Check in  the lib directory, it should be there.

Author

Commented:
which lib directory? Of glassfish? Of the project? What is its name?

The only lib directory I've found in this client container application is the jar of my EJB project
a_b
Top Expert 2009

Commented:
Open the directory where glassfish is installed, there should be a lib directory inside the server dir. Place the entire directory in the classpath.

Author

Commented:
Okay, the lib folder has something like 75Mo of libraries.

I've try this:


"C:\Program Files\Java\jdk1.6.0_14\bin\javac" -classpath "C:\Program Files\glassfish-v2ur2\lib;C:\Users\J4N\Desktop\TrustBN-ejb.jar" MatchBot.java

But I always got same error:


C:\Users\J4N\Documents\My Dropbox\WorkSpaces\J2EE\TrustBN\TrustBN-app-client\src\java\MatchBot>"C:\Program Files\Java\jdk1.6.0_14\bin\javac" -classpath "C:\Program Files\glassfish-v2ur2\lib;C:\Users\J4N\Desktop
\TrustBN-ejb.jar" MatchBot.java
MatchBot.java:14: package javax.ejb does not exist
import javax.ejb.EJB;
                ^
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'name()' in type 'javax.persistence.Table': class file for javax.persistence.Table not found
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'value()' in type 'javax.persistence.NamedQueries': class file for javax.persistence.NamedQueries not found
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'name()' in type 'javax.persistence.NamedQuery': class file for javax.persistence.NamedQuery not found
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'query()' in type 'javax.persistence.NamedQuery'
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'name()' in type 'javax.persistence.NamedQuery'
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'query()' in type 'javax.persistence.NamedQuery'
datamodel\Exchange.class(datamodel:Exchange.class): warning: Cannot find annotation method 'strategy()' in type 'javax.persistence.GeneratedValue': class file for javax.persistence.GeneratedValue not found
a_b
Top Expert 2009

Commented:
search for some ejb specific lib inside the folder.........can you list those out. Do a searcg *ejb*.jar in the lib folder and post the results.

Author

Commented:
I've some DTD and XSD about ejb, but no jar with the ejb in the name.
a_b
Top Expert 2009

Commented:

Author

Commented:
In facts the javaee was missing, now the compilation is ok, but I've always this problem:


C:\Users\J4N\Documents\My Dropbox\WorkSpaces\J2EE\TrustBN\TrustBN-app-client\src\java>"C:\Program Files\Java\jdk1.6.0_14\bin\javac" -classpath "appserv-rt.jar;javaee.jar;TrustBN-ejb.jar" MatchBot/MatchBot.java

C:\Users\J4N\Documents\My Dropbox\WorkSpaces\J2EE\TrustBN\TrustBN-app-client\src\java>java MatchBot
Exception in thread "main" java.lang.NoClassDefFoundError: MatchBot
Caused by: java.lang.ClassNotFoundException: MatchBot
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: MatchBot.  Program will exit.


but I've a main in my class:
    public static void main(String[] args) throws NamingException {
        new MatchBot().start();
        System.out.println("Job successfully finished");
    }
a_b
Top Expert 2009

Commented:
Any progress  on the issue as yet?

What is the pacakge name that you have specified and how to do you invoke in from the command line? You need to be at the right package level.
Commented:
No :(

I've show how I call it.

The package is MatchBot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial