Showing posts with label IllegalArgumentException. Show all posts
Showing posts with label IllegalArgumentException. Show all posts

Friday, December 16, 2011

java.lang.IllegalArgumentException: Illegal pattern character 'AT'

I got below mentioned error, while trying to add characters other than pre defined date pattern.

Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'AT'
    at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:769)
    at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:576)
    at java.text.SimpleDateFormat.(SimpleDateFormat.java:501)
    at java.text.SimpleDateFormat.(SimpleDateFormat.java:476)

To add your desire Characters or String you need to by-pass it using escape sequence. Please see the correct syntax below. Note the escape character single quote ('), whatever you want to pass a Characters or String need to by-pass it using escape character single quote (').

Correct Syntax:

Calendar cal = Calendar.getInstance();
SimpleDateFormat sdFormat =  new SimpleDateFormat("yyyy-MM-dd 'AT' hh:mm:ss");
String strDate = sdFormat.format(cal.getTime());
System.out.println("Now : "+strDate);

Output:

Now : 2011-12-16 AT 03:57:40

Friday, September 2, 2011

java.lang.IllegalArgumentException

Few days ago i absorbed below mentioned error on JBoss console,

06:34:22,276 ERROR [ContainerBase] Servlet.service() for servlet jsp threw exception
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1293)
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1254)
at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
at com.vignette.portal.website.internal.HttpSessionWrapper.setAttribute(HttpSessionWrapper.java:107)
at org.apache.jasper.runtime.PageContextImpl.doSetAttribute(PageContextImpl.java:340)
at org.apache.jasper.runtime.PageContextImpl.setAttribute(PageContextImpl.java:319)
at org.apache.jsp.survey.question_jsp._jspService(question_jsp.java:431)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Solution :
I traced back the root cause of the error. I went to that particular JSP file and found that particular java class which was throwing this error.

I implemented interface Serializable for that class

eg :

class Xyz implements Serializable { }