Netbeans 尝试运行 Web 应用程序来创建/读取/更新/删除 MySQL 数据库表条目时出现错误

发布于 2025-01-17 05:14:29 字数 1570 浏览 1 评论 0原文

我的程序有问题。我需要创建一个 Web 应用程序,连接到我的 MySQL 数据库,并且能够创建、读取、更新和删除数据库表中的条目。

我正在使用本教程来创建它:

https://www.youtube.com/watch ?v=TUKV-HITSrs

编辑:我已经下载了 Apache Tomee Webprofile 8.0.10,并使用 Java EE 7 作为平台。 (我尝试按照建议下载 Java EE 8,但 GlassFish5 最终位于该文件夹中,并且我不确定如何添加 Java EE 8 作为新平台)。我仍在使用 Netbeans 12.6。

我现在可以运行该程序,并创建一个网页: index.xhtml

但是,当我单击任一链接时,我收到以下错误页面:

An Error Occurred:
javax.el.ELException: Error reading [items] on type [storeDB.CustomersController$$OwbNormalScopeProxy0]

viewId=/customers/List.xhtml
location=C:\Users\jades\Desktop\Java\storeDB\target\storeDB-1\customers\List.xhtml
phaseId=RENDER_RESPONSE(6)

Caused by:
java.lang.NullPointerException - The bean encountered a non-application exception; nested exception is: java.lang.NullPointerException
at storeDB.AbstractFacade.findRange(AbstractFacade.java:47)

/customers/List.xhtml at line 17 and column 138 rendered="#{customersController.items.rowCount == 0}"
+ Stack Trace
+ Component Tree
+ Scoped Variables

AstractFacade.java 第 47 行是这样的:

javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();

List.xhtml 第 17 行是这样的:

<h:outputText escape="false" value="#{bundle.ListCustomersEmpty}" rendered="#{customersController.items.rowCount == 0}"/>

有谁知道这些行有什么问题吗?我没有看到任何错误符号或红色下划线。

I'm having trouble with my program. I need to make a Web application that connects to my MySQL database and is able to Create, Read, Update and Delete entries in the database tables.

I am using this tutorial to create it:

https://www.youtube.com/watch?v=TUKV-HITSrs

Edit: I have since downloaded Apache Tomee Webprofile 8.0.10, and am using Java EE 7 as the platform. (I tried downloading Java EE 8 as recommended, but GlassFish5 ended up being in the folder, and I wasn't sure how to add Java EE 8 as a new platform). I'm still using Netbeans 12.6.

I now can run the program, and a web page is created:
index.xhtml

However, when I click on either of the links, I get this error page:

An Error Occurred:
javax.el.ELException: Error reading [items] on type [storeDB.CustomersController$OwbNormalScopeProxy0]

viewId=/customers/List.xhtml
location=C:\Users\jades\Desktop\Java\storeDB\target\storeDB-1\customers\List.xhtml
phaseId=RENDER_RESPONSE(6)

Caused by:
java.lang.NullPointerException - The bean encountered a non-application exception; nested exception is: java.lang.NullPointerException
at storeDB.AbstractFacade.findRange(AbstractFacade.java:47)

/customers/List.xhtml at line 17 and column 138 rendered="#{customersController.items.rowCount == 0}"
+ Stack Trace
+ Component Tree
+ Scoped Variables

AstractFacade.java Line 47 is this:

javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();

List.xhtml Line 17 is this:

<h:outputText escape="false" value="#{bundle.ListCustomersEmpty}" rendered="#{customersController.items.rowCount == 0}"/>

Does anyone know what's wrong with these lines? I don't see any error symbols or red underlines.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文