aspose file tools*
The moose likes Web Services and the fly likes Unable to create JAXBContext - Don't know why Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Unable to create JAXBContext - Don Watch "Unable to create JAXBContext - Don New topic
Author

Unable to create JAXBContext - Don't know why

Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
Hi to everybody:

I have to create a Web service which accesses a database query. I'm a newbie with web services and I created my first one using Netbeans 6.8 and tomcat 6 (with no db connection) and it worked really fine and I felt myself happy because I thought my job could be easy, so I said to my boss "I will do it soon!". Now when I attemp to deploy it accessin a DB the following error appears:


I have two packages one for the data the web servicies returns ans onother one for making the connection. To be honest I don´t understand the problem...

The web method is

The Web Service return an objeto of the class DatosAfiliado which has the following attributes:



The class DatoGrupo



What does "java.sql.Connection is an interface, and JAXB can't handle interfaces" mean? I do need to establish a connection to a DB...whe working with web services how should I do the connection?

Thanks a lot for your kindly help ... I need it ... I feel like I'm in the middle of the night ... no clues no lights.
Yair Ivan
Greenhorn

Joined: Jul 13, 2008
Posts: 15

Hi Enrrique:

Which aplication server you used? Tomcat or JBoss ? .... are using some Datasource ?.

By.


SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
Thanks Yair for your reply:

I'm using tomcat 6.0, JEE5, Netbeans 6.8. I have a simple Connection class which is used by onother class to query a view from a database.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I don't see it in your code, but from the exceptions it looks like you are trying to marshall JDBC objects (ResultSet, Connection etc etc) to XML.
An advice is not to let such objects "leak" out of the data layer - even in small applications.
Thus, write your code in such a way that you can temporarily replace the data layer with a dummy that returns fixed results and you will probably solve your problem at the same time.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
Hi Ivan Krizsan:

Thank you once again for helping me.

This is my first web service I’m trying to do in my lifetime. Before using a DB connection I used fixed data and it works perfectly. So, since my mother tongue is not English, let me see if I understood what you wrote: I shouldn’t execute the query directly in the webmethod but in a separate class?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
The usual procedure is to implement database-related code in a data layer, for instance using DAOs (data access objects).
Reference: http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
A DAO contains queries that fetches data from the database and stores that data in some kind of object. This latter part is crucial in your case. The data must be extracted from the ResultSet obtained when querying the database and inserted into some other POJO that you have written.
The POJO class may also be used as a return-type in method(s) implementing web service operations.
Please do not hesitate to ask if you need further clarification!
Best wishes!
Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
Hi once again Ivan:

I think I got your idea. I keep on trying ... wait for news soon.

Thank you very much for your patience and good advice.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to create JAXBContext - Don't know why