如何让 Netbeans 9 在 Tomcat 上部署有效的 webapp [英] How to get Netbeans 9 to deploy a valid webapp on Tomcat

查看:18
本文介绍了如何让 Netbeans 9 在 Tomcat 上部署有效的 webapp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在运行的 Tomcat 实例;

I have a working Tomcat instance running;

  • Tomcat 9.0.10
  • OpenJDK 10.0.2

我有一个在库 JDK1.8 上编译的 Netbeans 8.2 项目,它可以在上述服务器上正常构建、部署和运行.

I have a working Netbeans 8.2 project compiled on Library JDK1.8, This builds and deploys and runs on the above server fine.

我现在正在尝试迁移到 Netbeans 9,所以我在 OpenJDK 10.0.2 JDK 上运行了一个.如果我构建相同的项目(仍然在库 JDK1.8 上),它会很好地构建和部署.但是,当它在同一台服务器上运行时,我收到以下错误;

I am now trying to move to Netbeans 9, so I have a that running on the OpenJDK 10.0.2 JDK. If I build the same project (still on Library JDK1.8), it builds and deploys fine. However, when it runs on the same server I get the following error;

javax.servlet.ServletException: Error instantiating servlet class [xxxx.xxx.xxx.TestServlet]
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.base/java.lang.Thread.run(Thread.java:844)
Root Cause

java.lang.RuntimeException: 
    xxxx.xxx.xxx.TestServlet.<init>(TestServlet.java:1)
    java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.base/java.lang.Thread.run(Thread.java:844)
Note The full stack trace of the root cause is available in the server logs.

(xxxx.xxx.xxx.TestServlet 替换为真正的 Servlet 类)

(xxxx.xxx.xxx.TestServlet replaced for real Servlet class)

它抱怨 Servlet 的第一行实际上是模板注释的/*".

It complaints about the first line of the Servlet which is actaully the "/*" of the template comment anyway.

我会认为我使用的任何 Netbeans,如果再次编译相同的 JDK1.8 JDK,两个部署的 WAR 应该是相同的并且都可以工作.Netbeans 9 似乎正在构建一些不同的东西,报告的错误并没有太大帮助.

I would have thought that which ever Netbeans I was using, if both were compiled again the same JDK1.8 JDK, both deployed WAR should be the same and both work. Netbeans 9 seems to be building something different and the error reported is not really much help.

有什么线索吗?

推荐答案

首先要注意Netbeans 9.0 RC1 仅支持 Java SE 开发...

发布 9.0,它将成为仅用于 Java SE 开发的 IDE其他功能尚未由 Oracle 捐赠,并且正在经过审计和处理,并成为 Apache 后续版本的一部分NetBeans.

Release 9.0, which will be an IDE for Java SE development only, the other features have not been donated yet by Oracle and are being audited and processed and be part of subsequent releases of Apache NetBeans.

也就是说,Apache NetBeans 9 的早期测试版提供了允许构建 Java EE 应用程序的插件,并且 NetBeans 9.0 发布后将重新引入该功能:

That said, earlier beta releases of Apache NetBeans 9 provided plugins to allow Java EE applications to be built, and that functionality will be reintroduced once NetBeans 9.0 is released:

Oracle 已审计并捐赠了所有模块以提供功能支持 JavaScript、PHP、Groovy 和企业 Java(即 JavaEE 或现在众所周知的 Jakarta EE).这些功能在一个Apache NetBeans Git 存储库中的单独分支.他们会在 Apache NetBeans 之后集成,即重新授权给 Apache(incubating) 9.0 发布.

Oracle has audited and donated all the modules for features providing support for JavaScript, PHP, Groovy, and enterprise Java (i.e., Java EE or, as it is known now, Jakarta EE). These features are on a separate branch in the Apache NetBeans Git repo. They will be integrated, i.e., relicensed to Apache, after Apache NetBeans (incubating) 9.0 is released.

您没有指定您使用的是哪个版本的 NetBeans 9(过去几个月已经有很多版本了),但是如果您 下载 NetBeans 9.0 RC1 它不提供创建 Java Web 应用程序的向导,也不能添加应用程序服务器,例如 Tomcat 或 Wildfly,也没有提供任何合适的插件.因此,大概 Java SE 范围之外的任何事情,例如 Web 应用程序的部署,都没有得到正式支持.

You didn't specify which version of NetBeans 9 you are using (there have been many in the past few months), but if you download NetBeans 9.0 RC1 it does not provide a wizard to create Java Web applications, nor is it possible to add an application server such as Tomcat or Wildfly, nor are any suitable plugins offered. So presumably anything outside the scope of Java SE, such as the deployment of web applications, is not formally supported.

但是,您仍然可以手动添加插件(风险自担)以在 Apache NetBeans 9.0 中启用 Java EE 功能:

However, you can still manually add plugins (at your own risk) to enable Java EE functionality in Apache NetBeans 9.0:

  • 工具 > 插件 > 设置标签>点击添加按钮
  • 更新中心定制器屏幕上的名称字段中输入一些值(例如我的插件"),http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gzURL 字段中,然后单击确定.
  • 这应该会在设置标签的更新中心配置列表中创建一个新条目.
  • 检查新条目应立即将插件添加到可用插件标签.就我而言,它添加了 43 个条目.
  • 点击可用插件标签,然后点击类别列以按类别对条目进行排序.
  • 检查Java Web 和EE 类别的所有条目,然后单击安装 按钮.
  • 将下载并安装插件.要确认这一点,请点击已安装标签.您应该会看到刚刚添加的插件,例如 Java EE BaseRESTful Web 服务.
  • Tools > Plugins > Settings tab > click the Add button
  • On the Update Center Customizer screen enter some value in the Name field (e.g. "My plugins"), http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz in the URL field, and click OK.
  • This should create a new entry in the Configuration of Update Centers list in the Settings tab.
  • Checking that new entry should instantly add plugins to the Available Plugins tab. In my case it added 43 entries.
  • Click the Available Plugins tab, then click the Category column to sort the entries by category.
  • Check all the entries for category Java Web and EE, and then click the Install button.
  • The plugins will be downloaded and installed. To confirm that, click the Installed tab. You should see the plugins you just added, such as Java EE Base and RESTful Web Services.

之后,您应该正确启用 Java EE 功能.那么您能否添加该功能,然后重试部署并提出建议?

After that you should have Java EE functionality properly enabled. So can you add that functionality and then retry your deployment and advise?

这篇关于如何让 Netbeans 9 在 Tomcat 上部署有效的 webapp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆