运行 hibernate3:hbm2ddl 时出现 ClassNotFoundException javax.mail.internet.AddressException

发布于 2024-10-10 04:40:37 字数 15406 浏览 4 评论 0原文

所以我在使用 log4j 和 hbm2ddl 时遇到了麻烦。 当我将 SMTPAppender 放入 log4j.xml 中时,我收到此 ClaasNotFoundException。

关于如何解决这个问题有任何提示吗?

这些是我的配置文件和堆栈跟踪:

stackctrace:

        [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Unnamed - Mail-logging-and-hbm2ddl:Mail-logging-and-hbm2ddl:jar:1.0
    [INFO]    task-segment: [package]
    [INFO] ------------------------------------------------------------------------
    [INFO] [resources:resources {execution: default-resources}]
    [WARNING] Using platform encoding (windows-1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] Copying 2 resources
    [INFO] [compiler:compile {execution: default-compile}]
    [INFO] Nothing to compile - all classes are up to date
    [INFO] Preparing hibernate3:hbm2ddl
    [WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive invocation.
    [INFO] [resources:resources {execution: default-resources}]
    [WARNING] Using platform encoding (windows-1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] Copying 2 resources
    [INFO] [hibernate3:hbm2ddl {execution: default}]
    [INFO] Configuration XML file loaded: file:/D:/DEV/PROJECTS/Mail%20logging%20and%20hbm2ddl/src/main/resources/hibernate.cfg.xml
    [FATAL ERROR] org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
    [FATAL ERROR] Plugin realm = app0.child-container[org.codehaus.mojo:hibernate3-maven-plugin:2.2]
    urls[0] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3-maven-plugin/2.2/hibernate3-maven-plugin-2.2.jar
    urls[1] = file:/d:/Settings/U190552/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar
    urls[2] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-tools/3.2.3.GA/hibernate-tools-3.2.3.GA.jar
    urls[3] = file:/d:/Settings/U190552/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
    urls[4] = file:/d:/Settings/U190552/.m2/repository/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar
    urls[5] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/jtidy/r8-20060801/jtidy-r8-20060801.jar
    urls[6] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
    urls[7] = file:/d:/Settings/U190552/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
    urls[8] = file:/d:/Settings/U190552/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
    urls[9] = file:/d:/Settings/U190552/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
    urls[10] = file:/d:/Settings/U190552/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
    urls[11] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
    urls[12] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-api/2.2/maven-hibernate3-api-2.2.jar
    urls[13] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
    urls[14] = file:/d:/Settings/U190552/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.0.1B_spec/1.1.1/geronimo-jta_1.0.1B_spec-1.1.1.jar
    urls[15] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar
    urls[16] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
    urls[17] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk14/2.2/maven-hibernate3-jdk14-2.2.jar
    urls[18] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk15/2.2/maven-hibernate3-jdk15-2.2.jar
    urls[19] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar
    urls[20] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar
    urls[21] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar
    urls[22] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
    urls[23] = file:/d:/Settings/U190552/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar
    urls[24] = file:/d:/Settings/U190552/.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar
    urls[25] = file:/d:/Settings/U190552/.m2/repository/jboss/jboss-common/4.0.2/jboss-common-4.0.2.jar
    urls[26] = file:/d:/Settings/U190552/.m2/repository/slide/webdavlib/2.0/webdavlib-2.0.jar
    urls[27] = file:/d:/Settings/U190552/.m2/repository/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar
    [FATAL ERROR] Container realm = plexus.core
    urls[0] = file:/D:/DEV/TOOLS/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar
    [INFO] ------------------------------------------------------------------------
    [ERROR] FATAL ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] javax/mail/internet/AddressException
    javax.mail.internet.AddressException
    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
     at java.lang.Class.getDeclaredConstructors0(Native Method)
     at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
     at java.lang.Class.getConstructor0(Class.java:2699)
     at java.lang.Class.newInstance0(Class.java:326)
     at java.lang.Class.newInstance(Class.java:308)
     at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:174)
     at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:150)
     at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:163)
     at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:425)
     at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:394)
     at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:829)
     at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:712)
     at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
     at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
     at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
     at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209)
     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
     at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
     at org.codehaus.mojo.hibernate3.configuration.AnnotationComponentConfiguration.createConfiguration(AnnotationComponentConfiguration.java:93)
     at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:51)
     at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:87)
     at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
     at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
     at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
     at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
     at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
    Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
     at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
     at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
     at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     ... 47 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2 seconds
    [INFO] Finished at: Fri Dec 31 11:42:20 CET 2010
    [INFO] Final Memory: 10M/24M
    [INFO] ------------------------------------------------------------------------

log4j.xml

    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

        <appender name="email" class="org.apache.log4j.net.SMTPAppender">
            <param name="Threshold" value="error" />
            <param name="BufferSize" value="10" />
            <param name="SMTPHost" value="smtp.host" />
            <param name="From" value="[email protected]" />
            <param name="To" value="CDB@mail" />
            <param name="Subject" value="[Site] Error - TST" />
            <param name="LocationInfo" value="false" />
            <layout class="org.apache.log4j.HTMLLayout">
                <param name="LocationInfo" value="false" />
            </layout>
        </appender>

        <root>
            <priority value="DEBUG" />
            <appender-ref ref="email" />
        </root>

    </log4j:configuration>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>Mail-logging-and-hbm2ddl</groupId>
<artifactId>Mail-logging-and-hbm2ddl</artifactId>
<version>1.0</version>


<dependencies>
    <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
    <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<exclusions>
<!-- We need a higher version of ehcache -->
<exclusion>
 <groupId>net.sf.ehcache</groupId>
 <artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>2.5.4</version>
</dependency>
 </dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/resources-${targetprofile}</directory>
            <filtering>false</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
<artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
<configuration>
 <source>${javaVersion}</source>
 <target>${javaVersion}</target>
 <encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
 <execution>
  <phase>process-classes</phase>
  <goals>
   <goal>hbm2ddl</goal>
  </goals>
 </execution>
</executions>
<configuration>
 <componentProperties>
  <propertyfile>
   src/main/resources-${targetprofile}/configuration.properties
  </propertyfile>
  <export>false</export>
  <drop>true</drop>
  <outputfilename>
   ${project.artifactId}-${project.version}-schema.sql
  </outputfilename>
 </componentProperties>
</configuration>
        </plugin>
    </plugins>
</build>

<properties>
<javaVersion>1.6</javaVersion>
</properties>

</project>

So I'm having trouble with log4j and hbm2ddl.
When I put an SMTPAppender in my log4j.xml I get this ClaasNotFoundException.

Any Hints on how to solve this?

These are my config files and the stacktrace:

stackctrace:

        [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Unnamed - Mail-logging-and-hbm2ddl:Mail-logging-and-hbm2ddl:jar:1.0
    [INFO]    task-segment: [package]
    [INFO] ------------------------------------------------------------------------
    [INFO] [resources:resources {execution: default-resources}]
    [WARNING] Using platform encoding (windows-1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] Copying 2 resources
    [INFO] [compiler:compile {execution: default-compile}]
    [INFO] Nothing to compile - all classes are up to date
    [INFO] Preparing hibernate3:hbm2ddl
    [WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive invocation.
    [INFO] [resources:resources {execution: default-resources}]
    [WARNING] Using platform encoding (windows-1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] Copying 2 resources
    [INFO] [hibernate3:hbm2ddl {execution: default}]
    [INFO] Configuration XML file loaded: file:/D:/DEV/PROJECTS/Mail%20logging%20and%20hbm2ddl/src/main/resources/hibernate.cfg.xml
    [FATAL ERROR] org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
    [FATAL ERROR] Plugin realm = app0.child-container[org.codehaus.mojo:hibernate3-maven-plugin:2.2]
    urls[0] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3-maven-plugin/2.2/hibernate3-maven-plugin-2.2.jar
    urls[1] = file:/d:/Settings/U190552/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar
    urls[2] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-tools/3.2.3.GA/hibernate-tools-3.2.3.GA.jar
    urls[3] = file:/d:/Settings/U190552/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar
    urls[4] = file:/d:/Settings/U190552/.m2/repository/freemarker/freemarker/2.3.8/freemarker-2.3.8.jar
    urls[5] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/jtidy/r8-20060801/jtidy-r8-20060801.jar
    urls[6] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
    urls[7] = file:/d:/Settings/U190552/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar
    urls[8] = file:/d:/Settings/U190552/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
    urls[9] = file:/d:/Settings/U190552/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
    urls[10] = file:/d:/Settings/U190552/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
    urls[11] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
    urls[12] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-api/2.2/maven-hibernate3-api-2.2.jar
    urls[13] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
    urls[14] = file:/d:/Settings/U190552/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.0.1B_spec/1.1.1/geronimo-jta_1.0.1B_spec-1.1.1.jar
    urls[15] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar
    urls[16] = file:/d:/Settings/U190552/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
    urls[17] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk14/2.2/maven-hibernate3-jdk14-2.2.jar
    urls[18] = file:/d:/Settings/U190552/.m2/repository/org/codehaus/mojo/hibernate3/maven-hibernate3-jdk15/2.2/maven-hibernate3-jdk15-2.2.jar
    urls[19] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar
    urls[20] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar
    urls[21] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar
    urls[22] = file:/d:/Settings/U190552/.m2/repository/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
    urls[23] = file:/d:/Settings/U190552/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar
    urls[24] = file:/d:/Settings/U190552/.m2/repository/javassist/javassist/3.4.GA/javassist-3.4.GA.jar
    urls[25] = file:/d:/Settings/U190552/.m2/repository/jboss/jboss-common/4.0.2/jboss-common-4.0.2.jar
    urls[26] = file:/d:/Settings/U190552/.m2/repository/slide/webdavlib/2.0/webdavlib-2.0.jar
    urls[27] = file:/d:/Settings/U190552/.m2/repository/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar
    [FATAL ERROR] Container realm = plexus.core
    urls[0] = file:/D:/DEV/TOOLS/apache-maven-2.2.1/lib/maven-2.2.1-uber.jar
    [INFO] ------------------------------------------------------------------------
    [ERROR] FATAL ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] javax/mail/internet/AddressException
    javax.mail.internet.AddressException
    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
     at java.lang.Class.getDeclaredConstructors0(Native Method)
     at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
     at java.lang.Class.getConstructor0(Class.java:2699)
     at java.lang.Class.newInstance0(Class.java:326)
     at java.lang.Class.newInstance(Class.java:308)
     at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:174)
     at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:150)
     at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:163)
     at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:425)
     at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:394)
     at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:829)
     at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:712)
     at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
     at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)
     at org.apache.log4j.LogManager.<clinit>(LogManager.java:122)
     at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:209)
     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
     at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
     at org.codehaus.mojo.hibernate3.configuration.AnnotationComponentConfiguration.createConfiguration(AnnotationComponentConfiguration.java:93)
     at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:51)
     at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:87)
     at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
     at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
     at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
     at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
     at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
     at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
     at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
    Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
     at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
     at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
     at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     ... 47 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2 seconds
    [INFO] Finished at: Fri Dec 31 11:42:20 CET 2010
    [INFO] Final Memory: 10M/24M
    [INFO] ------------------------------------------------------------------------

log4j.xml

    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

        <appender name="email" class="org.apache.log4j.net.SMTPAppender">
            <param name="Threshold" value="error" />
            <param name="BufferSize" value="10" />
            <param name="SMTPHost" value="smtp.host" />
            <param name="From" value="[email protected]" />
            <param name="To" value="CDB@mail" />
            <param name="Subject" value="[Site] Error - TST" />
            <param name="LocationInfo" value="false" />
            <layout class="org.apache.log4j.HTMLLayout">
                <param name="LocationInfo" value="false" />
            </layout>
        </appender>

        <root>
            <priority value="DEBUG" />
            <appender-ref ref="email" />
        </root>

    </log4j:configuration>

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>Mail-logging-and-hbm2ddl</groupId>
<artifactId>Mail-logging-and-hbm2ddl</artifactId>
<version>1.0</version>


<dependencies>
    <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
    <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<exclusions>
<!-- We need a higher version of ehcache -->
<exclusion>
 <groupId>net.sf.ehcache</groupId>
 <artifactId>ehcache</artifactId>
</exclusion>
</exclusions>
</dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>2.5.4</version>
</dependency>
 </dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/resources-${targetprofile}</directory>
            <filtering>false</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
<artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
<configuration>
 <source>${javaVersion}</source>
 <target>${javaVersion}</target>
 <encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
 <execution>
  <phase>process-classes</phase>
  <goals>
   <goal>hbm2ddl</goal>
  </goals>
 </execution>
</executions>
<configuration>
 <componentProperties>
  <propertyfile>
   src/main/resources-${targetprofile}/configuration.properties
  </propertyfile>
  <export>false</export>
  <drop>true</drop>
  <outputfilename>
   ${project.artifactId}-${project.version}-schema.sql
  </outputfilename>
 </componentProperties>
</configuration>
        </plugin>
    </plugins>
</build>

<properties>
<javaVersion>1.6</javaVersion>
</properties>

</project>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丢了幸福的猪 2024-10-17 04:40:37

另一个问题给了我答案答案
因此,答案是将 javax.mail 依赖项添加到插件中,如下所示:

<build>
....

<plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.0</version>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>hbm2ddl</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <componentProperties>
                    <propertyfile>
                        src/main/resources-${targetprofile}/configuration.properties
                    </propertyfile>
                    <export>false</export>
                    <drop>true</drop>
                    <outputfilename>
                        ${project.artifactId}-${project.version}-schema.sql
                    </outputfilename>
                </componentProperties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                    <version>1.4.3</version>
                </dependency>
            </dependencies>
        </plugin>

This other question gave me the answer answer
So the anwser is to add the javax.mail dependency to the plugin as follows :

<build>
....

<plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.0</version>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>hbm2ddl</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <componentProperties>
                    <propertyfile>
                        src/main/resources-${targetprofile}/configuration.properties
                    </propertyfile>
                    <export>false</export>
                    <drop>true</drop>
                    <outputfilename>
                        ${project.artifactId}-${project.version}-schema.sql
                    </outputfilename>
                </componentProperties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                    <version>1.4.3</version>
                </dependency>
            </dependencies>
        </plugin>
沫离伤花 2024-10-17 04:40:37

从错误消息和调试日志来看,javax.mail 依赖项似乎不是运行 hbm2ddl 时存在的依赖项的一部分。由于上面的内容格式很差并且可能不完整,所以很难说出原因。一种可能性是未包含 javax.mail 依赖项。或者如果是,则包含在不正确的(例如运行时)范围内。

您可以尝试运行从 log4j.xml 中删除 SMTPAppender 的目标,看看它是否有效。这将有助于缩小问题范围。

From the error message as well as the debug log, it appears that javax.mail dependency is not part of the dependencies that are present when hbm2ddl is run. Since the contents above are poorly formatted and possibly incomplete, it is difficult to say why. One possibility is javax.mail dependency is not included. Or if yes, included with incorrect (say runtime) scope.

You could try running the goal removing the SMTPAppender from log4j.xml to see if it works. This will help narrow down the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文