a free solution to package java web application with tomcat to an exe
I made a java web application that uses hibernate, spring and jsf. it is deployed on tomcat 7. I want to distribute it to external users, but I'm afraid that someone can decompile classes and get back to java code.
Excelsior JET fits my needs because it packages Tomcat and the war file of the web application into an exe file that can be distributed to third party.
BUT Excelsior is very expensive for me and I'm looking for a free solution to pack all the staff into one exe file.
EDIT : If I use obfuscation. it's going to modify methods and fields names. the problem is that I'm calling them from my xhtml files. they won't be accessible anymore.
You could obfusticate your code for free using ProGuard. There are other solutions that'll do this too, but they might not be free.
As david99 suggests, the most you can do is obfuscate the code (ProGuard or yGuard comes to mind). This avoids casual reverse engineering -- although no obfuscation is perfect. Any binary can be seen as "obfuscated code" -- given enough time, all (self-contained) programs are crackable; and Java bytecode is no exception.
From the obfuscated .war, you can easily generate a self-contained .war that packages a light-weight servlet-container in it: see executable-war.
The result would be people executing your code either by standard deployment or as
java -jar nameOfApp.war
If this is still too complicated for end-users, you can wrap it up as an .exe with launch4j. The whole toolchain is fee as in beer and speech (yGuard's code is proprietary though; but really easy to configure), and can be integrated into a maven/ant build.
Otherwise, you can build an installer that installs a pre-configured tomcat with the application in it. I have personally used izpack. However, adding this to a mavenized build may be harder.