2011-07-11 20 views
0

私は、Eclipse上でHibernateと絶えず私がコンパイルしようとすると、次のエラーメッセージが表示されます使用しています:ログ工場エラー

build.xml:39: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

私は私のlibsフォルダ内commons-logging.jarファイルを持っており、ここに私のクラスパス・ファイルです:

<?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="&lt;annotated-types/&gt;" /> 
     <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> 

答えて

0

あなたのプロジェクト構造についてもっと詳しく説明しなければならないかもしれません。どのようにプロジェクトをパッケージ化しましたか? (ejbモジュールをパッケージ化した耳を含んでいますか?)

明らかにそのクラスローディングの問題です。または、jarファイルが最終的に配布可能なアーカイブにパッケージ化されていない可能性があります。解決策の最も簡単な修正は、common-logging.jarファイルをコピーして、サーバーのlibディレクトリに貼り付けることです。 (Tomcatの私はCATALINA_HOMEフォルダの下にその信じている..しかし、私はわからない)

+0

残念ながら、私はすでにどのようにあなたのサーバーで、このプロジェクトを展開します運 –

+0

と以前のサーバーのlibディレクトリにコピー&ペースト瓶をしようとしましたか?展開可能なアーカイブを開いたのですか? (unzip it ..)common.loggin.jarを見つけましたか?異なるバージョンのjarファイルがあるかもしれません。また、common.logging.jarファイルを開いて、パッケージ "org.apache.common.logging"が存在するかどうかを確認することもできます。 –

+0

パッケージは本当にjarファイルに存在します。デプロイ可能なアーカイブが何を意味するかもわかりません。私はTomcatに関与することなく、ファイルのオフライン構築中にこれらのエラーを取得しています。それがサーバーの問題ではないのではないでしょうか? –

0

あなたは、Eclipseの内プロジェクトを構築する際にEclipseが使用するクラスパスを定義するEclipseの.classpathメタデータファイルの内容を掲載しているように見えますbuild.xmlを使用すると、Antを使用してIDEからプロジェクトを外部的にビルドすることも意味します。

<javac>build.xmlのタスクもcommons-logging.jarを参照してください。 .classpathファイルは、何らかの形でビルドスクリプトを設定していない限り(Eclipseからbuild.xmlを生成することによって)、Antによって使用されることはありません。

+0

彼らはcommons-logging.jarも参照しているようです。私は参照用の質問にbuild.xmlファイルを掲載しました。 –