开发者

Java Netbeans error

I've been following the 'Netbeans E-Commerce tutorial', and have am currently on this step: http://netbeans.org/kb/docs/javaee/ecommerce/entity-session.html

I have fully configured my Window 7 account as per that page, with NetBeans 6.9.1, Glassfish server and MySQL.

I'm getting an error 500 when executing 'Category' page (log extract below). The error manifests itself when I complete step 3 in the 'selected category' sub-section of the 'Accessing Data with EJBs' this page. The line in question is:

// get selected category
selectedCategory = categoryFacade.find(Short.parseShort(categoryId));

If I comment this line out, the bug goes away.

The log file snippet is here:

[#|2010-09-29T18:32:32.570+0100|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=30;_ThreadName=http-thread-pool-8080-(2);|StandardWrapperValve[Controller]: PWC1406: Servlet.service() for servlet Controller threw exception
javax.ejb.EJBException
 at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5119)
 at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5017)
 at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4805)
 at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2004)
 at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
 at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
 at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
 at $Proxy355.find(Unknown Source)
 at session.__EJB31_Generated__CategoryFacade__Intf____Bean__.find(Unknown Source)
 at controller.ControllerServlet.doGet(ControllerServlet.java:68)

Line 68 in the ControllerServlet code is the one identified above.

My experience with both Java and Netbeans is sufficiently light that I'm not even sure how to go about starting to debug this. I've followed the tutorial pretty closely, so it should not be something I've missed - but mistakes do happen.

I understand an outright solution based on the information contained would be difficult. If there is any further information required, please ask. Failing that, if anyone has any suggestions on how I can further investigate this on my 开发者_Go百科own, I'd be very grateful.

I always think cracking problems is the best way to learn, but it is pretty frustrating as well.

Update: I've been running through the NetBeans debugger. It appears that the problem is with the cast code (Short.parseShort(categoryId)). When I replace this with a simple numeral it works. e.g. this code works // get selected category selectedCategory = categoryFacade.find(1);

Does anyone have any ideas why the cast is failing? categoryId is confirmed as a string with a value of "1" in the debugger...


Okay, I've cracked this. It was obviously my fault...

The table identity should have been set up as a short, instead I set it up as an integer. Therefore by casting the 'categoryId' string to short and passing it into the find method, I was passing in the wrong data type.

Replacing the 'Short.parseShort(categoryId)' argument with a 'Integer.parseInt(categoryId)' fixed the problem.

For those that took the time to read this; thank you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜