当前位置: 首页 > 知识库问答 >
问题:

无法为CXF项目执行maven docker jar

廉博赡
2023-03-14

我有一个基于Apache CXF的现有工作java解决方案来使用一些SOAP服务。java可执行文件和着色jar在本地都能正常工作。然而,当我试图在docker中部署相同的解决方案时,代码

线程“main”javax.xml.ws中出现异常。WebServiceException:org.apache.cxf.service.factory。ServiceConstructionException:未能创建服务。位于org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82),位于com.flightview.BatchService.(BatchService.java:48),位于de.lh.hixca.oag.infectionraw.OAGIngestionMainClass。main(OAGIngestionMainClass.java:57)原因:org.apache.cxf.service.factory。ServiceConstructionException:未能创建服务。位于org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:87),位于org.aapache.cxf.jaxws.ServiceImpl.initialePorts(ServiceImpl.java:217),位于.org.apache.coxf.jjaxws.ServicesImpl.initialize(ServiceImple.java:160)…还有5个原因是:javax.wsdl。wsdl异常:WSDLException:faultCode=PARSER_ERROR:解析“file:/usr/src/app/src/main/resources/jks/oag_wsdl.wsdl”时出现问题。:java.io。文件未找到异常:/usr/src/app/src/main/resources/jks/oag_wsdl。com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReader Impl.java:2198)中的wsdl(无此类文件或目录wsdl11.WSDLManagerImpl.get定义(WSDLManagerImpl.java:165)在org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:85)…7更多原因:java.io。文件未找到异常:/usr/src/app/src/main/resources/jks/oag_wsdl。java.io.FileInputStream上的wsdl(无此类文件或目录)。位于sun.net.www.protocol.file.FileURLConnection.java:188的java.io.FileInputStream.open(FileInputsStream.java:195)的open0(本机方法)com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntity Manager.java:623(XML11Configuration.java:771)位于com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)位于com.sun.org.aapache.xercess.internall.parser.SOMParser.parser(DOMParser.java:243),位于com.sund.org.apacher.exerces-internal.jaxp.DocumentBuilderImpl.parse,位于com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReader Impl.java=2188)…12更多

我的样品袋。xml看起来像这样

   <dependencies>
        <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-bundle -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-bundle-compatible</artifactId>
            <version>3.3.6</version>
        </dependency>
        <!--some other dependencies-->
   </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>my.correct.main.class</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--shadded plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <!--  transformers for CXF (see http://stackoverflow.com/a/9069435/61298) -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/services/com.sun.tools.xjc.Plugin</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/cxf/cxf.extension</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/extensions.xml</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/extensions.xml</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/cxf/bus-extensions.txt</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/bus-extensions.xml</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/wsdl.plugin.xml</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/tools.service.validator.xml</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                                    <resource>META-INF/cxf/java2wsbeans.xml</resource>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/jks/oag_wsdl.wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        </plugins>
    </build>

我用来构建docker的docker文件是:

#
# Build stage
#
FROM maven:3.5-jdk-8 AS build
#copying .m2 settings.xml for profile
COPY settings.xml /root/.m2/
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app
ENV http_proxy "http://<username>:<password>@<host>:<port>"
ENV https_proxy "http://<username>:<password>@<host>:<port>"
RUN apt-get update \
    && apt-get install --no-install-recommends -y openjfx \
    && apt-get clean
RUN mvn -f /usr/src/app/pom.xml clean package
#
# Package stage
FROM gcr.io/distroless/java
COPY --from=build /usr/src/app/target/ingestion-oag-using-soap-1.0-SNAPSHOT.jar /usr/app/ingestion-oag-using-soap-1.0-SNAPSHOT.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/usr/app/ingestion-oag-using-soap-1.0-SNAPSHOT.jar"]

我的pom有问题吗。wsdl2java的xml目标是无法识别完整的oagwsdl。存储在资源文件夹中的wsdl路径?如果是这样,我该如何调整我的dockerfile?

共有1个答案

昌和悦
2023-03-14

看起来您的服务类是用绝对路径(而不是从类路径)生成的:

Caused by: java.io.FileNotFoundException: /usr/src/app/src/main/resources/jks/oag_wsdl.wsdl

尝试添加wsdlLocal参数以生成正确的wsdl路径:

<wsdlOptions>
    <wsdlOption>
        <wsdl>${basedir}/src/main/resources/jks/oag_wsdl.wsdl</wsdl>
        <wsdlLocation>classpath:jks/oag_wsdl.wsdl</wsdlLocation>
        <!-- <wsdlLocation>/jks/oag_wsdl.wsdl</wsdlLocation>  -->
    </wsdlOption>
</wsdlOptions>
 类似资料:
  • 我试图建立一个具有以下依赖关系的应用程序。 这是我在红帽网站上找到的一个例子-http://www.jboss.org/quickstarts/eap/helloworld-jms/ 我正在使用Netbeans 8.0.2。(还在dos和eclipse中使用Maven命令进行了尝试)我在构建时遇到了一个错误,下面是相同的日志: 我可以在以下路径找到文件: https://maven.reposit

  • 有关错误和可能的解决方案的更多信息,请阅读以下文章:http://cwiki.apache.org/confluence/display/maven/mojoExecutionException

  • 我在Android Studio中构建项目时遇到了一个问题,几周前它还能正常工作,但当我今天试图运行该项目时,它失败了。下面是我得到的错误消息: org.Gradle.tooling.gradleConnectionException:无法使用分级发行版“http://services.Gradle.org/distributions/gradle-1.7-bin.zip”执行生成。:无法使用分级

  • 我已经删除了。锁定文件和节点\u模块并再次尝试安装。然而,它不起作用。你能帮我修一下吗?

  • 我正在使用Linux-Ubuntu14.04。我安装了詹金斯2.7.2。 我在Eclipse中创建了一个maven项目,并遵循了此链接中提供的说明http://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html. 在完成项目设置后,我将其作为Maven项目执行,构建成功。 然后我安装了Jenkins,安装了Maven集

  • 我对科特林来说是全新的。我已经安装了kotlin插件来eclipse。我在下面的一个教程中找到了一个简单的例子。问题是,当我运行项目时,我收到了以下声明的错误。 为了解决这个问题,我试图运行项目作为kotlin应用程序,但我找不到这个选项。 请让我知道如何修复此错误? 代码: 错误: 更新: 为了解决这个问题,我完全按照本教程中的内容,安装了最新版本的eclipse PHOTON,但问题仍然存在。