I'm using Java Mail to read messages through IMAP.
One of these messages has a problem in its content that's causing JavaMail to throw an UnsupportedEncodingException.
The problem lies in the fact that one of the parts contained in the message declares this content type:
Content-type: TEXT/HTML; charset=""
and JavaMail fails with that empty charset.
Reading on the JavaMail FAQs it seems that providing a custom charset provider could do the trick.
That's a two step approach:
- declare a class that extends CharsetProvider;
- create the file META-INF/services/java.nio.charset.spi.CharsetProvider and write the name of that custom class in it (I entered it with the full package).
In fact, I did what the FAQs prescribe and I finally managed to make it work on Tomcat within my Eclipse IDE, adding my custom jar to the classpath in Tomcat launch configuration.
That has been the only way so that the JVM (?, or the java library?) could see the file in META-INF and load my custom class, there was no other place where I tried putting that jar that made it work.
As my production server is JBoss, I tried to apply the same solution on it.
But so far I failed; here's what I've attemped:
- create a module, as in the current module system, and declare it as a dependency of my war;
- create a global module, like it is suggested here: https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-GlobalModules
- put the jar with my custom class in jboss main directory, close to jboss-modules.jar - in this case the jar gets indexed, meaning a .index file is created;
- change standalone.bat adding -cp ".;%JBOSS_HOME%\myjarfile.jar" around :RESTART, where the java executable is launched;
- add the jar on the -mp parameter
None of the above worked.
For completeness, I found these two pages:
- a bug filed at sun.com (updated recently) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4619777
- a similar problem, but on an old thread, I think pre-7.0 https://community.jboss.org/message/104429
As a final note, I'm on Windows Server 2003, running JBoss as standalone (no matter if it's started as a service or by direct invocation of standalone.bat).