Friday, 5 October 2012

Name Is Too Long To Represent Error in JSP

SMAP is defined in jsr-45 to provide debugging support for other languages . For example , jsp files are converted in to java files . to debug jsp source file , we will need jsp source line numbers as well as generated java file line numbers . This mapping is done in SMAP . So web servers , after generating java source file from jsp pages , also generates SMAP information and append it to compiled class files . This SMAP info is saved in a classpath attribute called SourceDebugExtension . The maximum permissible size of this attribute is 64KB . If you a have a very large jsp , it might happen that generated SMAP information is also big , exceeding 64KB threshold . When we enable debugger , and try to run this big jsp files , we will get following error
java.lang.InternalError: name is too long to represent .


The only solution to this problem is to reduce the size of your jsp . We can check the  smap information in generated class file which is appended in the end and will start something like this :  
SMAP
* JSPFILENAME
1 : 3,5
2,2 : 8
1#0 : 1
 

each row of smap is called stratum and contains line mappings  in this example ,
first row :
line number 1 in jsp is mapped to line numbers 3,4,5 in output java file
second row:
line number 2 is mapped to line number 8
; line number 3 is mapped ot line number 9
; third row :
# denotes included files in the jsp which are declared on top of smap definition.