AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-3138238

madx's questions

Martin Hope
madx
Asked: 2024-09-05 02:58:59 +0800 CST

在 Jetty 12 上部署 Jakarta EE 应用程序:从 jetty-ee10-maven-plugin 到 Jetty 上的部署、ClassNotFoundException 和 CDIProvider 问题

  • 5

我有一个在 jetty 上运行的 jakarta ee 项目,我需要 cdi 和 faces。在开发过程中,我曾经通过jetty-ee10-maven-plugin运行 的插件来运行它mvn jetty:run。在本地执行mvn jetty:run可以正常工作,没有任何问题。

现在项目已经基本准备就绪,我相信导出 war 并将其部署到 jetty 网络服务器上12.0.4会很容易。

我的重要部分pom.xml如下:

<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>web</artifactId>
    <version>1.0.7</version>
    <packaging>war</packaging>
    <name>xyz_web</name>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <jetty.version>12.0.9</jetty.version>
        <jetty.port>8080</jetty.port>        
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>13.0.8</version>
            <classifier>jakarta</classifier>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.primefaces.extensions/primefaces-extensions -->
        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>13.0.8</version>
            <classifier>jakarta</classifier>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jakarta.platform/jakarta.jakartaee-api -->
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>${jakartaee-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jakarta.inject/jakarta.inject-api -->
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <version>2.0.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jakarta.ejb/jakarta.ejb-api -->
        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <version>4.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>4.0.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>5.1.2.Final</version>
            <exclusions>
                <exclusion>
                    <groupId>jakarta.el</groupId>
                    <artifactId>jakarta.el-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>4.3</version>
        </dependency>

        <!-- Other dependencies not related to jetty or server -->
        <!-- Other dependencies not related to jetty or server -->
        <!-- Other dependencies not related to jetty or server -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <release>${maven.compiler.release}</release>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>**/web.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <webXml>${project.build.directory}/web.xml</webXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty.ee10</groupId>
                <artifactId>jetty-ee10-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <!-- see https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#jetty-run-goal -->
                    <webApp>
                        <contextPath>/</contextPath>
                    </webApp>
                    <scan>5</scan>
                    <webXml>${project.build.directory}/web.xml</webXml>
                    <httpConnector>
                        <host>0.0.0.0</host>
                        <port>${jetty.port}</port>
                        <idleTimeout>300000</idleTimeout>
                    </httpConnector>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.jetty.ee10</groupId>
                        <artifactId>jetty-ee10-cdi</artifactId>
                        <version>${jetty.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>

        <!-- Parses all files in the specified directory and replaces properties expressions if found -->
        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                <includes>
                    <include>web.xml</include>
                </includes>
                <filtering>true</filtering>
                <targetPath>${project.build.directory}</targetPath>
            </resource>
        </resources>
    </build>
</project>

当我在该云码头服务器上部署 war 文件时出现以下错误:

Caused by:
java.lang.ClassNotFoundException: jakarta.websocket.server.ServerContainer
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:496)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at com.sun.faces.config.FacesInitializer.handleWebSocketConcerns(FacesInitializer.java:251)
at com.sun.faces.config.FacesInitializer.onStartup(FacesInitializer.java:123)
at org.eclipse.jetty.ee10.servlet.ServletContainerInitializerHolder.doStart(ServletContainerInitializerHolder.java:155)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler$ServletContainerInitializerStarter.doStart(ServletContextHandler.java:3041)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.startContext(ServletContextHandler.java:1289)
at org.eclipse.jetty.ee10.webapp.WebAppContext.startContext(WebAppContext.java:1223)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.lambda$doStart$0(ServletContextHandler.java:1042)
at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call(ContextHandler.java:1147)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.doStart(ServletContextHandler.java:1039)
at org.eclipse.jetty.ee10.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:522)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:162)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.pathAdded(ScanningAppProvider.java:293)
at org.eclipse.jetty.deploy.providers.ContextProvider.pathAdded(ContextProvider.java:520)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.pathAdded(ScanningAppProvider.java:69)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:902)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:868)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:775)
at org.eclipse.jetty.util.Scanner$ScanTask.run(Scanner.java:147)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

因此,即使我不确定我是否尝试在内部添加此依赖项pom.xml。

<!-- Added to solve "java.lang.ClassNotFoundException: jakarta.websocket.server.ServerContainer" -->
<dependency>
    <groupId>org.glassfish.tyrus.bundles</groupId>
    <artifactId>tyrus-standalone-client</artifactId>
    <version>2.2.0</version>
</dependency>

现在我收到此错误:

java.lang.IllegalStateException: Unable to locate CDIProvider
at jakarta.enterprise.inject.spi.CDI.findAllProviders(CDI.java:139)
at jakarta.enterprise.inject.spi.CDI.getCDIProvider(CDI.java:92)
at jakarta.enterprise.inject.spi.CDI.current(CDI.java:65)
at org.jboss.weld.module.web.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:89)
at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextInitialized(ForwardingServletListener.java:34)
at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:70)
at org.eclipse.jetty.ee10.servlet.ServletContainerInitializerHolder.doStart(ServletContainerInitializerHolder.java:155)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:171)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler$ServletContainerInitializerStarter.doStart(ServletContextHandler.java:3041)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.startContext(ServletContextHandler.java:1289)
at org.eclipse.jetty.ee10.webapp.WebAppContext.startContext(WebAppContext.java:1223)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.lambda$doStart$0(ServletContextHandler.java:1042)
at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call(ContextHandler.java:1147)
at org.eclipse.jetty.ee10.servlet.ServletContextHandler.doStart(ServletContextHandler.java:1039)
at org.eclipse.jetty.ee10.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:522)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:162)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.pathAdded(ScanningAppProvider.java:293)
at org.eclipse.jetty.deploy.providers.ContextProvider.pathAdded(ContextProvider.java:520)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.pathAdded(ScanningAppProvider.java:69)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:902)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:868)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:775)
at org.eclipse.jetty.util.Scanner$ScanTask.run(Scanner.java:147)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

我尝试了很多其他配置,添加了许多其他依赖项,但我找不到我所缺少的东西。

云端的Jetty服务器版本是12.0.4。我的Jetty Serverstart.ini文件如下:

#===========================================================
# Jetty Startup 
#===========================================================

# To disable the warning message, comment the following line
--module=home-base-warning

# --------------------------------------- 
# Module: ext
# Adds all jar files discovered in $JETTY_HOME/lib/ext
# and $JETTY_BASE/lib/ext to the servers classpath.
# --------------------------------------- 
--module=ext


# --------------------------------------- 
# Module: server
# Enables the core Jetty server on the classpath.
# --------------------------------------- 
--module=server

### Common HTTP configuration
## Scheme to use to build URIs for secure redirects
# jetty.httpConfig.secureScheme=https

## Port to use to build URIs for secure redirects
jetty.httpConfig.securePort=443

# --------------------------------------- 
# Module: jsp
# Enables JSP for all webapplications deployed on the server.
# --------------------------------------- 
--module=ee10-jsp
--module=ee9-jsp
--module=ee8-jsp


# --------------------------------------- 
# Module: resources
# Adds the $JETTY_HOME/resources and/or $JETTY_BASE/resources
# directory to the server classpath. Useful for configuration
# property files (eg jetty-logging.properties)
# --------------------------------------- 
--module=resources


# --------------------------------------- 
# Module: deploy
# Enables webapplication deployment from the webapps directory.
# --------------------------------------- 
--module=deploy
jetty.deploy.scanInterval=1

--module=ee10-deploy
jetty.deploy.scanInterval=1

--module=ee9-deploy
jetty.deploy.scanInterval=1

--module=ee8-deploy
jetty.deploy.scanInterval=1

# --------------------------------------- 
# Module: jstl
# Enables JSTL for all webapplications deployed on the server
# --------------------------------------- 
--module=ee10-jstl
--module=ee9-jstl
--module=ee8-jstl

# --------------------------------------- 
# Module: websocket
# Enable websockets for deployed web applications
# --------------------------------------- 
--module=websocket-jetty


# --------------------------------------- 
# Module: http
# Enables a HTTP connector on the server.
# By default HTTP/1 is support, but HTTP2C can
# be added to the connector with the http2c module.
# --------------------------------------- 
--module=http

### HTTP Connector Configuration

## Connector port to listen on
jetty.http.port=80

## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY or CUSTOMn
# jetty.http.compliance=RFC7230_LEGACY
# --------------------------------------- 
# Module: requestlog
# Enables a NCSA style request log.
# --------------------------------------- 
--module=requestlog

## Logging directory (relative to $jetty.base)
jetty.requestlog.dir=../../var/log/jetty

# --------------------------------------- 
# Module: gzip
# Enable GzipHandler for dynamic gzip compression
# for the entire server.
# --------------------------------------- 
--module=gzip
maven
  • 1 个回答
  • 19 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve