wood burning stoves 2.0*
The moose likes Web Services and the fly likes New to Web services- Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "New to Web services- Problem" Watch "New to Web services- Problem" New topic
Author

New to Web services- Problem

Andy Barky
Greenhorn

Joined: Sep 17, 2005
Posts: 16
Hi Friends,

I am new to web services development. I am facing a problem, if anybody can help me a little urgent, I would really thankful.

I am getting following error

SEVERE: caught throwable
javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class com.crw.services.vo.DbValsVO nor any of its super class is known to this context.]

I get this error when I try to add the above VO into an arraylist like this

while(rS.next())
{
dbVals = new DbValsVO();

/*dbVals.setName(rS.getString(i++));
dbVals.setAmt(rS.getDouble(i++));
dbVals.setRetailCost(rS.getDouble(i++));
dbVals .setStartDate(rS.getString(i++));
dbVals.setShipFee(rS.getDouble(i++));
dbVals.setBalance(rS.getDouble(i++));
dbVals.setExpDate(rS.getString(i++));
dbVals.setMsg(rS.getString(i++));
*/
dealInfoArr.add(dbVals); // Error here
}

If I comment the last line of above contruct then error does not pop up.

Can somebody help me in solving this mystery? I am using tomcat 6 + JDK1.6 and windows 7.

Please help, this is urgent.

Thanks in advance,

Regards

- AB


SCJP, SCWCD/OCPJWCD, OCUP-100,OCUP-200, OCPJBCD-In Process
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Andy,
You code isn't quite clear! You are setting values retrieved from ResultSet into some variable "setter". What is the type of this variable? Presumably, "dealInfoArr" being ArrayList and you are setting "dbVals", which is empty. Did you mean "setter" variable should actually be "dbVals"? And also on performing what operation on the code you are getting exception?


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
How are you setting up class com.crw.services.vo.DbValsVO for JAXB?


Ping & DNS - my free Android networking tools app
Andy Barky
Greenhorn

Joined: Sep 17, 2005
Posts: 16
Hi Naren,

Sorry for confusion. I have been changing codes to check why I am getting error and pasted the code as it is while testing. Yes, setting is = dbVals. infact dbVals was setting. I changed it to dbVals only to test if it was a reserved word or something. dealInfoArr is arraylist and after setting dbVals (OR setting) I wanted to add that to dealInfoArr arraylist and return arraylist, kust like old times. Still can't do it as now you know why. As I said, adding this line dealInfoArr.add(dbVals) throws the error. The code executes but throws the error after execution is done. I.e. I get arraylist populated but i get error after printing arraylist contents at output. Any insights?

@ulf: That is my value object and Its a plain class just like any other java class in the package said above in the same project. Its a plain POJO/bean. Do I need to do something special? Can you explain me please?

Thanks in adv.

- AB
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Which version of JAX-WS/JAXB are you using? See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6419632

Also be sure to use the same version of the class on both sides of the connection.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Andy,
Thanks for the details.

I envisage you are using JAX-WS to create web service and whilst testing your web service you are getting the problem (owing to the fact I see JAXB MarshallException, which only comes when JAXB tries to marshall Java object to XML and as you are not directly using JAXB, it must be when web service trying to marshall just before sending response). Let me know otherwise. Have you tried using Generics(defining ArrayList<DbValsVO> dealInfoArr=new ArrayList<DbValsVO>()? Not sure if this could solve your problem but worth trying.

Also, it is worth re-creating your JAX-WS web service & client (if you did in IDE, it'd not take more than a minute), which would cover any POJO class changes.
Andy Barky
Greenhorn

Joined: Sep 17, 2005
Posts: 16
@ulf:I am using JAX-WS 2.1. Can you Please. explain me what you mean by using same version on both sides? Here is what I do. I have developer some java classes and then using bottom up approach, I created JAX-WS web service to quickly cater the requirement. I am using myeclipse 7.X version for all this and I have an option to run the web service explorer and test the web service locally. So I didn't create any of the client.

@Naren: Yes, I am using JAX-WS 2.1 I tried generics also, the same way you have mentioned. The first thing, I did was, -recreated web service with bottom up apprach in myEclipse 7.X version. I have not created any client as yet as I can test this webservice in web service explorer in myEclipse. Any other ideas?

Thanks for explaining me though and your time til now. I wish I could find the solution asap.

Thanks
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Andy,
Your problem seems strange to me! I too use MyEclipse with JAX-WS 2.1 and never had this kind of problem. If I saw your code, I could have helped your better. Once you get WSDL and XSD for your generated web service, can you create a clean project and try to create Top-Down web service? (You will have to copy Impl and DAO classes in there). This should hopefully work.
Andy Barky
Greenhorn

Joined: Sep 17, 2005
Posts: 16
@Naren:

I got the problem. In the main class, which is treated as web service implementation class, returns the arraylist is essentially also output from calling webservice. According to JAX-WS 2.1 and JAX-RPC 1.1 standards arraylist is not allowed as return type. So I modified the main class to return some customized class that contains arraylist that previously wished to return. Now this problem is solved but I still remained with one issue...(if somebody can explain) ...If the problem was at the returning arraylist, why the error was thrown at the last line where value object is being added to the arraylist?

@Ulf: Thanks for chipping in some ideas and your time.

Thanks Naren.

- AB
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Andy,
According to JAX-WS 2.1 and JAX-RPC 1.1 standards arraylist is not allowed as return type.

I know there were problems with Collections in JAX-RPC 1.1 but I don't think they are in JAX-WS 2.1. As I said, I have couple of web services created using JAX-WS 2.1 (JAXB is default data binding) within MyEclipse. It works perfectly fine. For your information, List maps to WSDL/XSD element with maxOccurs="unbounded". So, it is no different to returning complex type array.


f the problem was at the returning arraylist, why the error was thrown at the last line where value object is being added to the arraylist?

Are you not getting this problem now? As you're wrapping arraylist within a java class(to make things simple you may convert to array dbVals.toArray(dbValsArray)), I presume the above code still exists.
Andy Barky
Greenhorn

Joined: Sep 17, 2005
Posts: 16
Hi Naren,

Yes, the problem was with JAX-RPC 1.1 and not JAX-WS 2.1. Sorry for confusion.

Yep, After a little thought I guesses it the same that as you said wrapping array list was a problem.

Thanks a ton for these inputs and your time.

- AB
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: New to Web services- Problem
 
Similar Threads
Urgent !
Urgent....
URGENT!!
(jdbc+oracle) urgent please!!
Urgent !