*
The moose likes Java Micro Edition and the fly likes Don't know why I am getting this expections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Don Watch "Don New topic
Author

Don't know why I am getting this expections

Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Hi

I am making an asp.net webservice that will be used on a midlet. I got currently only of my webservices that returns allmarks back to in the form of a string array.

When I test out my webservice in asp.net tester tool this is what I get.

<ArrayOfString>
<string>A00000000,John,Doe,1,100.00,25</string>
<string>A00000000,John,Doe,2,100.00,25</string>
<string>A00000000,John,Doe,3,100.00,25</string>
<string>A00000000,John,Doe,4,100.00,25</string>
<string>A00000001,Jane,Smith,1,100.00,25</string>
<string>A00000001,Jane,Smith,2,100.00,25</string>
<string>A00000001,Jane,Smith,3,100.00,25</string>
<string>A00000001,Jane,Smith,4,100.00,25</string>
<string>A00000002,Cynthia,Lee,1,100.00,25</string>
<string>A00000002,Cynthia,Lee,2,100.00,25</string>
<string>A00000002,Cynthia,Lee,3,100.00,25</string>
<string>A00000002,Cynthia,Lee,4,100.00,25</string>
<string xsi:nil="true"/>
</ArrayOfString>

Now I used the netbeans stubgenerator(Jave Me web serviceClient) and generated all the stubs.

I have another web method that I test and it works(it just returns a simple int back though).

So now I have this code

This code is in the CommandAction. The idea is that they click on the menu item and they get returned whatever they choose. In this case it allMarks



So now everytime I call that menu item to grab that webMethod I get this error

Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.
java.lang.ClassCastException
at Students.COMP_x0020_7031_Stub.ArrayOfString_fromObject(COMP_x0020_7031_Stub.java:169)
at Students.COMP_x0020_7031_Stub.AllMarks(COMP_x0020_7031_Stub.java:163)
at Students.StudentMidlet.commandAction(StudentMidlet.java:94)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(Display.java:2093)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(Display.java:2929)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(DefaultEventHandler.java:297)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(AutomatedEventHandler.java:667)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(DefaultEventHandler.java:711)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(DefaultEventHandler.java:608)



stub.java

private static ArrayOfString ArrayOfString_fromObject( Object obj[] ) {
if(obj == null) return null;
ArrayOfString result = new ArrayOfString();
result.setString((String [])obj[0]); -> line 169
return result;
}

public ArrayOfString AllMarks() throws java.rmi.RemoteException {
Object inputObject[] = new Object[] {
};

Operation op = Operation.newInstance( _qname_operation_AllMarks, _type_AllMarks, _type_AllMarksResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/AllMarks" );
Object resultObj;
try {
resultObj = op.invoke( inputObject );
} catch( JAXRPCException e ) {
Throwable cause = e.getLinkedCause();
if( cause instanceof java.rmi.RemoteException ) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}

return ArrayOfString_fromObject((Object[])((Object[]) resultObj)[0]); -> line 164
}

So I don't get it I never touched those classes they where generated for me.

To get rid of the grid lock warning I got this.

else if (command == allMarks)
{

Thread t = new Thread()
{

public void run()
{
GetAllMarks();
}
};
t.start();
}

public void GetAllMarks()
{
try
{

String[] allMarksArray = studentService.AllMarks().getString();
String row = allMarksArray[0];



String[] split = split(row);

data = RecordStore.openRecordStore(split[0], true);

StringItem record = new StringItem("RecordStore:", split[0]);

record.addCommand(openRecord);
record.setItemCommandListener(this);

frmMain.append(record);



data.closeRecordStore();
}
catch (RemoteException ex)
{
ex.printStackTrace();
}
catch (RecordStoreException ex)
{
ex.printStackTrace();
}
}

but then I just get this error so for now I moved it back

Uncaught exception java/lang/ClassCastException

So it just not catch those exceptions anymore but I bet there the same one.

So I am not sure what is going on.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Michael Hubele:



Are you sure this getString() method return an array of String? It seems where the exception came from.


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Originally posted by Duc Vo:

Are you sure this getString() method return an array of String? It seems where the exception came from.


As far as I am aware yes it does return an String[].

ArrayOfString
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Michael Hubele:


As far as I am aware yes it does return an String[].

ArrayOfString


What encoding did you use to generate the WSDL?
Try to generate WSDL with different encoding then generate the client stub with the new WSDL and try again. Normally, document/literal should work.
[ December 02, 2008: Message edited by: Duc Vo ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Duc, I'm afraid the question was posted in 2005. We all what you did "resurrecting a zombie". By now, if Michael's like a lot of us, he's not even working for the same employer any more, so he probably no longer cares.

Thanks for making the effort, though!


Customer surveys are for companies who didn't pay proper attention to begin with.
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Originally posted by Duc Vo:


What encoding did you use to generate the WSDL?
Try to generate WSDL with different encoding then generate the client stub with the new WSDL and try again. Normally, document/literal should work.

[ December 02, 2008: Message edited by: Duc Vo ]


I am not sure how to change encoding. I just did this to encode it

http://localhost:1229/Comp7031_Service.asmx?wsdl

that's it then I popped that link into my stub generator.
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
I made a little bit of progress but still don't understand why it's not working.


I went to the line it was crashing on and I put a try catch on it.



now I get a null pointer exception


java.lang.NullPointerException
at Students.StudentMidlet.commandAction(StudentMidlet.java:99)
at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(Display.java:2093)
at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(Display.java:2929)
at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(DefaultEventHandler.java:297)
at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(AutomatedEventHandler.java:667)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(DefaultEventHandler.java:711)
at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(DefaultEventHandler.java:608)
Execution completed.


So while watching the debugger I found this the parameter brings in an array that is one cell big. In this one cell it has like 12 cells in that.

When it tries to set this:

result.setString((String[]) obj[0]);

that's where it dies. It some how does not set and that's why I am getting null.

Now I don't know how to fix.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Tim Holloway:
Duc, I'm afraid the question was posted in 2005. We all what you did "resurrecting a zombie". By now, if Michael's like a lot of us, he's not even working for the same employer any more, so he probably no longer cares.

Thanks for making the effort, though!


Tim, it is active and new. Are you sure you got the right topic?
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Michael Hubele:

I went to the line it was crashing on and I put a try catch on it.
[/CODE]

Michael, normally you shouldn't modify generated resources. It will normally give more problem than what it can solve.

Are you generate your WebService using .NET? Either the project properties or publish options should tell you what encoding are you using. Your problem seems to be with the way the WSDL was generated.
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Originally posted by Duc Vo:

Michael, normally you shouldn't modify generated resources. It will normally give more problem than what it can solve.

Are you generate your WebService using .NET? Either the project properties or publish options should tell you what encoding are you using. Your problem seems to be with the way the WSDL was generated.


Yes of course but I wanted to exactly what error was being thrown.

I can't find anywhere where it would say encoding.

When I make my wsdl I get an xml looking file and that's it.

Also I don't understand why one of my webService methods works and the other one does not.
[ December 02, 2008: Message edited by: Michael Hubele ]
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Michael Hubele:


When I make my wsdl I get an xml looking file and that's it.


Can you post the WSDL file up here?

Also, what VS version are you using? And what project type are you using?

If I remember correctly, by default .NET WSDL is rpc/encoded and this encoding is not very well supported when crossing different languages.
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Originally posted by Duc Vo:

Can you post the WSDL file up here?

Also, what VS version are you using? And what project type are you using?

If I remember correctly, by default .NET WSDL is rpc/encoded and this encoding is not very well supported when crossing different languages.


Originally posted by Duc Vo:

Can you post the WSDL file up here?

Also, what VS version are you using? And what project type are you using?

If I remember correctly, by default .NET WSDL is rpc/encoded and this encoding is not very well supported when crossing different languages.


Hi

First I will say I figured it out. I was using the netbeans "Jave Me webservice Client" plugin thing and it must not be generating all the files possibly due to what you just said rpc/encoded thing.

I used the emulator from the wireless toolkit and generated it and it generated all my webMethods I just realized it was not even generating half of the methods and it now works.

I don't understand why it does not work and maybe if we figure out how to change this encoding we can figure it out. Weird that it generates some and then out of those some, some of them work and some don't.


I am using Visual Studios 2008 pro. Project type is a Webservice Application.

and here is the wsdl



I just realized that in firefox it does not show this line:

<?xml version="1.0" encoding="utf-8" ?>

so thats probably why I never knew what it was in(if that is the encoding your talking about). In IE it shows you though.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Originally posted by Michael Hubele:

I just realized that in firefox it does not show this line:

<?xml version="1.0" encoding="utf-8" ?>

so thats probably why I never knew what it was in(if that is the encoding your talking about). In IE it shows you though.


No, it's not. What I meant is about SOAP encoding. You are using document/literal so it should be OK. Properly there is problem with the stub generator of netbean. It's in here


Anyway, glad to hear that it's working now.

Cheers,
 
Don't get me started about those stupid light bulbs.
 
subject: Don't know why I am getting this expections