“无主要清单属性,在服务器中。不使用主班

发布于 2025-01-25 02:09:29 字数 6123 浏览 0 评论 0原文

我要做的是让Docker使用Maven运行Tomee 8.0.0应用程序。但是,在编译应用程序时,它给了我来自标题无主清单属性的错误。

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>org.example</groupId>
    <artifactId>server</artifactId>
    <version>0.1-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomee.maven</groupId>
                <artifactId>tomee-embedded-maven-plugin</artifactId>
                <version>8.0.0</version>
                <configuration>
                    <context>ROOT</context>
                    <containerProperties>
                        <tomee.mp.scan>true</tomee.mp.scan>
                    </containerProperties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.tomee</groupId>
                        <artifactId>mp-common</artifactId>
                        <version>8.0.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
        </plugins>
    </build>
    <packaging>war</packaging>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.apache.tomee</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile</groupId>
            <artifactId>microprofile</artifactId>
            <version>2.0</version>
            <type>pom</type>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.json</groupId>
                    <artifactId>javax.json.bind-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.enterprise</groupId>
                    <artifactId>cdi-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>javax.ws.rs-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.json</groupId>
                    <artifactId>javax.json-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.annotation</groupId>
                    <artifactId>javax.annotation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.3.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

我已经尝试了以下解决方案,无需

我的问题是,因为我在应用程序中不使用任何“主”类,而是要让托梅运行应用程序,我如何包括subtest.mf正确吗?

或者,如果不是这样,我应该如何启动该应用程序,因为当前我通过执行以下命令与Docker一起运行该应用

entrypoint [“ java”,“ - jar”,“ server.war”]

What I'm trying to do is have Docker run a TomEE 8.0.0 application with Maven. However when compiling the application, it gives me the error from the title no main manifest attribute, in server.war.

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>org.example</groupId>
    <artifactId>server</artifactId>
    <version>0.1-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomee.maven</groupId>
                <artifactId>tomee-embedded-maven-plugin</artifactId>
                <version>8.0.0</version>
                <configuration>
                    <context>ROOT</context>
                    <containerProperties>
                        <tomee.mp.scan>true</tomee.mp.scan>
                    </containerProperties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.tomee</groupId>
                        <artifactId>mp-common</artifactId>
                        <version>8.0.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
        </plugins>
    </build>
    <packaging>war</packaging>

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.apache.tomee</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile</groupId>
            <artifactId>microprofile</artifactId>
            <version>2.0</version>
            <type>pom</type>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.json</groupId>
                    <artifactId>javax.json.bind-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.enterprise</groupId>
                    <artifactId>cdi-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>javax.ws.rs-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.json</groupId>
                    <artifactId>javax.json-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.annotation</groupId>
                    <artifactId>javax.annotation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.3.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

I've tried the following solutions without avail

My question is, because I'm not using any "main" class within the application, but have TomEE running the application, how can I include the manifest.mf correctly?

Or, if this is not the case, how should I start the application, because currently I run the application with Docker through doing the following command

ENTRYPOINT ["java","-jar","server.war"]

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心病无药医 2025-02-01 02:09:29

来自java

The java command starts a Java application. It does this by starting the Java Runtime Environment (JRE), loading the specified class, and calling that class's main() method. The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. The method declaration has the following form:

    public static void main(String[] args)

By default, the first argument that is not an option of the java command is the fully qualified name of the class to be called. If the -jar option is specified, its argument is the name of the JAR file containing class and resource files for the application. The startup class must be indicated by the Main-Class manifest header in its source code.

您正在尝试进行战争,与罐子不同,它不能独立运行,但需要一个容器;在你的情况下。

https://github.com/tomitribe/docker-docker-tomee 以及如何将战争添加到图像中。

From the java tool specs

The java command starts a Java application. It does this by starting the Java Runtime Environment (JRE), loading the specified class, and calling that class's main() method. The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. The method declaration has the following form:

    public static void main(String[] args)

By default, the first argument that is not an option of the java command is the fully qualified name of the class to be called. If the -jar option is specified, its argument is the name of the JAR file containing class and resource files for the application. The startup class must be indicated by the Main-Class manifest header in its source code.

You're trying to run a war, and unlike a jar it cannot be run standalone but it requires a container; in your case TomEE.

https://github.com/tomitribe/docker-tomee descibes how you should start tomee, and also how to add your war to the image.

待天淡蓝洁白时 2025-02-01 02:09:29

最终,在对Robert Scholte的提示感到困惑之后,这帮助我搜索了解决方案之后,确实不是在pom.xml.xml中更重要Dockerfile。在旧的Dockerfile中,我试图将.war作为.jar文件运行。

https://github.com/tomitribe/docker-bome/docker-come 我结束时,请稍微跟随设置。在设置以下dockerfile上,

FROM maven:3.8.3-jdk-11-slim AS build
RUN mkdir -p /workspace
WORKDIR /workspace
COPY pom.xml /workspace
COPY src /workspace/src
RUN mvn -B -f pom.xml clean package -DskipTests

FROM openjdk:11-jdk-slim
RUN apt-get update; apt-get -y install curl gpg
ENV PATH /workspace/tomee/bin:$PATH
RUN mkdir -p /workspace/tomee
WORKDIR /workspace/tomee

RUN set -xe; \
  for key in \
  # Matt Hogstrom <[email protected]>
  9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
  # Jeremy Whitlock <[email protected]>
  F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
  # Richard Kenneth McGuire (CODE SIGNING KEY) <[email protected]>
  223D3A74B068ECA354DC385CE126833F9CF64915 \
  # Jonathan Gallimore <[email protected]>
  DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
  # Jarek Gawor (CODE SIGNING KEY) <[email protected]>
  7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
  # Jarek Gawor <[email protected]>
  B8B301E6105DF628076BD92C5483E55897ABD9B9 \
  # Andy Gumbrecht (TomEE Code Signing) <[email protected]>
  FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
  # Romain Manni-Bucau <[email protected]>
  A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
  # Mark Struberg (Apache) <[email protected]>
  82D8419BA697F0E7FB85916EE91287822FDB81B1 \
  # David Blevins <[email protected]>
  B7574789F5018690043E6DD9C212662E12F3E1DD \
  # Xu Hai Hong (Ivan Xu @ Geronimo) <[email protected]>
  C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  678F2D98F1FD9643811639FB622B8F2D043F71D8 \
  # Romain Manni-Bucau <[email protected]>
  BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
  # Romain Manni-Bucau <[email protected]>
  D11DF12CC2CA4894BDE638B967C1227A2678363C \
  # Roberto Cortez (Apache Signing Key) <[email protected]>
  C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
  # David Blevins <[email protected]>
  626C542EDA7C113814B77AF09C04914D63645D20 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  3948829384B269D333CC5B98358807C52B4B0E23 \
  # Richard Zowalla (Code Signing Key) <[email protected]>
  B83D15E72253ED1104EB4FBBDAB472F0E5B8A431 \
  ; do \
    gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key" || \
    gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
  done

ENV TOMEE_VER 8.0.11
ENV TOMEE_BUILD plus

RUN set -x \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.asc -o tomee.tar.gz.asc \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.sha512 -o tomee.tar.gz.sha512 \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz -o apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && gpg --batch --verify tomee.tar.gz.asc apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && echo `cat tomee.tar.gz.sha512` apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz | sha512sum -c - \
  && tar -zxf apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && mv apache-tomee-${TOMEE_BUILD}-${TOMEE_VER}/* /workspace/tomee \
  && rm apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && rm -Rf apache-tomee-${TOMEE_BUILD}-${TOMEE_VER} \
  && rm bin/*.bat \
  && rm bin/*.exe \
  && rm bin/*.tar.gz* \
  && rm tomee.tar.gz.asc \
  && rm tomee.tar.gz*

EXPOSE 8080
CMD ["catalina.sh", "run"]

WORKDIR /workspace
COPY --from=build /workspace/target/*.war /workspace/tomee/webapps/server.war

这基本上是用maven创建.war文件,然后最终使用该.war在Tomee Server中使用。代码>复制-from = build/workspace/target/* .war/workspace/tomee/webapps/server.war

Eventually after puzzling around with the hints from Robert Scholte, which helped me in the search of a solution, the indeed problem wasn't so much in the pom.xml, but more so in the setup of the Dockerfile. Within the old Dockerfile I was trying to run the .war as a .jar file.

Slightly following the setup from https://github.com/tomitribe/docker-tomee I ended up setting up the following Dockerfile

FROM maven:3.8.3-jdk-11-slim AS build
RUN mkdir -p /workspace
WORKDIR /workspace
COPY pom.xml /workspace
COPY src /workspace/src
RUN mvn -B -f pom.xml clean package -DskipTests

FROM openjdk:11-jdk-slim
RUN apt-get update; apt-get -y install curl gpg
ENV PATH /workspace/tomee/bin:$PATH
RUN mkdir -p /workspace/tomee
WORKDIR /workspace/tomee

RUN set -xe; \
  for key in \
  # Matt Hogstrom <[email protected]>
  9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
  # Jeremy Whitlock <[email protected]>
  F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
  # Richard Kenneth McGuire (CODE SIGNING KEY) <[email protected]>
  223D3A74B068ECA354DC385CE126833F9CF64915 \
  # Jonathan Gallimore <[email protected]>
  DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
  # Jarek Gawor (CODE SIGNING KEY) <[email protected]>
  7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
  # Jarek Gawor <[email protected]>
  B8B301E6105DF628076BD92C5483E55897ABD9B9 \
  # Andy Gumbrecht (TomEE Code Signing) <[email protected]>
  FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
  # Romain Manni-Bucau <[email protected]>
  A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
  # Mark Struberg (Apache) <[email protected]>
  82D8419BA697F0E7FB85916EE91287822FDB81B1 \
  # David Blevins <[email protected]>
  B7574789F5018690043E6DD9C212662E12F3E1DD \
  # Xu Hai Hong (Ivan Xu @ Geronimo) <[email protected]>
  C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  678F2D98F1FD9643811639FB622B8F2D043F71D8 \
  # Romain Manni-Bucau <[email protected]>
  BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
  # Romain Manni-Bucau <[email protected]>
  D11DF12CC2CA4894BDE638B967C1227A2678363C \
  # Roberto Cortez (Apache Signing Key) <[email protected]>
  C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
  # David Blevins <[email protected]>
  626C542EDA7C113814B77AF09C04914D63645D20 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  3948829384B269D333CC5B98358807C52B4B0E23 \
  # Richard Zowalla (Code Signing Key) <[email protected]>
  B83D15E72253ED1104EB4FBBDAB472F0E5B8A431 \
  ; do \
    gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key" || \
    gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
  done

ENV TOMEE_VER 8.0.11
ENV TOMEE_BUILD plus

RUN set -x \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.asc -o tomee.tar.gz.asc \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.sha512 -o tomee.tar.gz.sha512 \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz -o apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && gpg --batch --verify tomee.tar.gz.asc apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && echo `cat tomee.tar.gz.sha512` apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz | sha512sum -c - \
  && tar -zxf apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && mv apache-tomee-${TOMEE_BUILD}-${TOMEE_VER}/* /workspace/tomee \
  && rm apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && rm -Rf apache-tomee-${TOMEE_BUILD}-${TOMEE_VER} \
  && rm bin/*.bat \
  && rm bin/*.exe \
  && rm bin/*.tar.gz* \
  && rm tomee.tar.gz.asc \
  && rm tomee.tar.gz*

EXPOSE 8080
CMD ["catalina.sh", "run"]

WORKDIR /workspace
COPY --from=build /workspace/target/*.war /workspace/tomee/webapps/server.war

This basically creates a .war file with maven and then ends up using that .war file in the tomee server by adding it at the end using COPY --from=build /workspace/target/*.war /workspace/tomee/webapps/server.war.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文