Take the 2-minute tour ×

I have a JSF 2.0 web project and I use Glassfish 3.1.2 server. In this project, I have among other things :

  • a class called AjaxServlet annotated with @javax.servlet.annotation.WebServlet
  • a class called Session annotated with @javax.ejb.Stateful

When I deploy this project to Glassfish from eclipse, everything runs perfectly : in the administration console of Glassfish, the engines associated with the application are [ejb, jpa, web, weld]. But when I first export the project as a war, then from the admin console I deploy the war, the application doesn't work : the engines associated to the application are then [web] only.

How can I export an application to a war without loosing any information (all the engines)? I didn't declare my Servlet in web.xml because in JSF 2.0, we don't need that: the annotations are enough. Does anyone have an idea about what is going on here? I'm quite sure it is not a problem of Glassfish distributions (Web Profile Vs Full Platform) as the same Glassfish server is used for the 2 scenarios above.

Note for those who erroneously think my question is off-topic : Jsf is a framework for programming Java EE web applications. war is a way to package a Jsf application, in the same as jar is a way to package java classes. So my question is totally a programming topic! It is totally legitimate to have it here in StackOverflow. If exporting JSF application into war is not a programming issue, then compiling java classes into .class should not be a programming topic neither! So Pleaze don't downgrade for this reason!

share|improve this question
JSF is the view technology and is a part of the JEE stack. War and JSF is not directly related. Your question is more how to package a JEE webapp into a war. It depends on what tools do you use to manage and build your project (an eclipse project, maven...) –  Nicolas Labrot Feb 21 '13 at 19:16
My question is why the difference? why does everything work when I deploy my application with eclipse, and not when I first export as war then deploy the war? –  ouba64 Feb 21 '13 at 22:21
add comment

1 Answer

You have to understand the difference between your eclipse environment and Your glassfish environment. Not all your libraries that are available in eclipse might be included in your external environment. There are cases where programs compile in eclipse, but not when run from console. Here are is a tip.

Right click on project, Navigate to Properties > Java Build Path > Order and Export, and ensure that all the Libraries you require are going to be exported.

share|improve this answer
add comment

Your Answer


