yun liu

Greenhorn
+ Follow
since Apr 11, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by yun liu

We assumed that if we used messages or errors
(bean:message and html:errors) within a model and the message was not
found in the message resources for that model, that Struts would look to
the default app for the messages. We did not like the idea of duplicating
messages across all model. For example, most all of our modules will be
using messages for our buttons like Save, New, Cancel, Delete, etc. (we are
using i18n so it's not feasible to hard-code these). We wanted to define
these once in the message resources for the default app and override the
message in the model as necessary.
How to do this,Please give me some advise.
I used Struts1.2.

Thanks advance
david.liu
17 years ago
hi all:
How to figure out a free Disk space using Java?

thanks!
18 years ago
I see, thanks very much!
18 years ago
I am only want to knowed ,why isn't running outside of weblogic?
javax.mail.Session isn't Serializable that is real reason?
or other reasons?

thanks very much!
18 years ago
I writed a java application that useing weblogic mail session outside weblogic ,show full codes,
<mycode>
import ........;
public class WebligicMail {
private Session mailSession;
public static void main(String[] args) {
WebligicMail weblogicMail = new WebligicMail();
try {
weblogicMail.init();
} catch (NamingException e) {
e.printStackTrace();
return;
}
try {
weblogicMail.sendMail("dliu@cn.test","test test");
} catch (MessagingException e) {
e.printStackTrace();
}
}
private void init() throws NamingException {
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL,"t3://localhost:7001"); // provider url is right
h.put(Context.SECURITY_PRINCIPAL,"weblogic");
h.put(Context.SECURITY_CREDENTIALS,"password");
Context namingContext = new InitialContext(h);
Session mailSession = (Session) namingContext.lookup("jndi/mail");
}

public void sendMail(String mailTo, String context) throws MessagingException {
Message msg = new MimeMessage(mailSession);
msg.setFrom();
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(
mailTo, false));
msg.setSubject("test weblogic mail");
msg.setSentDate(new Date());
// Content is stored in a MIME multi-part
// message// with one body partMimeBodyPart
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(context);
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp);
msg.setContent(mp);
Transport.send(msg);
}
}
</mycode>
<errors>
javax.naming.ConfigurationException. Root exception is java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: javax.mail.Session
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
at weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.dsii.mail.weblogic.WebligicMail.init(WebligicMail.java:60)
at com.dsii.mail.weblogic.WebligicMail.main(WebligicMail.java:36)
Caused by: java.io.NotSerializableException: javax.mail.Session
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:106)
at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:93)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:407)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:356)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:123)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:351)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)
</errors>

what's wrong?
thanks!
18 years ago
hi all,

Here is a problem that I have with my the usage of Java Mail Session
that i set up in weblogic. I use weblogic 8.1

When I do the JNDI lookup to the mail session (set up in the weblogic
admin interface), it looks that the lookup itself is ok but when i do
the casting, it doesn't work. Have a look at my code and the trace
produced :

writed an external client,follow:
<myCode>
Properties h = new Properties();


h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory
");
h.put(Context.PROVIDER_URL,"t3://localhost:7001"); // provider url is
right
h.put(Context.SECURITY_PRINCIPAL,"weblogic");
h.put(Context.SECURITY_CREDENTIALS,"password");
Context namingContext = new InitialContext(h);
Session mailSession = (Session) namingContext.lookup("jndi/mail");
</myCode>


<trace>
javax.naming.ConfigurationException. Root exception is
java.rmi.MarshalExceptio
n: error marshalling return; nested exception is:
java.io.NotSerializableException: javax.mail.Session
java.io.NotSerializableException: javax.mail.Session
<<no stack trace available>>
</trace>


I can understand the exception as javax.mail.Session doesn't implement
serializble. But How do I have to do to make it work, then? Because what
I do is just how it's explained in the weblogic doc. Is there a mistake
in the do? Do I have to cast to somethig else?


Any help would be very appraciated.


Thanks.
18 years ago