Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

java.lang.SecurityException

Posted on 2006-07-03
9
Medium Priority
?
542 Views
Last Modified: 2008-01-09
Hi:

I copied a project from one folder to another in the file System. Then I opened it through eclipse and tried to run the programs. I got the following error message when the program starts by creating an object:

java.lang.SecurityException: class "javax.mail.Message"'s signer information does not match signer information of other classes in the same package.

I have a mail.jar on the project's buildpath and at the end of the program an email will be sent. But the exception is thrown at a line that is still far from sending emails.

Please help.
0
Comment
Question by:sdc248
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 150 total points
ID: 17031092
Sign all classes and jars with the same cert if they need to be signed
0
 

Author Comment

by:sdc248
ID: 17031934
All the classes and jars were copied from the other location and they weren't "signed". (Sorry I am not even sure what that means.) I made some changes to the java files, such as default values of some variables etc. and that's it. I don't think they need to be signed.
0
 

Author Comment

by:sdc248
ID: 17033696
I did some testing and found the problem is with a class called Data.  Data has two email sending functions together with a bunch of public static variables, which are referenced each time an object is created. If I commented out these two email functions, the problem would be gone, but of course the problem would have problem sending emails.  Any thoughts?

public static void sendEmail(String title, String content, String[] mailingList) {
            
            try {
                  Address[] addresses_to = new InternetAddress[mailingList.length];
                  
                  for (int i=0; i<mailingList.length; i++) {
                        addresses_to[i]= new InternetAddress(mailingList[i]);
                  }
                                    
                  Properties props = new Properties();
                  props.put("mail.host", "mailserver");
                  
                  Session mailConnection = Session.getInstance(props, null);
                  Message msg = new MimeMessage(mailConnection);      
                  Address sender = new InternetAddress ("notifications@camenergy.com", "system");
                  msg.setContent(content, "text/plain");
                  msg.setFrom(sender);
                  msg.setRecipients(Message.RecipientType.TO, addresses_to);
                  msg.setSubject(title);
                  
                  Transport.send(msg);
                              
                  System.out.println("email sent.");

            } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("fail to send email.");
            }
      }
      
      public static void sendEmail(String title, String content,
                  File attachment, String[] mailingList) {
            
            try {
                  Address[] addresses_to = new InternetAddress[mailingList.length];
                  
                  for (int i=0; i<mailingList.length; i++) {
                        addresses_to[i]= new InternetAddress(mailingList[i]);
                  }
                  
                  Properties props = new Properties();
                  props.put("mail.host", "mailserver");
                  Session mailConnection = Session.getInstance(props, null);
                  
                  Message msg = new MimeMessage(mailConnection);      
                  //Create the message part
                  BodyPart messageBodyPart = new MimeBodyPart();

                  //Fill the message
                  messageBodyPart.setText(content);

                  Multipart multipart = new MimeMultipart();
                  multipart.addBodyPart(messageBodyPart);

                  //Part two is attachment
                  messageBodyPart = new MimeBodyPart();
                  DataSource source = new FileDataSource(attachment);
                  messageBodyPart.setDataHandler(new DataHandler(source));
                  messageBodyPart.setFileName(attachment.getName());
                  multipart.addBodyPart(messageBodyPart);

                  // Put parts in message
                  msg.setContent(multipart);

                  Address sender = new InternetAddress ("notifications@camenergy.com", "system");
                  msg.setFrom(sender);
                  msg.setRecipients(Message.RecipientType.TO, addresses_to);
                  msg.setSubject(title);
                  
                  Transport.send(msg);
                              
                  System.out.println("email sent.");

            } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("fail to send email.");
            }
      }
      
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 92

Accepted Solution

by:
objects earned 225 total points
ID: 17033853
make sure none of your classes are in the javax.mail package, if they are then rename the package to something else.
0
 

Author Comment

by:sdc248
ID: 17034008
I am not sure I understand you.
By "in the javax.mail package" you mean classes that import javax.mail packages?
"Rename the package".. the package that contains above mentioned classes?

0
 
LVL 92

Expert Comment

by:objects
ID: 17034020
No I mean your application classes, make sure that you are not using that package name.
Also check that u don't have two copies of mail.jar available in classpath.
0
 

Author Comment

by:sdc248
ID: 17084088
I resolved the problem by moving the two email related functions away from Data class so they are no longer involved in the object creation process. It worked although I still don't know what happened.  Anyway, thank you guys for trying to help.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17084368
:-)
0
 
LVL 92

Expert Comment

by:objects
ID: 17086746
> Sign all classes and jars with the same cert if they need to be signed

that had nothing to do with your problem :)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question