How do I fix this: Ant cannot “find file” when trying to build a Java web application on Jenkins?

匆匆过客 提交于 2019-12-11 20:34:54

问题


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..?


回答1:


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.



来源:https://stackoverflow.com/questions/25061162/how-do-i-fix-this-ant-cannot-find-file-when-trying-to-build-a-java-web-applic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!