JDO Exception: Identifier unresolved(Not a static fields)

44 views
Skip to first unread message

Prashant Khaire via StackOverflow

unread,
Jun 8, 2016, 7:40:03 AM6/8/16
to google-appengin...@googlegroups.com

i am making an object persistent using JDO. I have run code numerous times. At times, i get things persisted without any error. At times, i receive the following errors.

  1. org.datanucleus.exceptions.NucleusUserException
  2. javax.jdo.JDOUserException

I dont understand why it runs successfully sometimes and why it fails sometimes. These happens very randomly. My application is validating new User during signUp. Here goes my code.

> ##    User.java(entity being persisted) ##


 @Entity
 @PersistenceCapable

 public class User {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
public String userName;

@Persistent
private String name, password, city, bikeModel, age;

public User(){

}
public User(String name, String uname, String pswd, String age, String city, String bike){
    this.name=name;
    this.userName=uname;
    this.password=pswd;
    this.age=age;
    this.city=city;
    this.bikeModel=bike;
}

public String getUserName() {
    return userName;
}
//rest of the getters
}



    //Getting SignUp form values
    String name=req.getParameter("name1");
    String uname=req.getParameter("uname1");
    String pswd=req.getParameter("pswd1");
    String age=req.getParameter("age");
    String city=req.getParameter("city");
    String bike=req.getParameter("bike");

            //PeristenceManager instance
            PersistenceManager pm = PMF.get().getPersistenceManager();

            //Creating instance for persistent entity class
     User newEntry=new User(name,uname,pswd,age,city,bike);

            //Query to match the userName entered in form and that of the dataStore user
    Query q = pm.newQuery(User.class);
    q.setFilter("userName == userNameParam");
    q.declareParameters("String userNameParam");
            try{
      List<User> results = (List<User>) q.execute(uname);
      if (!results.isEmpty()) {
                //if userName is found in DataStore
            resp.sendRedirect("invalidUser.html");  
      } else{
             //If userName is not found in dataStore
          pm.makePersistent(newEntry);          
          resp.sendRedirect("success.html");
          return;
      }
     }**strong text**
    finally{

        System.out.println("Finally!");
    }


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/37701299/jdo-exception-identifier-unresolvednot-a-static-fields
Reply all
Reply to author
Forward
0 new messages