keviin555
asked on
Problem with REST
Hello ,
i tire to write a REST web - service with java ( netbean , glassfish and jersey)
i write a very simple code and it work . But when i tried to make something like this :
i have this error :
Status: 500 (Internal Server Error)
i think that the problem is in the @XmlRootElement , i dont found where write it ... Help me please
i tire to write a REST web - service with java ( netbean , glassfish and jersey)
i write a very simple code and it work . But when i tried to make something like this :
package service;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import converter.FlyedpConverter;
import entities.FlysCombination;
@Path("/getdates")
public class FlyedpResource {
@GET
@Path("{date}")
@Produces({"application/json"})
public Response get(@PathParam("date") String date) throws IOException
{
FlysCombination comb =new FlysCombination();
FlysCombination x = FlysCombination.instance();
comb = x.getcomb(date);
System.out.println(comb.toString());
if(comb == null)
{
return Response.status(Response.Status.NOT_FOUND).build();
}
return Response.ok(comb).build();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package entities;
import converter.FlyedpConverter;
import java.util.ArrayList;
/**
*
* @author mehdi
*/
public class FlysCombination {
public FlysCombination ()
{
}
public static FlysCombination flycomb=null;
public static FlysCombination instance()
{
if(flycomb == null)
{
flycomb=new FlysCombination();
}
return flycomb;
}
private String session;
@SuppressWarnings("rawtypes")
private ArrayList combinations = new ArrayList();
public FlysCombination(String session,ArrayList combinations)
{
this.session=session;
this.combinations=combinations;
}
public ArrayList getcombinations() {
return combinations;
}
public void setcombinations(ArrayList goingthere) {
this.combinations = goingthere;
}
public String getsession() {
return session;
}
public void setsession(String session) {
this.session = session;
}
public FlysCombination getcomb(String a)
{
FlyedpConverter fly = new FlyedpConverter (a);
combinations.add(fly);
session="sdjkbsqdjhf";
FlysCombination flycomb =new FlysCombination (session,combinations);
return(flycomb);
}
}
package converter;
public class FlyedpConverter
{
private String keydate;
public FlyedpConverter(String keydate)
{
this.keydate=keydate;
}
public String getkeydate() {
return keydate;
}
public void setkeydate(String keydate) {
this.keydate = keydate;
}
}
i have this error :
Status: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException at com.sun.jersey.spi.contain er.Contain erResponse .write(Con tainerResp onse.java: 268) at com.sun.jersey.server.impl .applicati on.WebAppl icationImp l._handleR equest(Web Applicatio nImpl.java :1029) at com.sun.jersey.server.impl .applicati on.WebAppl icationImp l.handleRe quest(WebA pplication Impl.java: 941) at com.sun.jersey.server.impl .applicati on.WebAppl icationImp l.handleRe quest(WebA pplication Impl.java: 932) at com.sun.jersey.spi.contain er.servlet .WebCompon ent.servic e(WebCompo nent.java: 384) at com.sun.jersey.spi.contain er.servlet .ServletCo ntainer.se rvice(Serv letContain er.java:45 1) at com.sun.jersey.spi.contain er.servlet .ServletCo ntainer.se rvice(Serv letContain er.java:63 2) at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 847) at org.apache.catalina.core.S tandardWra pper.servi ce(Standar dWrapper.j ava:1523) at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:279) at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:188) at org.apache.catalina.core.S tandardPip eline.invo ke(Standar dPipeline. java:641) at com.sun.enterprise.web.Web Pipeline.i nvoke(WebP ipeline.ja va:97) at com.sun.enterprise.web.PES essionLock ingStandar dPipeline. invoke(PES essionLock ingStandar dPipeline. java:85) at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:185 ) at org.apache.catalina.connec tor.Coyote Adapter.do Service(Co yoteAdapte r.java:325 ) at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:226) at com.sun.enterprise.v3.serv ices.impl. ContainerM apper.serv ice(Contai nerMapper. java:165) at com.sun.grizzly.http.Proce ssorTask.i nvokeAdapt er(Process orTask.jav a:791) at com.sun.grizzly.http.Proce ssorTask.d oProcess(P rocessorTa sk.java:69 3) at com.sun.grizzly.http.Proce ssorTask.p rocess(Pro cessorTask .java:954) at com.sun.grizzly.http.Defau ltProtocol Filter.exe cute(Defau ltProtocol Filter.jav a:170) at com.sun.grizzly.DefaultPro tocolChain .executePr otocolFilt er(Default ProtocolCh ain.java:1 35) at com.sun.grizzly.DefaultPro tocolChain .execute(D efaultProt ocolChain. java:102) at com.sun.grizzly.DefaultPro tocolChain .execute(D efaultProt ocolChain. java:88) at com.sun.grizzly.http.HttpP rotocolCha in.execute (HttpProto colChain.j ava:76) at com.sun.grizzly.ProtocolCh ainContext Task.doCal l(Protocol ChainConte xtTask.jav a:53) at com.sun.grizzly.SelectionK eyContextT ask.call(S electionKe yContextTa sk.java:57 ) at com.sun.grizzly.ContextTas k.run(Cont extTask.ja va:69) at com.sun.grizzly.util.Abstr actThreadP ool$Worker .doWork(Ab stractThre adPool.jav a:330) at com.sun.grizzly.util.Abstr actThreadP ool$Worker .run(Abstr actThreadP ool.java:3 09) at java.lang.Thread.run(Threa d.java:680 )
i think that the problem is in the @XmlRootElement , i dont found where write it ... Help me please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.