First, Thanks you for your replies. 首先，谢谢你的回复和建议/指导！
Second, sorry about my poor English,
if you understand Chinese, you can read Chinese under the English content.
I have an idea to develop a standalone swing application
( which can be deployed in any standalone J2SE environment) using EJB 3.1. It means:
Using all of ejb 3.1 technology. 充分利用全部的EJB3.1技术。
Can run in the embedded containers. do not need fully j2ee application server. 不需要部署在完整的J2EE应用服务器上，仅需使用各种嵌入式容器即可。
The requirement I want the application completely fit the specification.
I want use all of the ejb3.1 features.
I want the application can be deployed in the fully j2ee container. and,
I want the application can be deployed in a standalone j2se jvm environment without any codes modified.
To make my idea clear, I'll introduce the simplest programs which describe the idea.
There are 4 important Java classes:
a) a main class to start up the embedded containers and set the J2EE environment.
b) context holder. hold the J2EE context in the swing application.
c) a stateless session bean, implements the business logics or accesses the database.
d) a swing client to invoke the stateless session bean
what I want:
a) the main class (StartApp) to start up the embedded containers:
b) the context holder:
c) the stateless session bean:
d) the swing client:
I've found a way to implement the idea:
using openejb 3.2.0 snapshot (supports most important ejb3.1 technologies).
The swing classes can inject ejb by openejb proprietary way,
and most of the container properties can be set:
the StartApp class:
The startApp class init and start the ejb container with configurable properties.
The Ejb container start when invoke the new InitialContext method.
When the main thread exits, the container is disposed.
If I want to inject the EJB reference to a client,
I must invoke the bind("inject", clientObject) method. openejb container can not do it automatically.
I think It's not good. If there are a lots of client need ejb inject,
the client's construct method must be have the "bind("inject", clientObject)" sentence.
And the openejb performance can not be used in other j2ee container. It is not fit the specification.
the context holder:
The ContextHolder class is very simple.
But I think if use a powerful container, the context holder is not necessary.
the stateless session bean:
It's very simple.
the swing client:
It's simple. But there is an annotation named "LocalClient".
If the annotation is not exist, the "ContextHolder.getContext().bind("inject", client);"
setence in the StartApp class is useless.
Openejb container use the "LocalClient" annotation to indentify the client.
I think it's not good, and it is not fit the specification.
I think there must be another way to implement my idea
Now I tried to use glassfish embedded container and glassfish embedded acc container.
I make 3 jars.
1) startApplication.jar. I want it to init and start the glassfish embedded container and glassfish acc container.
2) EJBModule.jar. contains all of the ejb components.
3) EJBClient.jar. the clients which invoke ejb components.
startApplication.jar The pom.xml of startApplication.jar:
There is only 1 class to init and start the containers.StartApp:
EJBModule.jar the most important dependency in pom.xml:
There is only 1 class to perform the ejb charator.
EJBClient.jar the most important dependencies in pom.xml
There are 2 classes in EJBClient.jar:
App: provide main method to the glassfish embedded acc container
TestClient: the client to invoke ejb components.
the App class:
the TestClient class:
I can not start the glassfish embedded ejb container and embedded acc container in the same time/method.
I can start the embedded ejb container without acc container, but how can i deploy modules without point out the path of the modules?
I can start the embedded acc container without ejb container, but how can i inject the ejbs into the clients?
when i run the StartApp class, i got the log and exception:
If i modified the pom.xml of startApplication.jar , delete the dependency of "glassfish-embedded-all", there are no errors in compile time. but in the run time ,i got the log and exceptions:
I followed the exception, and I found that the habitat.getComponent(CommandRunner.class) (ConfiguratorImpl.java:68) returns null.
Then I comment the CommandRunner, CommandResult and GlassFishProperties in the main method of StartApp class. I got the exceptions:
I think it is about the Deployer. so i comment the Deployer in the StartApp class. then I got the exceptions:
There are only injects exceptions, I think the acc container runs correctly. but How can i deploy ejb modules on this situation?
how can i implements my idea? Thanks for your replies!
subject: How to develop a standalone swing application with ejb 3.1