File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Enterbrise bean with nullpointerexception :-( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Enterbrise bean with nullpointerexception :-(" Watch "Enterbrise bean with nullpointerexception :-(" New topic
Author

Enterbrise bean with nullpointerexception :-(

Scafuro Te
Greenhorn

Joined: Oct 08, 2007
Posts: 18
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

Joined: Oct 08, 2007
Posts: 18
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

Joined: Aug 15, 2004
Posts: 22
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,


SCJP 1.4, SCWCD 1.4, SCBCD 5, SCJD 5
Fabian Gutierrez
Greenhorn

Joined: Aug 15, 2004
Posts: 22
take a look at this,
http://www.coderanch.com/t/217808/ORM/java/EJB-HibernateException-EntityManager-remove-object
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enterbrise bean with nullpointerexception :-(