Pages

Wednesday, February 16, 2011

ClassNotFoundException or NoClassDefFoundError.. what the hell is going on...

many a times we face "ClassNotFoundException" or  "NoClassDefFoundError"  and then we wonder what the hell is going on... not able to figure out what went wrong... some times we even see that even though class file or jar was exist in classpath, classloader unable to find it...
first try to understand that  "ClassNotFoundException" is thrown when specified class was not found in classpath by classloader, simply its a missing class in classpath or in a jar.
"NoClassDefFoundError" is also similar but with bit difference that it is a runtime error that is thrown by JVM when classloader did not find class definition while loading class caused by  "ClassNotFoundException",  it means that class was present at compile time but does not present at run time". normally both (error and exception) will print the causing class name that was not found by the classloader.

but if you come to notice that even though if class is present in classpath or in a jar and still classloader gives same error then try to look for dependent class imported inside the class that was thrown as "ClassNotFoundException"
Also check is that class has some static block/class variable defined from other package or jar, then make sure even those class/jars are present in classpath


in case of web applications or case where you use framworks like struts/spring or hibernate exceptions are wrapped and you may not come to know actual error that was causing the problem... some such scenarios could be

1. in web applications classloader has child and parent classloaders where classes loaded by parent are accessable to child classloaders but not child to parent. so in such case need to know which classloader is loading the class. for e.g. if you have some class (or class in jar)from shared lib of application referring to web-inf/lib or folder...

2. version compatibility. sometimes it happens that your application jdk is of lower version and jars created in higher version will create unsupported classversion error.. but thrown error could be "ClassNotFoundException"

3. recheck the fully qualified class name that may have typo error, e.g. class.forname or applicationcontext.xml in case of spring where beans are defined.

Wednesday, November 17, 2010

Google CEO interview in web2.0 summit in San Fransisco on the coming mobile revolution

On Monday at the Web 2.0 Summit in San Francisco, Google CEO Eric Schmidt did a wide-ranging interview  in which he shared new details about where Google sees the mobile revolution heading in the years ahead
In his interview Eric give presentation of his next version of Andriod which called as Gingerbread, He has also covered many other features that are coming in and how Googlesees the business opportunity in the mobile world. please have a look at this video.

Google TV

www.google.com
Google TV is a new experience that combines TV, the entire web, and apps -- as well as a way to search across them all. Take a tour, learn how it works, and find out how to get it.

Monday, November 1, 2010

Procedure / plsql support in jasper report

I am not very sure from which version Jasper started supporting this feature, but recently when I was evaluating 3.7.5 version I suddenly explored this... and it is so easy...!

Well here it is how...  when you write a query in the querystring tag, Jasper has added a property called "language" and here it supports for different languages querystring. so for calling a procedure from jasper report you need to set this attribute value as "plsql", and done! just call your procedure from querystring.

<queryString language="plsql">
     <![CDATA[call myproc()]]>
</queryString>








just to make sure that your jasperreport version support this feature check your xml schema or jasper that it has this property, I am quite sure that when jasper was having DTD as validate jrxml, that time it was not supported.

Wednesday, October 13, 2010

creating a crosstab report with jasper report

creating a crosstab report with jasper is became very easy task now...
as I explore it I found it very easy and simple to do...
the most tedious task was earlier to manage with the query to get the data in cross format. since there was no alternate or easy feature available from database either.
but for now with japserreport it become so easy that you don't have to modify your query at all just fire simple query and its done.
lets see how.

to show example I will use hssqldb that shipped with ireport tool.

concept: in a business case we have some times a requirement where we need a crosstab data for analysis which is difficult to achieve. because what we store in database is in number of rows and if we need that to be shown in columns is very difficult to achieve.

in our example lets see following result of table "tasks"

and assume now that we have a requirement to show this data in a different format as
group scheduled and actual and subgroup with tasks within and show them as columns
and subtasks as rows. that means it will look like something like this

                actual                           | scheduled
               task1 | task2 | task3      |task1 | task2 | task3     
 subtask1 
subtask2
subtask3
etc.

lets see how we can put this in cross tab report as below.
1. open ireport
2. file>>new>>launch report wizard (click) button
3. give reportname.>> next>>
4. select database connection>>add sql query as "select * from tasks" >> next>>
5. select all fields >> next>>
6. next>> finish>>
7. set all bands height as 0 except summery band.

8.   drag and drop crosstab icon on summery band.
9.   select "main report databaset" >> next
10. in rows we want to show subtasks so select "subtask Field" in rowgroup1 , group by "unique" >> next>>
11. now for column we have two level of grouping first is actual and scheduled and under it tasks so for
columngroup1 select "series Field" group by "unique">>
columngroup2 select "task   Field" group by "unique">> next>>
12. for data we will select "percent Field" , function "nothing" because we want to show values as it is.>> next>>
13. you can choose colour scheme of your choice and also column/row grouping if you want for my example i am leaving it unchecked that means I am not using row& column grouping.
 >> finish.

Thats all your report is done now click on preview and try to see how it looks.

after genrating view see it as below.