24 Haziran 2009 Çarşamba

Create mail session with Weblogic

Create mail session with Weblogic

The aim of the mailsession in Weblogic is avoid to parameter your session in your java code and obtain a dynamic mail server without to recode your application.

Here are the steps :
  1. In your Administration console, go to Service, Mail Sessions.Then click on New.
  2. Fill the information like the screen :


The "name" is for weblogic, but the "JNDI" Name will be the session name used in your java code to retrieve the server mail parameters.

  • then you have to put the parameters of your mail server in the "JavaMail Properties" box :
PropertyDescriptionDefault
mail.store.protocolProtocol for retrieving email. Example: mail.store.protocol=imapimap
mail.transport.protocolProtocol for sending email. Example: mail.transport.protocol=smtpsmtp
mail.hostThe name of the mail host machine. Example: mail.host=mailserverLocal machine
mail.userName of the default user for retrieving email. Example: mail.user=postmasterValue of theuser.name Java system property.
mail.protocol.hostMail host for a specific protocol. For example, you can set mail.SMTP.host andmail.IMAP.host to different machine names. Examples:mail.smtp.host=mail.mydom.com mail.imap.host=localhostValue of themail.hostproperty.
mail.protocol.userProtocol-specific default user name for logging into a mailer server. Examples:mail.smtp.user=weblogic mail.imap.user=appuserValue of themail.userproperty.
mail.fromThe default return address. Examples: mail.from=master@mydom.comusername@host
mail.debugSet to True to enable JavaMail debug output.False

in my case :


you also can specify more information (report to the tab before) like user login and hostname.

  • Click Next, check your Managed server and click Finish.
Now the Java code part :

  • The imports :
import java.util.*;
import javax.activation.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.naming.*;
  • Load your Weblogic MailSession :
InitialContext ic = new InitialContext();
Session session = (Session) ic.lookup("myMail");
  • If you need to override the Weblogic parameters you can do with the following code and the java.util.Properties Object (OPTIONAL)
Properties props = new Properties();
props.put("mail.transport.protocol", "imap"); // new protocol instead of smtp
props.put("mail.smtp.host", "mailhost");
// use mail address from HTML form for from address
props.put("mail.from", emailAddress);
Session session2 = session.getInstance(props);
  • Construct a MimeMessage
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse(to, false));
    //"to" and "subject" are strings define by the user or developer
    msg.setSubject(subject);
    msg.setSentDate(new Date());
    // Content is stored in a MIME multi-part message
    // with one body part
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText(messageTxt);
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
  • Send the message
Transport.send(msg);
For more informations on How to use javamail API with Jdeveloper : http://edocs.bea.com/wls/docs90/programming/javamail.html

Now you have a mail sent through your application with a dynamic smtp or mail server ! (you just need to change java properties in your MailSession in Weblogic)



17 Haziran 2009 Çarşamba

BEA-101216 BEA-149231 (Startup Hataları)

Rac kurulumdan dolayı kaynaklanan gateway ve policymanager db bağlantı hatasında
şağıdaki config dosyalarını güncellemen lazım

/oracle/product/10.1.3.1/soasuite/owsm/config/policymanager/policymanager-config-installer.properties dosyasında

policymanager.policyRepository.url=jdbc:oracle:thin:@//10.6.119.130:1521/TTSOA2

satırını

policymanager.policyRepository.url=jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=10.6.119.129) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.6.119.130) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TTSOA)))

şekline getirmelisiniz.

ayrıca
policymanager.componentRepository.url=jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=10.6.119.129) (PORT=1521)

şekline getirilecek.

/oracle/product/10.1.3.1/soasuite/owsm/config/gateway/gateway-config-installer.properties dosyasında

gateway.repository.url=jdbc:oracle:thin:@//10.6.119.130:1521/TTSOA2

satırını

gateway.repository.url=jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=10.6.119.129) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.6.119.130) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TTSOA)))

şekline çevirilmeli.