我很难让我非常简单的 Java EE 源代码在运行在 tomcat6(在 Centos 6.x 上)上的 Jenkins 中编译。我尝试下载 JBoss,但找不到 Java EE jar 文件,因此我可以将它们包含在我的 ANT 脚本中。我从 Oracle 下载了 JavaEE,它是 .sh shell 脚本(80mb),我猜想通过提取或编译各种 jar 来“安装”java ee。问题是它不会运行,因为 Oracle shell 脚本需要运行 X11 实例(GUI)......但这是一个无头服务器。
目标是让一个使用 JavaEE 的项目在夜间工作。
我需要以某种方式找到如何仅将 JBoss 用于它的 java ee 库(以便我可以编译我的代码),或者需要以某种方式让 oracle 的产品工作?或者我的设置还有其他选择吗?
这是我的 Jenkins/Ant 日志输出:
build-project:
[echo] JUtils: /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/build.xml
[javac] Compiling 27 source files to /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/target/tmp
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:21: error: package javax.mail does not exist
[javac] import javax.mail.Message;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:22: error: package javax.mail does not exist
[javac] import javax.mail.MessagingException;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:23: error: package javax.mail does not exist
[javac] import javax.mail.Session;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:24: error: package javax.mail does not exist
[javac] import javax.mail.Transport;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:25: error: package javax.mail.internet does not exist
[javac] import javax.mail.internet.AddressException;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:26: error: package javax.mail.internet does not exist
[javac] import javax.mail.internet.InternetAddress;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:27: error: package javax.mail.internet does not exist
[javac] import javax.mail.internet.MimeMessage;
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:51: error: cannot find symbol
[javac] throws AddressException, MessagingException {
[javac] ^
[javac] symbol: class AddressException
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:51: error: cannot find symbol
[javac] throws AddressException, MessagingException {
[javac] ^
[javac] symbol: class MessagingException
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:63: error: cannot find symbol
[javac] Session session = Session.getDefaultInstance(props, null);
[javac] ^
[javac] symbol: class Session
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:63: error: cannot find symbol
[javac] Session session = Session.getDefaultInstance(props, null);
[javac] ^
[javac] symbol: variable Session
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:64: error: cannot find symbol
[javac] MimeMessage message = new MimeMessage(session);
[javac] ^
[javac] symbol: class MimeMessage
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:64: error: cannot find symbol
[javac] MimeMessage message = new MimeMessage(session);
[javac] ^
[javac] symbol: class MimeMessage
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:65: error: cannot find symbol
[javac] message.setFrom(new InternetAddress(from));
[javac] ^
[javac] symbol: class InternetAddress
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:67: error: cannot find symbol
[javac] InternetAddress[] toAddress = new InternetAddress[to.length];
[javac] ^
[javac] symbol: class InternetAddress
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:67: error: cannot find symbol
[javac] InternetAddress[] toAddress = new InternetAddress[to.length];
[javac] ^
[javac] symbol: class InternetAddress
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:71: error: cannot find symbol
[javac] toAddress[i] = new InternetAddress(to[i]);
[javac] ^
[javac] symbol: class InternetAddress
[javac] location: class SendEmail
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:76: error: package Message does not exist
[javac] message.addRecipient(Message.RecipientType.TO, toAddress[i]);
[javac] ^
[javac] /usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/src/net/snakedoc/jutils/SendEmail.java:82: error: cannot find symbol
[javac] Transport transport = session.getTransport("smtp");
[javac] ^
[javac] symbol: class Transport
[javac] location: class SendEmail
[javac] 19 errors
BUILD FAILED
/usr/share/tomcat6/.jenkins/jobs/JUtils-Nightly/workspace/build.xml:54: Compile failed; see the compiler error output for details.
Total time: 4 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
编辑:(蚂蚁构建脚本)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="JUtils">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../../Program Files/eclipse-jee-juno-SR1-win32-x86_64/eclipse"/>
<property name="JAVAEE_HOME" value="/opt/jboss/modules/**"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<property name="dest_dir" value="target"/>
<property name="tmp_dir" value="tmp"/>
<property name="jar_name" value="JUtils"/>
<path id="javaee.libraryclasspath">
<pathelement location="${JAVAEE_HOME}"/>
</path>
<tstamp>
<format property="build.datestamp" pattern="yyyy-MM-dd" locale="en,US"/>
</tstamp>
<path id="JUtils.classpath">
<pathelement location="bin"/>
<pathelement location="lib/h2-1.3.170.jar"/>
<pathelement location="lib/hsqldb.jar"/>
<pathelement location="lib/jt400.jar"/>
<pathelement location="lib/log4j-1.2.17.jar"/>
<pathelement location="lib/mariadb-java-client-1.1.1.jar"/>
<pathelement location="lib/mysql-connector-java-5.1.23-bin.jar"/>
<pathelement location="lib/postgresql-9.2-1002.jdbc4.jar"/>
<pathelement location="lib/sqlite-jdbc-3.7.2.jar"/>
<path refid="javaee.libraryclasspath"/>
</path>
<target name="init">
<mkdir dir="${dest_dir}"/>
<mkdir dir="${dest_dir}/${tmp_dir}"/>
<mkdir dir="${dest_dir}/${tmp_dir}/src"/>
<mkdir dir="${dest_dir}/${tmp_dir}/doc"/>
<mkdir dir="${dest_dir}/${tmp_dir}/lib"/>
<mkdir dir="${dest_dir}/${tmp_dir}/META-INF"/>
<copy includeemptydirs="false" todir="${dest_dir}">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${dest_dir}/${tmp_dir}">
<fileset dir=".">
<include name="**/*"/>
<exclude name="target/**"/>
<exclude name="logs/**"/>
<exclude name="bin/**"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${dest_dir}"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project,jar" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${dest_dir}/${tmp_dir}" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="JUtils.classpath"/>
</javac>
</target>
<target name="create_manifest">
<manifest file="${dest_dir}/${tmp_dir}/META-INF/MANIFEST.MF">
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Website" value="www.snakedoc.net"/>
<attribute name="Project" value="JUtils-${build.datestamp}"/>
</manifest>
</target>
<target depends="create_manifest" name="jar">
<jar destfile="${dest_dir}/${jar_name}-${build.datestamp}.jar" basedir="${dest_dir}/${tmp_dir}"/>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="DBTest">
<java classname="net.snakedoc.jutils.testsuite.DBTest" failonerror="true" fork="yes">
<classpath refid="JUtils.classpath"/>
</java>
</target>