关于Weblogic 下配了javamail session 后lookup时会出错?
weblogic javamail配置内容以下:
name: BibleMailSession
JNDIName: BibleMailSession
Properties:
mail.transport.protocol=smtp
mail.store.protocol=imap
mail.host=smtp.mycompany.com
mail.user=test
mail.debug=true
注:已经Targets
在Targets完后weblogic显示以年信息:
DEBUG: not loading system providers in <java.home>/lib
DEBUG: not loading optional custom providers file: /META-INF/javamail.providers
DEBUG: successfully loaded default providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPTransport=javax.m
il.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, In
], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap
IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provid
r[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider[STORE,imap,com.s
n.mail.imap.IMAPStore,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,po
3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], smtp=javax.mail.Provider[
RANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: not loading optional address map file: /META-INF/javamail.address.map
请问从上面的信息看,我的javamail session是否正确?或存在什么样问题?
我用JBuilder写了以下程序片段:
//lookup mail session in JNDI
Hashtable ht = new Hashtable();
ht.put( Context.INITIAL_CONTEXT_FACTORY ,"weblogic.jndi.WLInitialContextFactory" ) ;
ht.put( Context.PROVIDER_URL , "t3://xhy:7001" ) ;
ht.put( Context.SECURITY_PRINCIPAL , "xhy" ) ;
ht.put( Context.SECURITY_CREDENTIALS, "12345678" ) ;
InitialContext ctx = new InitialContext( ht );
//ctx.lookup("BibleMailSession") ;
Session session = (Session) ctx.lookup("BibleMailSession") ;
//set message with to ,subject, and message text
Message msg = new MimeMessage( session );
当执行到Session session = (Session) ctx.lookup("BibleMailSession") ;这句时出现以下错误:
javax.naming.ConfigurationException. Root exception is java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: javax.mail.Session
Start server side stack trace:
java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: javax.mail.Session
java.io.NotSerializableException: javax.mail.Session
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1143)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:107)
at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:82)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
End server side stack trace
然后我也用了implements java.io.Serializable序列化了我写的类,还是这样。
请高手帮帮忙!