on 04-09-2008 7:34 AM
Hi Experts,
below is the code i wrote inside a view in webdynpro(java).
public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSave(ServerEvent)
//this.CreateXML();
StringBuffer strb=new StringBuffer("testStringBuffer");
strb.append("123");
strb.append(0);
wdComponentAPI.getMessageManager().reportSuccess(strb.toString());
//@@end
}
when i run this application i am getting an exception as given below.
java.lang.NoSuchMethodError: java/lang/StringBuffer.append(D)Ljava/lang/AbstractStringBuilder
and when i do
strb.append("123").append(0);
i am getting an exception stating that
"the type AbstractStringBuilder is not visible".
Please help me.
Thanks,
Srinivas
Hi Srinivas,
The problem is with the StringBuffer class ( gosh i have always had problems with it).
I found some abstract articles indicating that StringBuffer.append doesn't necessarily return StringBuffer anymore (see http://www.nearinfinity.com/blogs/page/sleberkn/20060721) so it seems like it can (or does) return AbstractStringBuffer even though the JDK still indicates it returns StringBuffer so then subsequent .append calls in the statement fail to compile.
As an alternative solution you can write something like
String strb=new String("testStringBuffer");
strb =strb + "123";
strb =strb + "0";
wdComponentAPI.getMessageManager().reportSuccess(strb);
Best Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
solved(temporarily)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
Thankyuou all for your replies. as said by all of you all the things are correct.
1. when i do a strringbuffer,append it is returning a AbstractStringBuilder rather than StringBuffer.
2.My JRE version no. is 1.6 where as my EPServer JRE version no. is 1.4
So what i did is i made use of string rather than stringbuffer, and done a concatination
i.e,
instead of
StringBuffer sb=new StringBuffer();
sb.append("str1");
sb.append("str2");
I did
String s=null;
s=s1+s2;
now my program is not running. I know using s1+s2 is not recomended, but to temporaryly solve my problem i did this. later i will try to change my JRE version(to make it compatable with my server's JRE).
Thank you all for your valuble sugessions.
Thanks,
Srinivas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srinivas,
Try checking the versions of java runtime on server as well as on your machine. StringBuffer class throws error at runtime when Java Runtime version differs in client machine and server machine.
It happened to me once. In my machine JRE version was 1.6 while at server version was 1.4.2_13
Regards,
Gopal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gopal,
thanks for yopur reply. in my system jre version no is 1.6, and i checked in my nwds there also it is 1.6
i am having a doubt,
that why stringbuffer.append.append is not supported in my studio?
as u said if the version no. are different then i will get an error at runtime.
but when i do stringbuffer.append.append i am getting an error at designtime it self,
and more over if try to import java.lang.AbstractStringBuilder in my view then also i am getting the same error as "java.lang.AbstractStringBuilder is not visible". please help me.
thanks,
Srinivas.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.