jvanhouter / t3-pcc

Team 3 - CSC 429 Professional Clothes Closet Project
3 stars 1 forks source link

Unable to Add ArticleType - Invalid Barcode prefix #2

Open eriknystrom opened 6 years ago

eriknystrom commented 6 years ago

While attempting to add an Article Type, entered in test data of 25, Halter Top, HT. After clicking submit, the field validator stated that "25" was not numeric.

Steps to reproduce:

  1. Launch the Closet application
  2. Under Article Types, click Add
  3. Enter test data: 25, Halter Top, HT
  4. Click Submit

Expected Results: For the new Article Type to be added to the system

Actual Results: Article Type is not added, error message:

ERROR: Invalid barcode prefix: 25! Must be numerical.

IAmAbszol commented 6 years ago

Hey Erik, I dove into the AddArticleTypeTransaction object where this call was being processed and found something interesting that Mitra didn't account for which led to a misleading error output.

The Barcode is valid and isn't NULL but what is NULL is the Database connection. Upon issuing the line excep.printStackTrace(); on where the error is to be handled, this comes up.

java.lang.NullPointerException at database.SQLInsertStatement.(SQLInsertStatement.java:90) at database.Persistable.insertAutoIncrementalPersistentState(Persistable.java:663) at model.ArticleType.updateStateInDatabase(ArticleType.java:182) at model.ArticleType.update(ArticleType.java:164) at model.AddArticleTypeTransaction.processTransaction(AddArticleTypeTransaction.java:93) at model.AddArticleTypeTransaction.stateChangeRequest(AddArticleTypeTransaction.java:145) at userinterface.AddArticleTypeView$1.handle(AddArticleTypeView.java:195) at userinterface.AddArticleTypeView$1.handle(AddArticleTypeView.java:177) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Node.fireEvent(Node.java:8413) at javafx.scene.control.Button.fire(Button.java:185) at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748)

The first few lines give away the error

java.lang.NullPointerException at database.SQLInsertStatement.(SQLInsertStatement.java:90) at database.Persistable.insertAutoIncrementalPersistentState(Persistable.java:663) at model.ArticleType.updateStateInDatabase(ArticleType.java:182) at model.ArticleType.update(ArticleType.java:164) at model.AddArticleTypeTransaction.processTransaction(AddArticleTypeTransaction.java:93)

So the error is really being relayed to the ArticleType object which is called by the AddArticleTypeTransaction -> myArticleType.update() call.

Suggestion We should look more at the database to completely verify a linking with the JDBC works, I saw the email noting connection problems and this is one of them. Though we now know that a new error check for a failure to connect is in order, possibly place it higher in the hierarchy of the framework to counter this problem.

eriknystrom commented 6 years ago

Yea I verified last night that the 5.1.7 driver doesn't work with the SQL database. Need to use 5.1.45. still seemed to have the issue.

Regards,

On Feb 23, 2018 12:30 PM, "Kyle" notifications@github.com wrote:

Hey Erik, I dove into the AddArticleTypeTransaction object where this call was being processed and found something interesting the Mitra didn't account for which led to a misleading error output.

The Barcode is valid and isn't NULL but what is NULL is the Database connection. Upon issuing the line excep.printStackTrace(); on where the error is to be handled, this comes up.

java.lang.NullPointerException at database.SQLInsertStatement.(SQLInsertStatement.java:90) at database.Persistable.insertAutoIncrementalPersisten tState(Persistable.java:663) at model.ArticleType.updateStateInDatabase(ArticleType.java:182) at model.ArticleType.update(ArticleType.java:164) at model.AddArticleTypeTransaction.processTransaction( AddArticleTypeTransaction.java:93) at model.AddArticleTypeTransaction.stateChangeRequest( AddArticleTypeTransaction.java:145) at userinterface.AddArticleTypeView$1.handle(AddArticleTypeView.java:195) at userinterface.AddArticleTypeView$1.handle(AddArticleTypeView.java:177) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent( CompositeEventHandler.java:86) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent( EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent( EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent( CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Node.fireEvent(Node.java:8413) at javafx.scene.control.Button.fire(Button.java:185) at com.sun.javafx.scene.control.behavior.ButtonBehavior. mouseReleased(ButtonBehavior.java:182) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1. handle(BehaviorSkinBase.java:96) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1. handle(BehaviorSkinBase.java:89) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord. handleBubblingEvent(CompositeEventHandler.java:218) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent( CompositeEventHandler.java:80) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent( EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent( EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent( CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent( BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent( EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at com.sun.javafx.tk.quantum.GlassViewEventHandler$ MouseEventNotification.run(GlassViewEventHandler.java:394) at com.sun.javafx.tk.quantum.GlassViewEventHandler$ MouseEventNotification.run(GlassViewEventHandler.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$ handleMouseEvent$353(GlassViewEventHandler.java:432) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock( QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent( GlassViewEventHandler.java:431) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$ 147(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748)

The first few lines give away the error

java.lang.NullPointerException at database.SQLInsertStatement.(SQLInsertStatement.java:90) at database.Persistable.insertAutoIncrementalPersisten tState(Persistable.java:663) at model.ArticleType.updateStateInDatabase(ArticleType.java:182) at model.ArticleType.update(ArticleType.java:164) at model.AddArticleTypeTransaction.processTransaction( AddArticleTypeTransaction.java:93)

So the error is really being relayed to the ArticleType object which is called by the AddArticleTypeTransaction -> myArticleType.update() call.

Suggestion We should look more at the database to completely verify a linking with the JDBC works, I saw the email noting connection problems and this is one of them. Though we now know that a new error check for a failure to connect is in order, possibly place it higher in the hierarchy of the framework to counter this problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jvanhouter/t3-pcc/issues/2#issuecomment-368080261, or mute the thread https://github.com/notifications/unsubscribe-auth/AGD81pVdmm44zlKW61x2udc_ZO97yWbaks5tXvXPgaJpZM4SQae5 .

eriknystrom commented 6 years ago

@IAmAbszol Or in sleep deprived state did not fully test 5.1.45. Was able to add article type.

This is no longer an issue as originally written. Got the DB transactions to work just never verified this again. Knowing this though we should probably put in checks to prevent DB null connections causing wrong errors.