• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enterbrise bean with nullpointerexception :-(

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
take a look at this,
https://coderanch.com/t/217808/ORM/java/EJB-HibernateException-EntityManager-remove-object
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic