While doing the original training for EJBs from Sun I came across the rather strange concept of a enterprise application client which has the notion of dependecy injection and a main class:
@javax.ejb.EJB
private static auctionsystem.ejb.AuctionManagerRemote auctionManager;
public static void main (String[] args)
{
TestClient.logger.entering (TestClient.TAG, "main");
final String message = "hello";
TestClient.logger.log (Level.INFO, "Sending {0}", message);
final String reply = auctionManager.communicationTest (message);
TestClient.logger.log (Level.INFO, "Received {0}", reply);
TestClient.logger.exiting (TestClient.TAG, "main");
return;
}
I just can't find any background info on this. Like:
Yes I do use NetBeans - but I am not satisfied if I can not do the same operation on the command-line and/or Maven as well.
Answering my own question (again)
How is this supposed to work?
The main() class is deployed to the application server which injects the dependencies and calls main (). On glassfish deployment is done with a special command (appclient
).
How do you start such an application without NetBeans?
As said on glassfish ou start the client with the use of appclient
. For example:
appclient -enableassertions -mainclass auctionapp.TestClient -jar target/AuctionApp-ejb.jar
How do you build this construct without NetBeans (i.E. with Maven)?
You create a normal executable jar. It will only work if your remote interfaces are inside a library as well (which is good praxis anyway) and this library is included inside your executable lib. You can use maven-assembly-plugin
to create the executable. Just the same way you create a normal executable jar.
Thanks for all the help. Without SO I would not have found out the details.