开发者

Google App Engine JDO Persistence Manager and 500 server error

I keep getting a 500 error everytime to run my service, since the google message tells mme almost nothing i began uploading the service and commenting parts out. It seems to work fine with out using the JDO persistence manager object. It would be great if someone can take a quick look at my code and tell me if I am using the JDO Persistence Manager wrong. This would help me alot.

@Path("/surveymakerpro/")
public class SurveyResource {

    // JDO Persistence object
    private PersistenceManager surveyDataStore = SurveyPersistenceManagerFactory
            .get().getPersistenceManager();

    @GET
    @Produces({ "application/xml", "application/json" })
    @Path("/survey/{surveyName}/")
    public Survey getSurvey(@PathParam("surveyName") String surveyName) {

        Survey e = surveyDataStore.getObjectById(Survey.class, surveyName);

        return e;
    }

    @GET
    @Produces({ "application/xml", "application/json" })
    @Path("/allsurveys")
    public SurveyNames getListOfSurveys() {

        //test code

        SurveyQuestion one = new SurveyQuestion();
        one.setAnswer("Yes");
        one.setId(3);
        one.setQuestion("Do you like cake?");

        SurveyQuestion two = new SurveyQuestion();
        two.setAnswer("Yes");
        two.setId(3);
        two.setQuestion("Do you like cake?");

        List<SurveyConverter> sur = new ArrayList<SurveyConverter>();
        sur.add(new SurveyConverter(one));
        sur.add(new SurveyConverter(two));

        Survey surv = new Survey(sur);

        surv.setSurveyName("Test Survey");

        Survey survv = new Survey(sur);
        survv.setSurveyName("sdd");


        surveyDataStore.makePersistent(surv);
        surveyDataStore.makePersistent(survv);

        //test code

        List<String> surveyNames = new ArrayList<String>();

        Extent<Survey> extent = surveyDataStore.getExtent(Survey.class, false);

        for (Survey survey : extent) {

            surveyNames.add(survey.getSurveyName());

        }
        extent.closeAll();

        SurveyNames surveyName = new SurveyNames(surveyNames);

        surveyDataStore.close();
        return surveyName;

    }

    @POST
    @Consumes({ MediaType.APPLICATION_XML })
    @Path("/addSurvey")
    public void addSurvey(Survey survey) {

        surveyDataStore.makePersistent(survey);

    }

    // This method gets a survey object stores its data into a TakenSurvey
   开发者_C百科 // object and stores it
    // in the Google data store.
    @POST
    @Consumes({ MediaType.APPLICATION_XML })
    @Path("/addTakenSurvey")
    public void addTakenSurvey(Survey survey) {

        List<SurveyConverter> surveyConverter = survey.getSurvey();
        TakenSurvey takenSurvey = new TakenSurvey();

        for (SurveyConverter s : surveyConverter) {

            TakenSurveyQuestion tsq = new TakenSurveyQuestion(s.getId(),
                    s.getQuestion(), s.getAnswer());

            takenSurvey.getSurvey().add(tsq);
        }

        surveyDataStore.makePersistent(takenSurvey);

    }

    @GET
    @Produces({ "application/xml", "application/json" })
    @Path("/analysis/{surveyName}/{question}/")
    public SurveyDataConverter analyzeSurveys(
            @PathParam("surveyName") String surveyName,
            @PathParam("question") String questionNum) {

        Extent<TakenSurvey> extent = surveyDataStore.getExtent(
                TakenSurvey.class, false);

        List<TakenSurvey> takenSurveys = new ArrayList<TakenSurvey>();

        for (TakenSurvey ts : extent) {

            if (ts.getSurveyName().equals(surveyName)) {

                takenSurveys.add(ts);
            }

        }
        extent.closeAll();

        SurveyAnalyzer analyze = new SurveyAnalyzer(takenSurveys);
        analyze.getData();
        SurveyData data = analyze.getSurveyData(Integer.parseInt(questionNum));

        return new SurveyDataConverter(data);

    }

    // remove survey

    // remove taken survey

}


Don't expect the error page to give you a stacktrace - that would be extremely bad practice for both security and usability reasons. Instead, exceptions are logged in the App Engine admin console, under 'logging'. The stacktrace there will tell you what's wrong; if you still can't figure it out, update your question to include it so we can help further.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜