cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.NoClassDefFoundError: javax.activation.DataSource

asif_hirani
Active Participant
0 Kudos

Hi,

I am trying to send email through my JSP Dynpage Component on Button Click.

I use below code to send the email :

STEP 1: Properties props = System.getProperties();

STEP 2: props.put("mail.smtp.host", "mailout.company.name");

STEP 3: Session session = Session.getDefaultInstance(props, null);

STEP 4: MimeMessage message = new MimeMessage(session);

at STEP 4: I get Java.lang.NoClassDefFoundError: javax.activation.DataSource

can anyone please help me to get around this error I added activation.Jar in my project through

Project>Properties>BuildPath but still keep getting the same error.

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The only issue that i can see then is whether you havent set CLASSPATH correctly to find activation.jar file.

CHk on that.

regards,

Shailesh

asif_hirani
Active Participant
0 Kudos

Hi Shailesh,

I tried to put activation jar file in jre lib folder just in case & set my classpath ( control panel --> system > advanced> environment variable class path to .;C:\Program Files\Java\jre1.5.0_10\lib\ext\activation.jar still I get the same error .

can you suggest any other way of resolving this issue, I tried same code in a web dynpro Java DC and it works perfectly fine there, it is only in JSP Dynpage DC i get this issue. I tried inlcuding activation dc in used DC METADATA of my portal DC still keep getting same error.

any help / suggestion would highly be apprecaited !!!

Thanks !!

Former Member
0 Kudos

Hello,

Also you can whether the JavaBeans(TM) Activation Framework package to be installed as well, since the JavaMail API requires it as a mandatory feature. You can try downloading it from -

[JAF 1.0.2 released|http://java.sun.com/javase/technologies/desktop/javabeans/glasgow/jaf.html]

This should get that resolved.

Thanks.

regards,

Shailesh

asif_hirani
Active Participant
0 Kudos

Hi ,

I installed JAF and set my CLASSPATH to activation.jar in it , but still the problem did not get resolved.

any other suggestion ?

it's Portal DC so you think adding any sharing Refrence / Private Refrence will help here

I tried doing that with values SAPJ2EE::sap.com/activation, javax.activation , activation

but could never get pass Portal Runtime Exceptions: Could not find portal application as they are not any portal application but simple JAR..

and I am not able to use them to send email...

kindly help !!!

Former Member
0 Kudos

Hi,

I use this also:


    Properties props = new Properties();
    props.put("mail.smtp.host", p_mailServer);
    Session mailsession = Session.getDefaultInstance(props, null);
    MimeMessage l_msg = new MimeMessage(mailsession);
...

and in sharingreference I have: knowledgemanagement

Romano

asif_hirani
Active Participant
0 Kudos

Hi Romano,

how do you exactly refer knowledgeManagement in sharing refrences in PORTALAPP.XML file

were you able to send the emails sucessfully with that sharing refrence ?

Thanks

Asif

Former Member
0 Kudos

Yes it works for me - I would not send it to you ;o)

asif_hirani
Active Participant
0 Kudos

you got your points ...Why would you send me now ..Thanks anyways..

Hi All,

I tried adding activation.jar in a library project and then adding refrence to that library project in my sharingrefrences as below

<property name="SharingReference" value="SAPJ2EE::test.com/libs"/>

<property name="SharingAccess" value="true"/>

still the Portal DC in which I have my code to send email gives exception

Could not find portal application SAPJ2EE::test.com/libs

any suggestions what could be missing in the way I refrence the JAR

Thanks !

Former Member
0 Kudos

Nono - ;o)

I would not send the portalapp.xml if it wouldn't work. It has nothing with the points - now I realized, that you have a standalone CD in SDA, I have a Portal Application Module. I will try to make one and let you know...

Romano

Former Member
0 Kudos

I'll try next time...

Former Member
0 Kudos

Asif,

I tried to make a standalone DC that has a AbstractPortalComponent which sends an email:

- created a library project, added activation.jar and mail.jar

- created a standalone DC deployable as SDA, put the library project as used DC for this project

- the portalapp.xml is as follows:


the edit does not allow me to put the portalapp.xml here, will be in next post...

It also worked also this way:


...
    <property name="SharingReference" value="knowledgemanagement"/>
...

- Here I created a AbstractPortalComponent called Mailer:


import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;

public class Mailer extends AbstractPortalComponent {

  private static final String MAIL_ENCODING = "windows-1250";

  public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
    response.write("started...");
    boolean ok = sendMail("mail.test.com", "toaddress[at]test.com", "fromaddress[at]test.com", "subject...", "body message");
    response.write("ended..." + (ok ? "OK" : "ERROR"));
  }

  public static boolean sendMail(
    String p_mailServer,
    String p_mailTo,
    String p_mailFrom,
    String p_subject,
    String p_body) {
    Properties props = new Properties();
    props.put("mail.smtp.host", p_mailServer);
    Session mailsession = Session.getDefaultInstance(props, null);
    MimeMessage l_msg = new MimeMessage(mailsession);
    try {
      l_msg.setFrom(new InternetAddress(p_mailFrom));
      InternetAddress[] address = { new InternetAddress(p_mailTo)};
      l_msg.setRecipients(Message.RecipientType.TO, address);
      l_msg.setSubject(p_subject, MAIL_ENCODING);
      l_msg.setSentDate(new Date());
      l_msg.setText(p_body, MAIL_ENCODING);
      Transport.send((Message) l_msg);
    } catch (MessagingException e) {
      return false;
    }
    return true;
  }
}

Deployed SDA, created an iview, started, got the email.

Portal version is:7.00 SP20

If you have more questions let me know...

Romano

Former Member
0 Kudos

<?xml version="1.0" encoding="UTF-8"?>

<application>

<application-config>

<property name="startup" value="true"/>

<property name="releasable" value="false"/>

<property name="SharingReference" value="SAPJ2EE::library:activation,SAPJ2EE::library:mail"/>

</application-config>

<components>

<component name="Mailer">

<component-config>

<property name="ClassName" value="Mailer"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

asif_hirani
Active Participant
0 Kudos

Hi Romano,

Thanks for taking efforts in replicating the scenario...But all I needed was that one line

<property name="SharingReference" value="knowledgemanagement"/>

you had said that in your very first reply that you have sharing reference to knowledgemanagement and I was not sure how to add that refrence as I saw N ways on google for adding refrences for activation jar, J2EE:sap.com/libraries . com.sap.activation

so I went for creating Seprate library DC and adding activation.jar in that library and refrencing that library in my portal DC for the activation jar , but we shouldn't be doing this as J2EE server already has activation jar and we shouldn't redploy that JAR manually.

all we need is to refrence it...one way it worked was as you suggested

<property name="SharingReference" value="knowledgemanagement"/>

other way which also works

<property name="SharingReference" value="com.sap.netweaver.coll.shared"/>

Thanks again .... Romano

one more thing just see If u can provide any help on this as well as (I will also create seprate thread for this issue). I want to redirect to external url (eg http://www.google.com) on click of button in web dynpro application, but I am accessing the application through portal.

I tried SAP's recommended approach

1) EXIT PLUG : http://help.sap.com/saphelp_nw70ehp1/helpdata/en/83/e7c24122e3c317e10000000a155106/frameset.htm

it works when i test web dynpro application separately but when I run it through Portal it gave me Error: saying use portal navigation when running inside portal and do not fire exit plug to navigate to external URL

2) so i tried

WDPortalNavigation.navigateAbsolute( "http://www.google.com", WDPortalNavigationMode.SHOW_INPLACE,(String) null,(String) null,WDPortalNavigationHistoryMode.NO_DUPLICATIONS,(String) null,(String) null,(String) null);

this wont work as google.com web page is not part of portal content's (Role/iview)

3)WDClientUser.forceLogoffClientUser("http://www.google.com");

again this work's when web dynpro application is tested standalone but when i run it through portal it doesn't work

can you provide any help on this ? I am too short of time to make it work..I have SAP message opned for this..it may be silly thing again which i may not be knowing

Former Member
0 Kudos

Sorry,

I'm not a WD expert ;o)

Romano

Former Member
0 Kudos

HI,

I have found this - maybe will be of some help: [How to Redirect to a external URL |]

Romano

asif_hirani
Active Participant
0 Kudos

Thanks Romano...

but that will not solve my problem as the given code in the thread will redirect in external window which I do not want..I want redirect to happend in same window and user should no longer be able to access Portal.

Former Member
0 Kudos

What about this?

[redirect logoff page of sap portal |]

Romano

asif_hirani
Active Participant
0 Kudos

Hi Romano,

problem was resolved Thanks for your help !!

Below solution Worked -

1) set ume.logoff.url value to <url to be redirceted to>

2) create html file in KM to execute script

EPCM.getSAPTop().document.forms\"logoffForm\".submit();

or

(something like: EPCM.getSAPTop().document.location.href=<new url>).

3) create KM Navigation iview using above html file

4) use WdPortal Navigation inside web dynpro code to navigate to the KM

iview

Former Member
0 Kudos

Glad to hear about a success!

Romano

Answers (0)