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);
}
}

|
0

Oracle Sequence ID increase by double

if you are using trigger to generate sequence then might happened that the trigger is called twice. So to prevent from increasing the id value here is a little trick

CREATE OR REPLACE TRIGGER TRG_ABC BEFORE INSERT ON ABC
FOR EACH ROW
BEGIN
if :NEW.ID is null
then SELECT ABC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
end if;
END;

|
0

Oracle: use timestamp to convert string to date


You can use the timestamp keyword to convert a string to Date:

select * from retail_transactions where posted_date >= timestamp '2008-12-01 00:00:00';

|
0

5 Regular Expressions Every Web Programmer Should Know

in
Here are 5 Regular Expressions Every Web Programmer Should Know


|
0

How to convert String date into Date obj

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

try
{
Date today = df.parse("10/12/2009"); //converts String object into Date Object
System.out.println("Today = " + df.format(today)); //formats the Date object accourding to the format mentioned above
} catch (ParseException e)
{
e.printStackTrace();
}

|
0

Javascript confirm in aj4:commandLink in JSF

in ,

<a4j:commandLink onclick="if (! window.confirm('Are you sure?') ) {return false}" immediate = "true" >

don't forget to add immediate = 'true';



|

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