cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mail Configuration

Former Member
0 Kudos

I'm trying to send an email notification using JavaMail API. I've copied the mail.jar and activation.jar in my PORTAL-INF/lib folder. Initially I was getting an SMTP error. After much dabbling, I figured that the problem was with the "javamail.default.properties" file (under META-INF directory) which has entry for SMTP. It was pointing to a SAP SMTPTransport class. I changed that to point to SUN's SMTPTransport class. And I restarted the server. But my changes were over-written upon deployment. I want to know where does the J2EE Engine look to deploy mail.jar (because the property file is in that jar). My suspicion is that at the point of deployment, it is looking into some mail.jar to copy the property file to META-INF. Any help is appreciated.

Thanx,

Mahesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahesh,

the J2EE Engine contains its own JavaMail provider (represented at runtime as the JavaMail Client Service, and defines APIs by the Mail library). Having that said, I don't think you have to the mail.jar in the PORTAL-INF/lib folder; instead, you can declare a reference to the Mail library in the portalapp.xml as described <a href="http://help.sap.com/saphelp_nw04/helpdata/en/88/bdfc3f48ecc742e10000000a1550b0/frameset.htm">here</a>. However, this is just a suggestion from a person, who's not an expert in portal development => not 100% sure if it works!

Now back to the configuration of the J2EE Engine's mail provider... The separate protocol providers configuration is kept centrally in the javamail.default.providers file located under the \usr\sap\<SID>\<InstanceName>\j2ee\cluster\server0\META-INF directory. You can change the SMTP provider to the SUN's implementation there. This is the case up to SP10 of the J2EE Engine. With SP11 on, the Sun's implmentation of the SMTP protocol is used by default.

Hope that helps a bit!

Former Member
0 Kudos

I'd changed that file located in the META-INF directory. Upon re-start of the server, the file seems to be be over-written with old values i.e.

<i>protocol=smtp; type=transport; class=com.sap.engine.services.javamail.library.S

MTPTransport;</i>

instead of retaining

<i>protocol=smtp; type=transport; class=com.sun.mail.smtp.SMTPTransport;</i>

I wonder if this file is being copied from some mail.jar during deployment?

Former Member
0 Kudos

Hi Mahesh,

I actually did not give you the full solution in my first post. Just wanted to see if this works first. The reason the settings get reset upon restart of the server is because the J2EE Engine keeps it's configuration data in the database. So, you have edited the JavaMail configuration file in the local file system, whereas the J2EE Engine synchronizes the old version of the file from the DB upon startup.. and that causes the "reset" of the changes.

To edit the javamail.default.providers file in the DB you should use the Config Tool. Here are the steps to follow:

1. Launch Config tool using configtool.bat in \usr\sap\<SID>\<Instance>\j2ee\configtool dir.

2. Use the default settings to connect to the DB.

3. From the menu choose File -> Configuration Editor.

4. In the new screen, press the button with a tooltip <i>switch between view and edit mode</i> to switch to edit mode.

5. Browse the tree Configurations -> cluster_data -> server -> META-INF -> javamail.default.providers

6. Double-click on javamail.default.providers and enter the Sun's provider..

After that, restart the Engine so that the new settings get synchronized.. And it should work fine after that.

Regards,

Ivo

Former Member
0 Kudos

U the man Ivaylo!!!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I'm basically into webdynpro developement. So I can provide solution only from that perspective.

In webdynpro for using the javamail api we add the mail.jar and activation.jar in the buildpath of the project. May be you can try adding the jars in that fashion.i.e

by taking the context options(right click options)->properties->libraries->add variable->wdRuntime(the option mostly at the last in the popup)->extend-> com.tssap.ext.libs.j2ee_1.3->lib-> *.jar

Then in the order and export tab just select the jars and that's all.

Excuse me if was too elaborate.