• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to create JAXBContext - Don't know why

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 15
Eclipse IDE Firefox Browser Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Enrrique:

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

By.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic