• 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

Finder problem - message to Kyle

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kyle,
Believe me that it is not an error in coding or database, that in my program FindByPrimaryKey doesn�t work. I put System.out.println() to check all parameter and they are okay. Primary key object.toString() is okay and has exactly the same value like I�ve got while testing this method in UTC. I even created finder with simple string argument FindByName (String name). And I cannot call it from code too. The same error just after I call it. Then I created FindByNumber which takes integer. All the same�
So I think something is not set up properly.
Do you have any idea?
Thanks
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you getting any messages in the console at all?
Kyle
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a part of console output:
[1/21/03 20:41:03:506 EST] 29cb22cc SystemOut O my servlet init after homelookup =
[1/21/03 20:41:03:697 EST] 29cb22cc SystemOut O big dec user 10270
[1/21/03 20:41:03:707 EST] 29cb22cc SystemOut O primarykey echargeit.entity.UserfileKey@4dba2
[1/21/03 20:41:03:707 EST] 29cb22cc SystemOut O before findbyNumber
[1/21/03 20:41:03:707 EST] 29cb22cc SystemOut O naming excep
[1/21/03 20:41:03:707 EST] 29cb22cc SystemErr R java.lang.NullPointerException
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at echargeitservlet.LogonServlet.doPost(LogonServlet.java:76)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[1/21/03 20:41:03:727 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[1/21/03 20:41:03:737 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
[1/21/03 20:41:03:737 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[1/21/03 20:41:03:737 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[1/21/03 20:41:03:747 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[1/21/03 20:41:03:787 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
[1/21/03 20:41:03:787 EST] 29cb22cc SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[1/21/03 20:41:03:787 EST] 29cb22cc SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
[1/21/03 20:41:03:797 EST] 29cb22cc SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
[1/21/03 20:41:03:797 EST] 29cb22cc SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
Thanks
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be getting a naming exception:
[1/21/03 20:41:03:707 EST] 29cb22cc SystemOut O naming excep
Why don't you attach the full exception to the output text (e.g. do something like:
} catch (Naming Exception e) {
System.out.println("Naming Exception:" + e);
}
Where "e" is the exception you catch -- that would make debugging easier. And also, try printing out the reference to the LocalHome as well -- I'm still not convinced you're getting it returned back.

(P.S. Posting the full most recent code snippet you are using for lookup would help too).
[ January 22, 2003: Message edited by: Kyle Brown ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jenny,
It seems like you are getting NameNotFoundException...Make sure the following
1)look up name should match you have given in JNDI
2)make sure you have ejb-ref entry in your web.xml deployment descriptor
3)make sure you have all the client classes(Remote , Home and Key classes in your classpath)
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for helping me...
I post my resent console output and code. They are not too big. Looks like it doesn't even go to my error page...
How can I check the classpath?
[1/22/03 13:13:05:879 EST] 6675d74a WsServer A WSVR0001I: Server server1 open for e-business
[1/22/03 13:13:10:326 EST] 3cbf975d WebGroup I SRVE0180I: [EchargeItWeb] [/EchargeItWeb] [Servlet.LOG]: /Logon.jsp: init
[1/22/03 13:13:32:788 EST] 3cbf975d WebGroup I SRVE0180I: [EchargeItWeb] [/EchargeItWeb] [Servlet.LOG]: LogonServlet: init
[1/22/03 13:13:32:818 EST] 3cbf975d SystemOut O my servlet init before lookup
[1/22/03 13:13:33:029 EST] 3cbf975d SystemOut O my servlet init after homelookup
[1/22/03 13:13:33:059 EST] 3cbf975d SystemOut O big decimal user: 10153
[1/22/03 13:13:33:059 EST] 3cbf975d SystemOut O primarykey: echargeit.entity.UserfileKey@4cd77
[1/22/03 13:13:33:059 EST] 3cbf975d SystemOut O before findbyPK
[1/22/03 13:13:34:130 EST] 3cbf975d WebGroup E SRVE0026E: [Servlet Error]-[LogonServlet]: java.lang.NullPointerException
at echargeitservlet.LogonServlet.doPost(LogonServlet.java:78)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:258)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:872)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:491)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:173)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:199)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:592)
public class LogonServlet extends HttpServlet
{

String password = null;

public echargeit.entity.UserfileLocalHome home;
public echargeit.entity.UserfileLocal userfilelocal;

public void init() throws javax.servlet.ServletException
{
//super.init(config);
try
{
System.out.println("my servlet init before lookup");
InitialContext ctx = new InitialContext();
echargeit.entity.UserfileLocalHome home =
(echargeit.entity.UserfileLocalHome)ctx.lookup
("java:comp/env/ejb/echargeit/entity/UserfileLocalHome");

System.out.println("my servlet init after homelookup ");
}
catch(NamingException e)
{
e.printStackTrace();
System.out.println("naming exc in my servlet init: " + e);
}
}
public void doPost(
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException
{

String dbpassword = null;

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("&ItHTML>");
out.println("&ItHEAD>");
out.println("&ItTITLE>Logon Servlet&IT/TITLE>");
out.println("&It/HEAD>");
out.println("&ItBODY>");

HttpSession session = request.getSession(true);
String userno = request.getParameter("userid");
//int userid = Integer.valueOf(userno).intValue();
double userid = Double.valueOf(userno).doubleValue();
String password = request.getParameter("password");
BigDecimal user = new BigDecimal(userid);
System.out.println("big decimal user: " + user.toString());

echargeit.entity.UserfileKey primarykey =
new echargeit.entity.UserfileKey(user);
System.out.println("primarykey: " + primarykey.toString());

try
{
System.out.println("before findbyPK");

userfilelocal = home.findByPrimaryKey(primarykey);
System.out.println("after findByPrimaryKey userfilelocal: " + userfilelocal.toString());
}
catch (FinderException e)
{
System.out.println("finder exception: " + e);
System.out.println("userfilelocal: " + userfilelocal.toString());
e.printStackTrace();
response.sendRedirect("error.jsp");

}
try
{
dbpassword = userfilelocal.getPassword();
System.out.println("dbpassword: " + dbpassword);
if (password.equals(dbpassword))
{

session.setAttribute("userno", userno);
System.out.println("sess user " + userno );
String firstname = userfilelocal.getStaff_firstname();
System.out.println("first name " + firstname );
String lastname = userfilelocal.getStaff_surname();
session.setAttribute("firstname", firstname);
session.setAttribute("lastname", lastname);
response.sendRedirect("mainmenu.jsp");
}
else
{//Logon failed
session.removeAttribute("user");
System.out.println("login failed userno&password: " + userno + " " + password );
response.sendRedirect("error.jsp");
}
}
catch (Exception e)
{
System.out.println("except: " + e);
e.printStackTrace();
response.sendRedirect("error.jsp");
}
}


public void doGet(
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException
{
}
}
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that the home variable may be null. Would you mind inserting a System.out.println() after you obtain the home (e.g. right after you do the lookup) and print out the object reference, e.g.
System.out.println("home = " + home);

Don't worry about the classpath. You are in WSAD, it will not be your problem.
Kyle
WHOOPS! UPDATE! In fact, I KNOW that home is null. In your code you have:
echargeit.entity.UserfileLocalHome home =
(echargeit.entity.UserfileLocalHome)ctx.lookup
("java:comp/env/ejb/echargeit/entity/UserfileLocalHome");
Note that you've declared "home" as a local variable, so THAT is what gets set, and not the instance variable! Change the line to read:
home =
(echargeit.entity.UserfileLocalHome)ctx.lookup
("java:comp/env/ejb/echargeit/entity/UserfileLocalHome");
and it should work.
[ January 22, 2003: Message edited by: Kyle Brown ]
 
Jenny Kalinina
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kyle,
Really stupid error!!! Sorry about that
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem at all. I'm just glad it wasn't some obscure WSAD bug...
Kyle
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic