我该如何解决:Ant无法& quot;查找文件& quot;尝试在Jenkins上构建Java Web应用程序时? [英] How do I fix this: Ant cannot "find file" when trying to build a Java web application on Jenkins?

查看:66
本文介绍了我该如何解决:Ant无法& quot;查找文件& quot;尝试在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存储库
  • 我已经设置了詹金斯CI
  • 我能够使用Jenkins CI从git存储库中获取项目
  • 我能够让Jenkins使用Ant清理它检索到的项目 从git仓库中

我被卡住的地方:

成功使用Ant执行 clean 命令后,我想使 debug 命令正常工作.为此,需要编译项目.这是哪里出了问题.

我在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

在我的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.Final干净的调试&&退出%% ERRORLEVEL %%"'

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

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

因此在此输出中,我看到以下警告:

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

现在,对我来说,这似乎是一个罕见的问题,因为我在互联网上几乎找不到任何东西(或者我使用的搜索字词是否正确?)我已经在Google,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无法& quot;查找文件& quot;尝试在Jenkins上构建Java Web应用程序时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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