DCH类与JavaMail错误 [英] DCH class error with JavaMail

查看:121
本文介绍了DCH类与JavaMail错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Glassfish 3.1提供的jar文件在Java EE 6中使用JavaMail建立简单的日志记录测试。这个问题似乎有很多问题,但我还没有找到任何有帮助的答案。我的测试代码如下所示:

  import java.util.logging.Logger; 

public class MyClass {
private static final Logger LOGGER = Logger.getLogger(MyClass);

public static void main(String [] args){
LOGGER.severe(This is a test);


我的logging.properties文件包含以下内容:

  com.sun.mail.util.logging.MailHandler.mail.smtp.host = {my mail hub FQDN} 
com .sun.mail.util.logging.MailHandler.mail.smtp.port = 25
com.sun.mail.util.logging.MailHandler.mail.to = {me}
com.sun.mail .util.logging.MailHandler.mail.from = {support address}
com.sun.mail.util.logging.MailHandler.level =警告
com.sun.mail.util.logging.MailHandler。 verify = local
com.sun.mail.util.logging.MailHandler.subject =应用程序错误
com.sun.mail.util.logging.MailHandler.formatter = java.util.logging.SimpleFormatter

我使用以下方式构建类:

  javac -cp $ AS_INSTALL / glassfish / modules / javax.mail.jar:$ AS_INSTALL / install / lib / external / jaxb / activation.jar :. MyClass.java 

然后我运行程序:

  java -cp $ AS_INSTALL / glassfish / modules / javax.mail.jar:$ AS_INSTALL / install / lib / external / jaxb / activation.jar :. -Djava.util.logging.config.file = logging.properties MyClass 

这会导致以下错误:

  2011年9月22日下午4点19分25秒MyClass main 
SEVERE:这是一个测试
java.util.logging.ErrorManager:3:SEVERE:对于MIME类型multipart / mixed,没有对象DCH;
boundary =---- = _ Part_1_26867996.1316722766145
javax.activation.UnsupportedDataTypeException:无对象DCH for MIME类型multipart / mixed;
boundary =---- = _ Part_1_26867996.1316722766145$ javax.activation.ObjectDataContentHandler.writeTo上的
(DataHandler.java:877)
at javax.activation.DataHandler.writeTo(DataHandler。
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
在javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1748)
在com.sun.mail.util.logging.MailHandler.toRawString(MailHandler.java:2196)
在com.sun .mail.util.logging.MailHandler.send(MailHandler.java:1597)
在com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
在java.util .logging.LogManager.resetLogger(LogManager.java:693)$ java.util.logging.LogManager.reset中的b $ b(LogManager.java:676)$ java.util.logging.LogManager中的
$ Cleaner.run (LogManager.java:221)

javax.mail.MessagingException:IOException whi le发送消息;
嵌套异常是:
javax.activation.UnsupportedDataTypeException:无对象DCH for MIME类型multipart / mixed;
boundary =---- = _ Part_1_26867996.1316722766145
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1141)
at javax.mail.Transport。 send0(Transport.java:195)
在javax.mail.Transport.send(Transport.java:124)
在com.sun.mail.util.logging.MailHandler.send(MailHandler.java: 1594)
在com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
在java.util.logging.LogManager.resetLogger(LogManager.java:693)$ b $ java.util.logging.LogManager.reset(LogManager.java:676)$ b $ java.util.logging.LogManager $ Cleaner.run(LogManager.java:221)
导致:javax .activation.UnsupportedDataTypeException:无对象DCH,用于MIME类型multipart / mixed;
boundary =---- = _ Part_1_26867996.1316722766145$ javax.activation.ObjectDataContentHandler.writeTo上的
(DataHandler.java:877)
at javax.activation.DataHandler.writeTo(DataHandler。
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1099)
... 7 more

我已验证我的javax.mail.jar文件包含multipart处理程序:

  unzip  - l $ AS_INSTALL / glassfish / modules / javax.mail.jar | grep multipart 
2617 01-14-2011 15:37 com / sun / mail / handlers / multipart_mixed.class

我甚至在启用了激活调试的情况下运行该程序。这显示了以下相关部分:

  parse:multipart / * ;;的x java的内容处理器= com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry = true 
类型:multipart / *
命令:content-handler,Class:com.sun.mail.handlers.multipart_mixed

MailcapCommandMap:createDataContentHandler对于多部分/混合
搜索DB#1
搜索DB#2
搜索后备数据库#1
获取内容处理程序
类com.sun.mail.handlers。 multipart_mixed
无法加载DCH com.sun.mail.handlers.multipart_mixed;异常:java.lang.ClassNotFoundException:com / sun / mail / handlers / multipart_mixed



  MailcapCommandMap:createDataContentHandler for text / plain 
search DB#1
获得内容处理程序
类com.sun.mail.handlers.text_plain
无法加载DCH com.sun.mail.handlers.text_plain;例外:java.lang.ClassNotFoundException:com / sun / mail / handlers / text_plain

在这里?



谢谢,
Steve

解决方案

I在这里找到解决方案:



http://blog.hpxn.net/2009/12/02/tomcat-java-6-and-javamail-cant-load-dch/

虽然我很想知道更多关于这个问题背后的细节以及这个-Xbootclasspath选项为纠正问题所做的事情。如果我像这样运行我的类:

  java -Djava.util.logging.config.file = logging.properties -Xbootclasspath / p:/app/glassfish-3.1/glassfish/modules/javax.mail.jar MyClass 

它找到必要的课程和我收到我的电子邮件。现在我只需要弄清楚如何将这个配置转换成我的Glassfish服务器,并从这个简单的测试用例中尝试一个更真实的测试。


I'm attempting to set up a simple logging test with JavaMail in Java EE 6, using the jar files provided with Glassfish 3.1. There seems to be a wealth of questions out there on this subject, but I haven't found any answers that have helped yet. My test code looks like this:

import java.util.logging.Logger;

public class MyClass {
  private static final Logger LOGGER = Logger.getLogger("MyClass");

  public static void main(String[] args) {
    LOGGER.severe("This is a test");
  }
}

My logging.properties file contains this:

com.sun.mail.util.logging.MailHandler.mail.smtp.host={my mail hub FQDN}
com.sun.mail.util.logging.MailHandler.mail.smtp.port=25
com.sun.mail.util.logging.MailHandler.mail.to={me}
com.sun.mail.util.logging.MailHandler.mail.from={support address}
com.sun.mail.util.logging.MailHandler.level=WARNING
com.sun.mail.util.logging.MailHandler.verify=local
com.sun.mail.util.logging.MailHandler.subject=Application Error
com.sun.mail.util.logging.MailHandler.formatter=java.util.logging.SimpleFormatter

I build the class using:

javac -cp $AS_INSTALL/glassfish/modules/javax.mail.jar:$AS_INSTALL/install/lib/external/jaxb/activation.jar:. MyClass.java

Then I run the program using:

java -cp $AS_INSTALL/glassfish/modules/javax.mail.jar:$AS_INSTALL/install/lib/external/jaxb/activation.jar:. -Djava.util.logging.config.file=logging.properties MyClass

This results in the following error:

Sep 22, 2011 4:19:25 PM MyClass main
SEVERE: This is a test
java.util.logging.ErrorManager: 3: SEVERE: no object DCH for MIME type multipart/mixed;
        boundary="----=_Part_1_26867996.1316722766145"
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
        boundary="----=_Part_1_26867996.1316722766145"
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:877)
        at javax.activation.DataHandler.writeTo(DataHandler.java:302)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1748)
        at com.sun.mail.util.logging.MailHandler.toRawString(MailHandler.java:2196)
        at com.sun.mail.util.logging.MailHandler.send(MailHandler.java:1597)
        at com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
        at java.util.logging.LogManager.resetLogger(LogManager.java:693)
        at java.util.logging.LogManager.reset(LogManager.java:676)
        at java.util.logging.LogManager$Cleaner.run(LogManager.java:221)

javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
        boundary="----=_Part_1_26867996.1316722766145"
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1141)
        at javax.mail.Transport.send0(Transport.java:195)
        at javax.mail.Transport.send(Transport.java:124)
        at com.sun.mail.util.logging.MailHandler.send(MailHandler.java:1594)
        at com.sun.mail.util.logging.MailHandler.close(MailHandler.java:552)
        at java.util.logging.LogManager.resetLogger(LogManager.java:693)
        at java.util.logging.LogManager.reset(LogManager.java:676)
        at java.util.logging.LogManager$Cleaner.run(LogManager.java:221)
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
        boundary="----=_Part_1_26867996.1316722766145"
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:877)
        at javax.activation.DataHandler.writeTo(DataHandler.java:302)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1476)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1772)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1099)
        ... 7 more

I've verified that my javax.mail.jar file contains the multipart handler:

unzip -l $AS_INSTALL/glassfish/modules/javax.mail.jar | grep multipart
     2617  01-14-2011 15:37   com/sun/mail/handlers/multipart_mixed.class

I've even run the program with the activation debugging enabled. This shows me the following related parts:

parse: multipart/*;;            x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true
  Type: multipart/*
    Command: content-handler, Class: com.sun.mail.handlers.multipart_mixed

MailcapCommandMap: createDataContentHandler for multipart/mixed
  search DB #1
  search DB #2
  search fallback DB #1
    got content-handler
      class com.sun.mail.handlers.multipart_mixed
Can't load DCH com.sun.mail.handlers.multipart_mixed; Exception: java.lang.ClassNotFoundException: com/sun/mail/handlers/multipart_mixed

I even get a duplicate of the above for type text/plain.

MailcapCommandMap: createDataContentHandler for text/plain
  search DB #1
    got content-handler
      class com.sun.mail.handlers.text_plain
Can't load DCH com.sun.mail.handlers.text_plain; Exception: java.lang.ClassNotFoundException: com/sun/mail/handlers/text_plain

What am I missing here?

Thanks, Steve

解决方案

I found the solution here:

http://blog.hpxn.net/2009/12/02/tomcat-java-6-and-javamail-cant-load-dch/

Though I would love to know more about the details behind why this is an issue and what this -Xbootclasspath option is doing to correct the problem. If I run my class like this:

java -Djava.util.logging.config.file=logging.properties -Xbootclasspath/p:/app/glassfish-3.1/glassfish/modules/javax.mail.jar MyClass

It finds the necessary classes and I get my email. Now I just have to figure out how to translate this configuration into my Glassfish server and try a more "real" test from this simple test case.

这篇关于DCH类与JavaMail错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆