0

Hi I am using maven I am trying to generate excel then send it as attachment to email in netbeans I am not gettig any error however in my tomcat I am getting error below I will really appreciate any hel or advice thank you

my pom

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.4.5</version>

</dependency>


    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
        <!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
        <dependency>
     <groupId>net.sourceforge.jexcelapi</groupId>
    <artifactId>jxl</artifactId>
    <version>2.6.12</version>
</dependency>
        <!-- End change plugin specific dependencies here -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.15</version>
            <type>jar</type>
        </dependency>
    </dependencies>

Error

SEVERE [http-nio-443-exec-10] org.oo.project1.try1.execute null
     java.lang.ClassCastException: javax.mail.util.ByteArrayDataSource cannot be cast to javax.sql.DataSource
            at org.oo.project1.try1.sendMail(carexcel.java:282)
            at org.oo.project1.try1.tryy(carexcel.java:240)
            at org.oo.project1.try1.execute(carexcel.java:116)
Wonderer
  • 65
  • 8

2 Answers2

3

Try to add <scope>provided</scope> to your javax.mail dependency,and restart and redeploy your Tomcat.

Seba López
  • 739
  • 1
  • 9
  • 18
0

Looks like your code has imports that confuse javax.sql.DataSource with javax.activation.DataSource.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40