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
- 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
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?
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
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?
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.
Joined: Sep 17, 2005
@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.
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.
Joined: Sep 17, 2005
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.
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.
Joined: Sep 17, 2005
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.