La valeur de l'attribut n'est pas défini pour le type d'annotation Produit pour “MediaType.APPLICATION_JSON”
Je reçois un étrange avertissement (tout en plaçant la ligne rouge dans eclipse) pour cette très simple reposant code de service:
(Eclipse dessine une ligne rouge sous "MediaType.APPLICATION_JSON")
import java.util.List;
import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import com.myCompany.annotation.RestfulServiceAddress;
import com.myCompany.myProject.middleware.api.myService;
@RestfulServiceAddress("/myCompany-middleware")
public class myServiceImpl implements myService {
private EntityManagerFactory entityManagerFactory;
@GET
@Path("/getStuff")
@Produces(MediaType.APPLICATION_JSON)
public List<Object> getStuff() {
EntityManager entityManager = entityManagerFactory
.createEntityManager();
try {
return entityManager.createQuery(
"Select S from Stuff S", Object.class)
.getResultList();
} catch (Exception ex) {
ex.printStackTrace();
return null;
} finally {
entityManager.close();
}
}
public EntityManagerFactory getEntityManagerFactory() {
return entityManagerFactory;
}
public void setEntityManagerFactory(
EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}
}
Aussi maven construit le fichier jar sans problèmes. Mais j'obtiens une erreur à partir du conteneur OSGI, me disant que le pot est échoué.
OriginalL'auteur brainmassage | 2015-05-15
Vous devez vous connecter pour publier un commentaire.
Utilisation
@javax.ws.rs.Produit
au lieu dejavax.enterprise.inject.Produces
OriginalL'auteur Paul Samsotha