Hello everyone, I’m developing a html5 application with a restful service generated using Netbeans. After modifying some configuration xml files like removing jersey serverlet<http://stackoverflow.com/questions/10583563/how-can-i-integrate-jersey-with-tomee-openejb>, changing xmlns to “ http://java.sun.com/xml/ns/persistence“ and configuring jta-data-source in persistence.xml. The service finally worked. But I cannot access my web files in the web root directory. Anyone knows why?
Here is my source files: web.xml <?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <filter> <filter-name>cross-origin</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/api/*</url-pattern> </filter-mapping> </web-app> persistence.xml <?xml version="1.0" encoding="UTF-8"?><persistence version="2.1" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="TongYiMenHuRestServicePU" transaction-type="JTA"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>tongyimenhu</jta-data-source><!-- <non-jta-data-source>tongyimenhu-nonjta</non-jta-data-source>--> <class>com.tongyimenhu.entities.Type</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit> </persistence> context.xml <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/tymh"/> Type.java /* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.tongyimenhu.entities; import java.io.Serializable;import javax.persistence.Basic;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.NamedQueries;import javax.persistence.NamedQuery;import javax.persistence.Table;import javax.validation.constraints.NotNull;import javax.validation.constraints.Size;import javax.xml.bind.annotation.XmlRootElement; /** * * @author yeyanbo */@Entity@Table(name = "type")@XmlRootElement@NamedQueries({ @NamedQuery(name = "Type.findAll", query = "SELECT t FROM Type t"), @NamedQuery(name = "Type.findByTypeId", query = "SELECT t FROM Type t WHERE t.typeId = :typeId"), @NamedQuery(name = "Type.findByTypeName", query = "SELECT t FROM Type t WHERE t.typeName = :typeName"), @NamedQuery(name = "Type.findByTypeAudit", query = "SELECT t FROM Type t WHERE t.typeAudit = :typeAudit"), @NamedQuery(name = "Type.findByTypeDescrib", query = "SELECT t FROM Type t WHERE t.typeDescrib = :typeDescrib")})public class Type implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "type_id") private Integer typeId; @Basic(optional = false) @NotNull @Size(min = 1, max = 35) @Column(name = "type_name") private String typeName; @Column(name = "type_audit") private Integer typeAudit; @Size(max = 50) @Column(name = "type_describ") private String typeDescrib; public Type() { } public Type(Integer typeId) { this.typeId = typeId; } public Type(Integer typeId, String typeName) { this.typeId = typeId; this.typeName = typeName; } public Integer getTypeId() { return typeId; } public void setTypeId(Integer typeId) { this.typeId = typeId; } public String getTypeName() { return typeName; } public void setTypeName(String typeName) { this.typeName = typeName; } public Integer getTypeAudit() { return typeAudit; } public void setTypeAudit(Integer typeAudit) { this.typeAudit = typeAudit; } public String getTypeDescrib() { return typeDescrib; } public void setTypeDescrib(String typeDescrib) { this.typeDescrib = typeDescrib; } @Override public int hashCode() { int hash = 0; hash += (typeId != null ? typeId.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Type)) { return false; } Type other = (Type) object; if ((this.typeId == null && other.typeId != null) || (this.typeId != null && !this.typeId.equals(other.typeId))) { return false; } return true; } @Override public String toString() { return "com.tongyimenhu.entities.Type[ typeId=" + typeId + " ]"; } } TypeFacadeREST.java /* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.tongyimenhu.restservice; import com.tongyimenhu.entities.Type;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; /** * * @author yeyanbo */@Stateless@Path("/api/com.tongyimenhu.entities.type")public class TypeFacadeREST extends AbstractFacade<Type> { @PersistenceContext(unitName = "TongYiMenHuRestServicePU") private EntityManager em; public TypeFacadeREST() { super(Type.class); } @POST @Override @Consumes({"application/xml", "application/json"}) public void create(Type entity) { super.create(entity); } @PUT @Override @Consumes({"application/xml", "application/json"}) public void edit(Type entity) { super.edit(entity); } @DELETE @Path("{id}") public void remove(@PathParam("id") Integer id) { super.remove(super.find(id)); } @GET @Path("{id}") @Produces({"application/xml", "application/json"}) public Type find(@PathParam("id") Integer id) { return super.find(id); } @GET @Override @Produces({"application/xml", "application/json"}) public List<Type> findAll() { return super.findAll(); } @GET @Path("{from}/{to}") @Produces({"application/xml", "application/json"}) public List<Type> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) { return super.findRange(new int[]{from, to}); } @GET @Path("count") @Produces("text/plain") public String countREST() { return String.valueOf(super.count()); } @Override protected EntityManager getEntityManager() { return em; } } I'm new in Java EE development. Can anybody help me? Thanks in advance! Best, Yanbo -- *Yanbo Ye* *Guangzhou Institutes of Biomedicine and Health, * *Chinese Academy of Sciences* *190 Kaiyuan Avenue, Science Park, Guangzhou, China* *Email: ye_ya...@gibh.ac.cn <ye_ya...@gibh.ac.cn>* *Web: http://www.yeyanbo.com <http://www.yeyanbo.com>* *Phone: (86)-020-32093810*