如何解决这个问题:Ant不能“找到文件”当试图在Jenkins上构建一个Java Web应用程序? [英] How do I fix this: Ant cannot "find file" when trying to build a Java web application on Jenkins?

查看:348
本文介绍了如何解决这个问题:Ant不能“找到文件”当试图在Jenkins上构建一个Java Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Jenkins CI为NetBeans多层Web应用程序项目设置一个自动构建系统。此NetBeans项目包含一个EJB项目(用于Web应用程序的业务层)和一个WAR项目(适用于该应用程序的Web层)。我目前正在阻止Ant编译项目。



我正在使用Windows 8在NetBeans IDE 8.0中开发。 Jenkins也在Windows 8上运行。



我正在寻找一个了解如何使用Jenkins和Ant构建EJB项目的人。



到目前为止我所做的一切:




  • 我已经设置了NetBeans项目(如上所述)

  • 我已经为项目设置了一个git存储库

  • 我已经设置了Jenkins CI

  • 我可以使用Jenkins CI从git仓库获取项目

  • 我可以让Jenkins使用Ant来清理其检索的项目
    从git存储库



我被卡住了:



在使用Ant成功执行 clean 命令之后,我想使调试命令正常工作。为此,该项目需要编译。这是错误的地方。



我在Jenkins的Ant Invoke的属性字段中输入了以下属性:

  libs.CopyLibs.classpath = C:/ Program Files / NetBeans 8.0 / java / ant / extra / org-netbeans-modules-java-j2seproject-copylibstask.jar 
j2ee.server.home = C:/ Program Files / wildfly-8.1.0.Final

在输出我的Jenkins构建我看到以下命令:



[PGB Webapp] $ cmd.exe / C'C:\Program Files(x86 )\Jenkins\tools\hudson.tasks.Ant_AntInstallation\Apache_Ant\bin\ant.bat-Dlibs.CopyLibs.classpath = C:/ Program Files / NetBeans 8.0 / java / ant / extra / org -netbeans-modules-java-j2seproject-copylibstask.jar-Dj2ee.server.home = C:/ Program Files / wildfly-8.1.0.Finalclean debug&& exit %% ERRORLEVEL %%'



这是我的输出的最后一部分(对我来说似乎最重要的部分)



$ $ $ $ $ $ $ $ $ $ $
$ b -init-cos:

-deps-module-jar:

-deps-ear-jar:

deps -jar:

-pre-pre-compile:
[mkdir]创建dir:C:\Program文件(x86)\Jenkins\workspace\PGB Webapp\pgb -ejb\build\classes

-pre-compile:

-copy-meta-inf:
[copy]将2个文件复制到C:\\ \\ Program Files(x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes\META-INF

-do-compile:
[ mkdir]创建目录:C:\Program文件(x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\empty
[mkdir]创建目录:C:\Program文件(x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\generated-sources\ap-source-output
[javac]将5个源文件编译为C:\程序文件(x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes

-post-compile:

co mpile:

-pre-dist:

library-inclusion-in-manifest:

BUILD FAILED
C:\Program文件(x86)\Jenkins\workspace\PGB Webapp \\\
bproject\build-impl.xml:204:执行此行时发生以下错误:
C:\Program文件(x86)\\ \\ Jenkins\workspace\PGB Webapp\pgb-ejb\\\
bproject\build-impl.xml:806:警告:找不到文件C:\Program文件(x86)\Jenkins\workspace\复制PGB Webapp\pgb-ejb\ $ {libs.MySQLDriver.classpath}。

总时间:1秒
构建步骤'启动Ant'标记为失败
已完成:FAILURE

所以在这个输出我看到以下警告:



警告:找不到文件C: \\ Program Files(x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\ $ {libs.MySQLDriver.classpath}复制。



现在,对我来说,这似乎是一个罕见的问题,因为我几乎无法在互联网上找到它(或者我使用错误的搜索字词?)我在谷歌搜索,这里是SO,和DuckDuckGo,我只能找到我的问题的以下(相当无用的)线索:(很无用,因为我得到的警告被提及那里,但上下文是不同的..)



https://netbeans.org/bugzilla/show_bug.cgi?id=128505 javafx DataApp演示中的数据库出错



任何帮助都表示赞赏,因为我仍然是连续集成系统的新功能,开发Web应用程序和构建工具。



此外,我还没有看到Maven或Gradle作为替代方案。所以也许这个问题的解决方案可能是切换到另一个构建工具..?

解决方案

在我看来,如果属性libs.MySQLDriver.classpath未定义。
当Ant无法解析属性时,它会使用输出中的属性名称。



尝试定义



属性字段中的

  libs.MySQLDriver.classpath 

在Jenkins中,您还定义了其他两个属性。



您需要将其指向您的MySQL JDBC驱动程序。


I am trying to set up an automatic build system with Jenkins CI for a NetBeans multitiered web application project. This NetBeans project contains an EJB-project (for the business layer of the web application) and a WAR-project (for the web layer of the application). I'm currently stuck on getting Ant to compile the project.

I am using Windows 8 to develop in NetBeans IDE 8.0. Jenkins also runs on Windows 8.

I'm currently looking for someone who understands how to build EJB-projects with Jenkins and Ant.

What I've done so far:

  • I've set up a NetBeans project (as described above)
  • I've set up a git repository for the project
  • I've set up Jenkins CI
  • I am able to get the project from the git repository with Jenkins CI
  • I am able to make Jenkins use Ant to clean the project it retrieved from the git repository

Where I get stuck:

After being succesful to execute the clean command with Ant I want to make the debug command work. For this the project needs to be compiled. Here is where it goes wrong.

I entered the following properties in the Properties field for the Ant Invoke in Jenkins:

libs.CopyLibs.classpath=C:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
j2ee.server.home=C:/Program Files/wildfly-8.1.0.Final

In the output of my Jenkins build I see the following command:

[PGB Webapp] $ cmd.exe /C '""C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Ant_AntInstallation\Apache_Ant\bin\ant.bat" "-Dlibs.CopyLibs.classpath=C:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar" "-Dj2ee.server.home=C:/Program Files/wildfly-8.1.0.Final" clean debug && exit %%ERRORLEVEL%%"'

And this is the last part of my output: (the part that seems most important to me)

init:

-init-cos:

-deps-module-jar:

-deps-ear-jar:

deps-jar:

-pre-pre-compile:
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes

-pre-compile:

-copy-meta-inf:
     [copy] Copying 2 files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes\META-INF

-do-compile:
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\empty
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\generated-sources\ap-source-output
    [javac] Compiling 5 source files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes

-post-compile:

compile:

-pre-dist:

library-inclusion-in-manifest:

BUILD FAILED
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\nbproject\build-impl.xml:204: The following error occurred while executing this line:
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\nbproject\build-impl.xml:806: Warning: Could not find file C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\${libs.MySQLDriver.classpath} to copy.

Total time: 1 second
Build step 'Start Ant' marked build as failure
Finished: FAILURE

So in this output I see the following warning:

Warning: Could not find file C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\${libs.MySQLDriver.classpath} to copy.

Now, to me this seems to be a rare issue as I can find almost nothing about it on the internet (or am I using the wrong search term?) I've searched on Google, here on SO, and DuckDuckGo, and I could only find the following (pretty useless) clues to my problem: (pretty useless because the warning I get is mentioned there, but the context is different..)

https://netbeans.org/bugzilla/show_bug.cgi?id=128505 and Error with database in javafx DataApp demo

Any help is appreciated as I am still pretty new to continuous integration systems, developing web applications and build tools.

Also, I haven't looked much into Maven or Gradle yet as alternatives. So maybe the solution to the problem might as well be to switch to another build tool..?

解决方案

It seems to me as if the property libs.MySQLDriver.classpath is not defined. When Ant cannot resolve a property, it uses the property name in the output.

Try to define

libs.MySQLDriver.classpath

in the properties field in Jenkins where you also defined the other two properties.

You need to point it to your MySQL JDBC driver.

这篇关于如何解决这个问题:Ant不能“找到文件”当试图在Jenkins上构建一个Java Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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