First a little background:
I'm working on an enterprise application (ear) with an EJB module & an Application Client module. I also use hibernate JPA for persistence, and swingx for GUI. Those are the only third parties atm. This application is deployed on Glassfish.
Everything was going well until I deployed my application for the first time and tried starting it by Java Web Start. I've hit major road blockers - JWS doesn't like hibernate3.jar, complains it's not signed, although it is. I've described the problem here if you're interested. Anyway it might be related to this unresolved bug in JVM. There are other things I don't like about JWS but that doesn't matter now.
Current approaches
Given this problem I thought I'd deploy the application myself (I plan to write some kind of auto-updater to keep everything synchronized). So I followed the instru开发者_StackOverflow社区ctions from here and everything was cool, except the fact that the application container I need to deploy to the client is around 40 MB!!!. That's way too much!
Ok, so I said I'll drop the application container, create a standalone client do the EJB lookup through JNDI and include only the minimum.
And here I'm stuck!
This is the JNDI lookup I use:
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
prop.put("org.omg.CORBA.ORBInitialHost", "bogdan-pc");
prop.put("org.omg.CORBA.ORBInitialPort", "3700");
try {
InitialContext ctx = new InitialContext(prop);
DatabaseCacheEJBRemote service = (DatabaseCacheEJBRemote) ctx.lookup("ejbs.DatabaseCacheEJBRemote");
System.out.println("count: " + service.getProductionCount());
} catch (NamingException ex) {
Logger.getLogger(MyFrame.class.getName()).log(Level.SEVERE, null, ex);
}
1) I thought that if I include appserv-rt.jar & javaee.jar should be enough. Apparently I need other stuff from GF... The question would be what is the bare minimum I need to deploy to the client to get EJB's lookup working?
2) Why do I need to include all the ejb-module dependencies (like hibernate libraries)?. I'm not using anywhere in my client stuff from hibernate...
Thanks for reading this long post!
EDIT:
Some details about my environment:
- Java 1.6.0_21
- GF 3.0.1
- Windows(XP/2003/7)
Think about using WebServices to connect your desktop application to application server. From Java EE 6 this is much easier, because you can just annotate some session bean (not so sure about details) to become a web service. It is a "thin" solution and connections can be done throw http(s) so standard ports 80/443 shouldn't be blocked in private or corporate networks.
You should be able to get rid of a lot of the dependencies if you split your ejb into separate modules, i.e. Interface and Implementation jars.
impl and client jars should depend on intf, and then client should no longer have any dependency on hibernate.
I've found maven to be a very useful toolset for splitting and managing the dependencies, and generating the jnlp files, deployment descriptors, signing jar files etc.
Your hibernate jar file may have duplicate signatures, and may need to be unsigned first and then resigned.
Why don't you consider a browser based front-end, like gwt or vaadin or jboss-seam or wicket or grails or tapestry or one of the many others. Then you won't have to worry about getting the right version of java installed on the client iether.
This is the complete list of client jars for glassfish 3 :
auto-depends.jar
deployment-common.jar
glassfish-corba-internal-api.jar
internal-api.jar
management-api.jar
bean-validator.jar
dol.jar
glassfish-corba-newtimer.jar
javax.ejb.jar
orb-connector.jar
common-util.jar
ejb-container.jar
glassfish-corba-omgapi.jar
javax.jms.jar
orb-iiop.jar
config-api.jar
ejb.security.jar
glassfish-corba-orb.jar
javax.resource.jar
security.jar
config-types.jar
glassfish-api.jar
glassfish-corba-orbgeneric.jar
javax.servlet.jar
ssl-impl.jar
config.jar
glassfish-corba-asm.jar
glassfish-naming.jar
javax.transaction.jar
transaction-internal-api.jar
connectors-internal-api.jar
glassfish-corba-codegen.jar
gmbal.jar
jta.jar
container-common.jar
glassfish-corba-csiv2-idl.jar
hk2-core.jar
kernel.jar
精彩评论