0

Problem !!! java.lang.ClassNotFoundException: [Ljava.lang.String

This, java.lang.ClassNotFoundException: [Ljava.lang.String is killing me a lot. I've suspected so many things about it, but actually is quite different. Its also mentioned in sun's bug database

Here are some of the solutions i've found in different sites;

1.http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434149

This link recommends the following actions to solve this bug:

1) Add -Dsun.lang.ClassLoader.allowArraySyntax=true if you want to use a
library for which you don't have the source with JDK6

2) Change loader.loadClass( name ) to Class.forName( name, false, loader ) if
you own the code.

class org.apache.catalina.loader.WebAppClassLoader
uses this code to load classes:

clazz = loader.loadClass(name);

Can you please change the sections of code where this line is used (1352 and
others) to
clazz = Class.forName( name, false, loader);



2. http://dev.bostone.us/2009/02/23/javaxfacesfacesexception-javalangclassnotfoundexception-ljavalangstring/
  • jdk1.6 unlike 1.5 it will not attempt to load class (java.lang.String) by name by default
  • it is easily solvable by locating JVM runtime in Eclipse's preferences (Window->Preferences->Installed JREs), highlighting the entry and adding runtime parameter -Dsun.lang.ClassLoader.allowArraySyntax=true
links:
  • https://blog.coremedia.com/cm/post/2672591/RE_Java_6_javalangClassNotFoundException_LjavalangString_exception.html
  • http://forums.java.net/jive/thread.jspa?threadID=15823

|
0

A simple secure MIME message SendMail function

Here is a simple secure MIME message sendMail function;


public boolean sendMail(String to, String subject, String text) {

Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", Constants.SMTP_HOST_NAME);
props.put("mail.smtp.port", Constants.SMTP_HOST_PORT);
props.put("mail.smtp.auth", "true");

Authenticator auth = new SMTPAuthenticator();

Session mailSession = Session.getInstance(props, auth);

try{
Transport transport = mailSession.getTransport();

MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(Constants.SMTP_MESSAGE_SENDER));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject(subject);
message.setHeader("MIM9
message.setHeader("Content-Type", "text/html");
message.setContent(text, "text/html");

transport.connect();
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();
return true;
} catch (MessagingException messagingException) {
messagingException.printStackTrace();
return false;
} catch (Exception exception){
exception.printStackTrace();
return false;
}


}

private class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = Constants.SMTP_AUTH_USER;
String password = Constants.SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);
}
}

|

Copyright © 2009 So That I Can Remember All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.