File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enterbrise bean with nullpointerexception :-(

 
Scafuro Te
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i started a new enterprise application with many servlet which simulate a web site for student for the exam prenotation and so one.
Sometimes on running the project it works all good, sometimes, as in this case, after the correct login, the server show me this message:

exception

java.lang.NullPointerException
web.Login.processRequest(Login.java:87)
web.Login.doGet(Login.java:108)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


and here is the problem (in bold the problem, the 87 line..)...

for (Iterator itProf = profili.iterator(); itProf.hasNext() {
Profili elem = (Profili) itProf.next();

for (Iterator itCorso = corsi.iterator(); itCorso.hasNext() {
Corsi crs = (Corsi) itCorso.next();
if(elem.getIdcorso().equals(crs.getIdcorsi())){
out.println("<h2>"+crs.getIdcorsi( +"\t"+crs.getNomecorso()+"</h2><a href=/EsameAS2-war/Destroy?idProf="+elem.getIdprof()+">rimuovi</a>");
}
}
}

I mean there's a problem for the nullpointer exception, does someone know how could i resolve this little problem?
 
Scafuro Te
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved the problem with a try - catch block :-) tkx...
But now i got another exception on the destroy query...
When i try to delete from the browser an object i have this exception:

javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [ejb.Profili#1]

In which way could i solve this persistence problem?
 
Fabian Gutierrez
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well
according to the hibernate's doc this is what is happening:

"This exception is thrown when an operation would break session-scoped identity. This occurs if the user tries to associate two different instances of the same Java class with a particular identifier, in the scope of a single Session."

you will have to provide more code in order to let us identify your problem.. :-)

regards,
 
Fabian Gutierrez
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
take a look at this,
http://www.coderanch.com/t/217808/ORM/java/EJB-HibernateException-EntityManager-remove-object
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic