javaee-samples / javaee7-hol

Java EE 7 Hands-on Lab
http://htmlpreview.github.io/?https://github.com/javaee-samples/javaee7-hol/blob/master/docs/javaee7-hol.html
Other
136 stars 90 forks source link

unable to integrate JSF2.2 page with REST endpoint class even with code written by you tried on Netbeans IDE8.1 using glassfish4.1.. #22

Open ankitshende opened 8 years ago

ankitshende commented 8 years ago

web.xml <?xml version="1.0" encoding="UTF-8"?>

javax.faces.PROJECT_STAGE Development javax.faces.CLIENT_WINDOW_MODE url ``` Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/* com.mycompany.movieplex7.rest.ApplicationConfig 1 ``` com.mycompany.movieplex7.rest.ApplicationConfig /webresources/* 30 faces/index.xhtml

booking.xhtml

```

Pick a Movie

``` MovieFacadeREST package com.mycompany.movieplex7.rest; import com.mycompany.movieplex7.entities.Movie; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; /** * - @author justme */ @Stateless @Path("movie") public class MovieFacadeREST extends AbstractFacade { @PersistenceContext(unitName = "movieplex7PU") private EntityManager em; public MovieFacadeREST() { super(Movie.class); } @POST @Override @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public void create(Movie entity) { super.create(entity); } @PUT @Path("{id}") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public void edit(@PathParam("id") Integer id, Movie entity) { super.edit(entity); } @DELETE @Path("{id}") public void remove(@PathParam("id") Integer id) { super.remove(super.find(id)); } @GET @Path("{id}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Movie find(@PathParam("id") Integer id) { return super.find(id); } @GET @Override @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public List findAll() { return super.findAll(); } @GET @Path("{from}/{to}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public List findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { return super.findRange(new int[]{from, to}); } @GET @Path("count") @Produces(MediaType.TEXT_PLAIN) public String countREST() { return String.valueOf(super.count()); } @Override protected EntityManager getEntityManager() { return em; } } ApplicationConfig package com.mycompany.movieplex7.rest; import java.util.Set; import javax.ws.rs.core.Application; /** * - @author justme */ @javax.ws.rs.ApplicationPath("webresources") public class ApplicationConfig extends Application { @Override public Set> getClasses() { Set> resources = new java.util.HashSet<>(); addRestResourceClasses(resources); return resources; } /** - Do not modify addRestResourceClasses() method. - It is automatically populated with - all resources defined in the project. - If required, comment out calling this method in getClasses(). */ private void addRestResourceClasses(Set> resources) { resources.add(com.mycompany.movieplex7.rest.MovieFacadeREST.class); resources.add(com.mycompany.movieplex7.rest.SalesFacadeREST.class); resources.add(com.mycompany.movieplex7.rest.ShowTimingFacadeREST.class); resources.add(com.mycompany.movieplex7.rest.TheaterFacadeREST.class); resources.add(com.mycompany.movieplex7.rest.TimeslotFacadeREST.class); resources.add(org.glassfish.movieplex7.json.MovieReader.class); resources.add(org.glassfish.movieplex7.json.MovieWriter.class); } } Pom.xml 4.0.0 ``` com.mycompany movieplex7 1.0-SNAPSHOT war movieplex7 ${project.build.directory}/endorsed UTF-8 org.eclipse.persistence eclipselink 2.5.2 provided org.eclipse.persistence org.eclipse.persistence.jpa.modelgen.processor 2.5.2 provided javax javaee-web-api 7.0 provided org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 ${endorsed.dir} org.apache.maven.plugins maven-war-plugin 2.3 false org.apache.maven.plugins maven-dependency-plugin 2.6 validate copy ${endorsed.dir} true javax javaee-endorsed-api 7.0 jar ``` I have already tried this example three times but everytime its getting stuck with same problem... Next the JSF2.2 fileuploadexample is also not working I have tried atleast twice once with my own code and second time I used your code as mentioned over here plz help me with both the issues