|
hi
thanx for your immediate reply . i have
configured the mailsession as descriibe in weblogic site.i have
configured the config.xml. after modifying the config.xml if i tried to run the
client application it is throwing following exception.
i am here attaching the MailClient.jave and my
bean class.can anyone suggest me what is the reason of the error.
thanx
rupalim
============================================================================================================================================
import
javax.naming.Context;
import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import ejb1.*; import java.util.*; public class MailClient
{
public static void
main(String[] args) {
try { Properties h = new Properties(); h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); h.put(Context.PROVIDER_URL, "t3://localhost:7001"); Context
initial = new InitialContext(h);
System.out.println("here in clinet1"); String
recipient = "[EMAIL PROTECTED]";
Object
objref = initial.lookup("mail");
ConfirmerHome home = (ConfirmerHome)PortableRemoteObject.narrow(objref, ConfirmerHome.class); Confirmer confirmer = home.create(); confirmer.sendNotice(recipient); System.exit(0); } catch (Exception ex)
{
System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); } } } ============================================================================================================================================ package ejb1;
import
java.rmi.RemoteException;
import java.io.Serializable; import java.io.IOException; import java.util.*; import java.text.*; import javax.ejb.*; import javax.mail.*; import javax.activation.*; import javax.mail.internet.*; import javax.naming.*; public class ConfirmerBean implements SessionBean { SessionContext sc;
private static final String mailer = "JavaMailer"; public void sendNotice(String recipient)
{
try
{
Context initial = new InitialContext(); Session session = (Session) initial.lookup("MailSession");
System.out.println("Found mail session " + session);
Message msg = new
MimeMessage(session);
msg.setFrom();
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(recipient, false));
msg.setSubject("Test Message from ConfirmerBean");
DateFormat dateFormatter =
DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT);
Date timeStamp = new Date();
String messageText = "Thank you for your order." + '\n'
+
"We received your order on " + dateFormatter.format(timeStamp) + ".";
msg.setText(messageText);
msg.setHeader("X-Mailer",
mailer);
msg.setSentDate(timeStamp);
Transport.send(msg);
System.out.println("Mail sent");
} catch(Exception e) { throw new EJBException(e.getMessage()); } } public ConfirmerBean() {}
public void ejbCreate() {} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {} }
=========================================================================================================================================
C:\bea\ex>java MailClient
here in clinet1 Caught an unexpected exception! javax.naming.ConfigurationException. Root exception is java.rmi.MarshalException: error marshalling return; nested 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:1148) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366) at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:115) at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:121) at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298) at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267) at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) End server side stack trace ; nested exception is: java.io.NotSerializableException: javax.mail.Session Start server side stack
trace:
java.io.NotSerializableException: javax.mail.Session at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366) at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:115) at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:121) at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298) at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267) at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) End server side stack trace |
