我使用Eclipse的休眠,當我嘗試編譯不斷收到以下錯誤信息:日誌廠錯誤
build.xml:39: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
我有commons-logging.jar
文件我libs文件夾內,這裏是我的類路徑文件:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="src" path="flex_src"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
我甚至嘗試從build.xml
文件中打印的類路徑和commons-logging.jar
出現內有作爲,有正確的目錄。這裏是我的build.xml文件供進一步參考:
<project name="project" default="main">
<property file="build.properties" />
<xmlproperty file="${project-root}/src/META-INF/persistence.xml" collapseAttributes="true" />
<description>Generate CDB files</description>
<target name="force">
<property name="force.build" value="true" />
<antcall target="mainInternal" />
</target>
<target name="main">
<property name="force.build" value="false" />
<antcall target="mainInternal" />
</target>
<target name="mainInternal">
<antcall target="generateHibernateCfg" />
<antcall target="compileEntities" />
<antcall target="findAnnotations" />
<antcall target="compileServiceInterfaces" />
<antcall target="generateDTOs" />
<antcall target="generateServices" />
<antcall target="generateFlex" />
<antcall target="generateBlazeDSConfig" />
</target>
<target name="generateHibernateCfg">
<xslt in="${project-root}/src/META-INF/persistence.xml" style="${project-root}/cdb_build/src/hibernate.cfg.xsl" out="${project-root}/src/hibernate.cfg.xml" force="${force.build}" />
</target>
<target name="compileEntities">
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<echo message="Classpath = ${cp}"/>
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<script language="javascript">
<![CDATA[
var includes = "";
var entitiesString = project.getProperty("persistence.persistence-unit.class");
if (entitiesString) {
var entities = entitiesString.split(",");
for (entity in entities) {
if (entities[entity] != null && entities[entity] != "") {
includes += String(entities[entity]).replace(/\./g, '/') + ".java,";
}
}
}
project.setProperty("entities.include", includes);
]]>
</script>
<mkdir dir="${project-root}/build/classes" />
<javac includes="${entities.include}" srcdir="${project-root}/src" destdir="${classes-folder}" classpath="${cp}" debug="on" />
</target>
<target name="findAnnotations">
<file name="annotated.xml" id="annotated.xml" />
<echo file="annotated.xml" message="<annotated-types/>" />
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<path id="cfg-xml-path">
<fileset file="${project-root}/src/hibernate.cfg.xml" />
</path>
<pathconvert property="cfg-xml" refid="cfg-xml-path" />
<apt classpath="${cp}"
compile="false"
factory="com.farata.cdb.annotations.processor.CDBFullAnnotationProcessor"
srcdir="${project-root}/src"
sourcepath="${project-root}/src">
<option name="com.faratasystems.cdb.annotations.file" value="annotated.xml"/>
<option name="com.faratasystems.cdb.configuration.file" value="${cfg-xml}"/>
<include name="**/*.java"/>
</apt>
</target>
<target name="compileServiceInterfaces">
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<xmlproperty file="annotated.xml" collapseAttributes="true" />
<script language="javascript">
<![CDATA[
var includes = "";
var typeNamesString = project.getProperty("annotated-types.annotated-type.name");
if (typeNamesString) {
var annotationNamesString = project.getProperty("annotated-types.annotated-type.annotations.annotation.name");
var annotationNames = annotationNamesString.split(",");
var typeNames = typeNamesString.split(",");
for (annotationName in annotationNames) {
if (annotationNames[annotationName] != null && annotationNames[annotationName] != "") {
if (annotationNames[annotationName] == "clear.cdb.annotations.CX_Service") {
includes += String(typeNames[annotationName]).replace(/\./g, '/') + ".java,";
}
}
}
}
project.setProperty("entities.include", includes);
]]>
</script>
<javac includes="${entities.include}" srcdir="${project-root}/src" destdir="${classes-folder}" classpath="${cp}" debug="on" />
</target>
<target name="generateDTOs">
<xmlproperty file="annotated.xml" collapseAttributes="true" />
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<xslt classpathref="build.class.path" in="annotated.xml" style="src/service-dto-all.xsl" out="tmp.txt" force="true">
<param name="outputFolder" expression="${project-root}src" />
<param name="force" expression="${force.build}" />
</xslt>
<script language="javascript" src="${basedir}/scripts.js">
<![CDATA[
var includes = getServicesDTOs();
includes += getServicesDTOSubclasses();
project.setProperty("entities.include", includes == ""? "none":includes);
]]>
</script>
<javac includes="${entities.include}" srcdir="${project-root}/src" destdir="${classes-folder}" classpath="${cp}" debug="on" failonerror="false" />
</target>
<target name="generateServices">
<xmlproperty file="annotated.xml" collapseAttributes="true" />
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<xslt classpathref="build.class.path" in="annotated.xml" style="src/service-impl-all.xsl" out="tmp.txt" force="true">
<param name="outputFolder" expression="${project-root}src" />
<param name="force" expression="${force.build}" />
</xslt>
<script language="javascript" src="${basedir}/scripts.js">
<![CDATA[
var includes = getServices();
includes += getServicesSubclasses();
project.setProperty("entities.include", includes == ""? "none":includes);
]]>
</script>
<javac includes="${entities.include}" srcdir="${project-root}/src" destdir="${classes-folder}" classpath="${cp}" debug="on" />
</target>
<target name="generateFlex">
<xmlproperty file="annotated.xml" collapseAttributes="true" />
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<xslt classpathref="build.class.path" in="annotated.xml" style="flex_src/flex-all.xsl" out="tmp.txt" force="true">
<param name="flexOutputFolder" expression="${flex-output-folder}" />
<param name="javaSrcFolder" expression="${project-root}src" />
<param name="force" expression="${force.build}" />
</xslt>
<xslt classpathref="build.class.path" in="annotated.xml" style="flex_src/application-all.xsl" out="tmp.txt" force="true">
<param name="javaSrcFolder" expression="${project-root}src" />
<param name="testFolder" expression="${project-root}test" />
<param name="force" expression="${force.build}" />
</xslt>
</target>
<target name="generateBlazeDSConfig">
<xmlproperty file="annotated.xml" collapseAttributes="true" />
<path id="build.class.path">
<fileset dir="${project-root}/WebContent/WEB-INF/lib" />
<pathelement path="${classes-folder}" />
</path>
<pathconvert property="cp" refid="build.class.path" />
<path id="srcfiles">
<fileset dir="${project-root}/src">
<include name="**/*.java" />
</fileset>
</path>
<pathconvert property="srcfiles" refid="srcfiles" pathsep=" " />
<script language="javascript" src="${basedir}/scripts.js">
<![CDATA[
generateRemotingConfig();
generateMessagingConfig();
]]>
</script>
</target>
</project>
不幸的是,我已經嘗試將jar複製到服務器的lib目錄中,但沒有運氣 –
如何在服務器中部署此項目?你打開了可部署的存檔嗎? (解壓縮..)你有沒有找到common.loggin.jar。可能你有一個不同版本的jar文件。你是否也可以打開common.logging.jar文件並查看包「org.apache.common.logging」是否存在。 –
包確實存在於jar文件中。我也不確定您的可部署歸檔文件的含義。在脫機構建文件的過程中,我收到了這些錯誤,沒有涉及Tomcat。這不妨礙它成爲服務器問題嗎? –