Link to home
Start Free TrialLog in
Avatar of Nargzul
Nargzul

asked on

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

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!
Avatar of a_b
a_b

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.
Avatar of Nargzul

ASKER

Okay, so how I generate this stand alone client?
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.
Avatar of Nargzul

ASKER

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

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

ASKER

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.
Yes I am sure..........the netbeans lib link the required libs internally and generate the classpath.
Avatar of Nargzul

ASKER

Okay, so what is this library? Where can I found it?
What webserver are yo using?
Avatar of Nargzul

ASKER

Glassfish V2U2
Check in  the lib directory, it should be there.
Avatar of Nargzul

ASKER

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
Open the directory where glassfish is installed, there should be a lib directory inside the server dir. Place the entire directory in the classpath.
Avatar of Nargzul

ASKER

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
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.
Avatar of Nargzul

ASKER

I've some DTD and XSD about ejb, but no jar with the ejb in the name.
Avatar of Nargzul

ASKER

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");
    }
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.
ASKER CERTIFIED SOLUTION
Avatar of Nargzul
Nargzul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial