java - OSGI and different mail.jar send plain text attachement, throw exception: "text/plain" DataContentHandler requires String object, -


in env, 2 different mail jars exist in 2 different classloaders, since our requirement keep 2 version of mail jar work together.

but when sending plain-text attachment, throws exception:

caused by: java.io.ioexception: "text/plain" datacontenthandler requires string object, given object of type class [b     @ com.sun.mail.handlers.text_plain.writeto(text_plain.java:152)     @ javax.activation.objectdatacontenthandler.writeto(unknown source)     @ javax.activation.datahandler.writeto(unknown source)     @ javax.mail.internet.mimebodypart.writeto(mimebodypart.java:1476)     @ javax.mail.internet.mimebodypart.writeto(mimebodypart.java:865)     @ iaik.smime.smimebodypart.writeto(unknown source)     @ javax.mail.internet.mimemultipart.writeto(mimemultipart.java:462)     @ com.tibco.ax.fw.mime.bcmimemultipart.writeto(bcmimemultipart.java:186)     @ com.tibco.ax.fw.mime.bcmultipartmixed.writeto(bcmultipartmixed.java:77)     @ javax.activation.objectdatacontenthandler.writeto(unknown source)     @ javax.activation.datahandler.writeto(unknown source)     @ javax.mail.internet.mimebodypart.writeto(mimebodypart.java:1476)     @ javax.mail.internet.mimemessage.writeto(mimemessage.java:1772)     @ javax.mail.internet.mimemessage.writeto(mimemessage.java:1748)     @ com.tibco.ax.ebms3.runtime.outbound.ebms3obmimemessage.encodemessage(ebms3obmimemessage.java:275) 

this week focus on research issue, figured out. here analysis , resolution.

basically, related mailcapcommand map(defaultcommandmap ,a system static map defined in jre , class name commandmap.java) , both 2 classloader updated mailcapcommand map in ebxml runtime evn, when enabled “automaticlly update saml token”.

details when bc interior server start up, class smimeutil.init() load mail caps defined in file “com/tibco/ax/fw/ediint/resource/defaultmailcap.properties”, include

        text/*;;x-java-content-handler=com.tibco.ax.fw.mime.defaulttexthandler 

and when sbr load sbr’s jars load mail caps logic, , add 2 special mail cap command

        text/xml={content-handler=[com.sun.xml.ws.encoding.xmldatacontenthandler] 

text/plain={content-handler=[com.sun.xml.ws.encoding.stringdatacontenthandler] // not jars sbr

and pp send transactions attachment, mail.jar logic try find datacontenthandler mailcapcommand map through contenttype. instance, qa test case “text/plain”, program com.sun.xml.ws.encoding.stringdatacontenthandler process content, unfortunately, class loaded our customize sbr classloader, in classloader can’t find class, system system default com.sun.mail.handlers.text_plain process content. in com.sun.mail.handlers.text_plain, must pass string object instead of byte array parameter of writeto method. exception “java.io.ioexception: ‘text/plain’ datacontenthandler requires string object, given object of type class [b” throw out.

what resolution add below 2 mailcap mailcapcommand map when starting bc interior server in class smimeutil.init().

 commandmap mimemap = commandmap.getdefaultcommandmap();     mc.addmailcap("text/plain;;x-java-content-handler=com.tibco.ax.fw.mime.defaulttexthandler");      mc.addmailcap("text/xml;;x-java-content-handler=com.tibco.ax.fw.mime.defaulttexthandler"); 

since handle text/plian , text/xml text in our bc program. above codes have no harm bc interior server. bring issues sbr request attachment. luck us, don’t use feature, simple send http request smal token. ok saml part.

last did text resolution, it’s works both , saml update.

if have goods suggestion please let me know.

share|improve answer
    
so have answered own question? – neil bartlett aug 3 '15 @ 10:32
    
yes, finally, resolove myself. – frank wu jul 1 '16 @ 8:13
    
can post solution? otherwise question useless on stackoverflow. – neil bartlett jul 1 '16 @ 18:26
    
@neilbartlett solution answer post. basiclly after customize classloader loaded classes jvm, , force load mailcups map. commandmap mimemap = commandmap.getdefaultcommandmap(); mc.addmailcap("text/plain;;x-java-content-handler=com.tibco.‌​ax.fw.mime.defaultte‌​xthandler"); mc.addmailcap("text/xml;;x-java-content-handler=com.tibco.ax‌​.fw.mime.defaulttext‌​handler"); – frank wu jul 3 '16 @ 3:28

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments