error when deploying a resftul service

0

I have a RESTful service created in Netbeans that takes the data from a remote database that I have in mysql. I followed the steps of this web: link (in this example they create a database. I have created on the remote server that I have virtual). In local it works well, but when I deploy it to the remote Glassfish server I get an error:

> Error occurred during deployment: Exception while deploying the app
> [ProjecteRepairManage] : Class service.PrioritatFacadeREST has
> unsupported major or minor version numbers, which are greater than
> those found in the Java Runtime Environment version 1.7.0_80. Please
> see server.log for more details.

The code for the service.PrioritatFacadeREST class is:

package service;

import entities.Prioritat;
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;

@Stateless
@Path("entities.prioritat")
public class PrioritatFacadeREST extends AbstractFacade<Prioritat> {

@PersistenceContext(unitName = "ProjecteRepairManagePU")
private EntityManager em;

public PrioritatFacadeREST() {
    super(Prioritat.class);
}

@POST
@Override
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public void create(Prioritat entity) {
    super.create(entity);
}

@PUT
@Path("{id}")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public void edit(@PathParam("id") Integer id, Prioritat 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 Prioritat find(@PathParam("id") Integer id) {
    return super.find(id);
}

@GET
@Override
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Prioritat> findAll() {
    return super.findAll();
}

@GET
@Path("{from}/{to}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Prioritat> 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;
}

}

I understand that it tells me that the Java version is not correct. The computer where I am working has the Java 1.8 version. If the change to 1.7 gives me exactly the same error.

    
asked by Montse 17.03.2017 в 16:34
source

1 answer

0

What it tells you is that you have moved to a JVM version 7 compiled classes for JVM 8. As JVM 7 does not know if the classes will be compatible, it protests.

What you have to do is compile your classes with indicating that you want me to generate the classes for the JVM 7.

You have to go to Project -> Properties -> Sources window and set the value to 1.7.

If you want to know in which version a class is compiled, you can use the javap tool; Java 7 has the "version-number" 51 and Java 8, 52.

link

    
answered by 17.03.2017 / 16:41
source