title: How a JEE6 enterprise application that offers REST web services should be organized?
body: <p>Since a month ago i am studying restful web services really hard. 
  Now that i did practice the Syntax and i understand the concepts, i decided to make a very simple enterprise application that includes EJB, JPA and REST.
  I am making a big effort in trying to understand what is the best way to organize this kind of system. Ill appreciate a lot if someone with experience in the field could give me some tips on what would be the best practice, and how can i solve my current problem. </p>
  
  <p>Let me show you this image please. Sorry i cannot get better resolution(Use Ctrl+ Mouse Scroll Up to zoom):</p>
  
  <p><img src="https://i.stack.imgur.com/Pz9yH.jpg" alt="enter image description here"></p>
  
  <p>As you can see this is a very simple enterprise app, that has 2 modules.</p>
  
  <p>This application does not use CDI( I want to achieve my goal without CDI help and)</p>
  
  <p>When some client(Any inter-operable client) sends a @GET with some parameters the REST service should pass those parameters to the EJB module which will search in the database and send back the appropiate data. At the end the service will automatically marshal with the help of JAXB and send the .XML back to the client. </p>
  
  <p>My problems are the following:</p>
  
  <ul>
  <li>I get a ClassCastException because the entity in the that is in the EJB module is not compatible with the JAXB class in the WebModule(Even if their variables are the same)</li>
  <li>I don't know how things should be organized so the front end can marshal and unmarshal those entities.</li>
  <li>Should maybe the entity class be in the front end combined with the JAXB mapping? If then, there will not be really need for the EJB module. But the thing is, i want the EJB module because i often do my CRUD operations there.</li>
  <li>What about exposing the EJB as a REST web service(making a hybrid)? Do you think this is a good idea? How can it help me? </li>
  <li>Again if i create a hybrid of JAXRS+EJB in the web module, i will must create then my JPA entities in the front end and that is a thing i never did before. Do you think it is a good practice?</li>
  <li>What do you suggest? What is often the way the Enterprise applications that use REST web services are organized? </li>
  </ul>