You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ".LX Max Länzlinger" <ma...@hrm-systems.ch> on 2009/06/25 09:05:25 UTC
xsd Validation and CXFNonSpringJaxrsServlet and ssl
Hello all,
I need a REST-Service preferable with CXFNonSpringJaxrsServlet. Given is Tomcat, ssl, java 6.
I defined the servlet in web.xml with init param jaxrs.serviceclasses the name of my service Class.
When starting Tomcat, CXFNonSpringJaxrsServlet.loadClass throws an ClassNotFoundException of my service class.
Questions:
1) Do I need configure ssl specially, could it be that load.class URLClassLoader$1.run cannot find my class due to ssl of tomcat??....
2) Do I need - additionally to jaxrs.serviceClasses - add the parameter jaxrs.providers? With same name of my service class? (I miss a complete example for CXFNonSpringJaxrsServlet, the documentation does not swhow the classes content)
3) I actually need cxf for configuring/doing xsd-File Validation (because the sun implementation cant do it), but what I don't know, is Spring needed for this, or is CXFNonSpringJaxrsServlet enough?
Many thanks in advance!
________________________________
Ab dem 1. August sind nur noch Mail-Adressen vorname.nachname@hrm-systems.ch in Betrieb. Andere Adressen werden ab dem 1. August 2009 nicht mehr erreichbar sein.
Dès le premier août seules les adresses email suivantes seront encore valables: prenom.nom@hrm-systems.ch. Les courriels envoyés aux autres adresses ne seront donc plus acheminés à partir du premier août 2009.
Dal primo di agosto saranno validi solo i seguenti indirizzi email: nome.cognome@hrm-systems.ch. La posta elettronica inviata agli altri indirizzi non sarà più inoltrata a partire dal primo di agosto 2009.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
It proved CXFNonSpringJaxrsServlet had imported a wrong ClassUtils; just
rerun today the TCK with 2.2.4-SNAPSHOT and CXFNonSpringJaxrsServlet was
loading application classes just fine from a shared folder
also added "jaxrs.schemaLocations" init parameter too
Sergey
Sergey,
On Thu June 25 2009 11:33:47 am Sergey Beryozkin wrote:
> I think ssl is not the issue here. I've used CXFNonSpringJaxrsServlet when
> working on TCK and to bypass this issue I had to copy
> org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet (only) to a given
> web
> app classes folder, I presuming CXF libs are in shared tomcat folder.
>
> May be we can do something similar to what Spring does by somehow making
> the child web app loader visible to the parent one loading CXF classes.
> For
> now please extract this class from CXF libs...
You really shouldn't need to do that. The Thread.contextClassLoader SHOULD
be the classloader of the application/war. Anything we do that
dynamically
loads classes or anything should be using the contextClassLoader. That
should make it so the CXFNonSpringJaxrsServlet doesn't need to be munged in
that way.
Dan
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p25722066.html
Sent from the cxf-user mailing list archive at Nabble.com.
RE: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Dan,
I'm using ClassLoaderUtils to load the classes and it should take care of it - but it was not the case.
Would it be possible to post the stack trace - I'll investigate further, it would save me a bit of time - may be ClassLoaderUtils are not used properly... Or I will try to reproduce and look into it again later on...
Cheers, Sergey
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: 26 June 2009 15:53
To: users@cxf.apache.org
Cc: Sergey Beryozkin
Subject: Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Sergey,
On Thu June 25 2009 11:33:47 am Sergey Beryozkin wrote:
> I think ssl is not the issue here. I've used CXFNonSpringJaxrsServlet when
> working on TCK and to bypass this issue I had to copy
> org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet (only) to a given web
> app classes folder, I presuming CXF libs are in shared tomcat folder.
>
> May be we can do something similar to what Spring does by somehow making
> the child web app loader visible to the parent one loading CXF classes. For
> now please extract this class from CXF libs...
You really shouldn't need to do that. The Thread.contextClassLoader SHOULD
be the classloader of the application/war. Anything we do that dynamically
loads classes or anything should be using the contextClassLoader. That
should make it so the CXFNonSpringJaxrsServlet doesn't need to be munged in
that way.
Dan
>
> you may want to add jaxrs.providers if you need to add some custom
> providers in addition to those shipped with CXF JAX-RS
>
> > 3) I actually need cxf for configuring/doing xsd-File Validation (because
> > the sun implementation cant do it), but what I don't know, is Spring
> > needed for this, or is CXFNonSpringJaxrsServlet enough?
>
> Unfortunately not, it's not possible yet to do it with
> CXFNonSpringJaxrsServlet. I need to introduce the support for some commonly
> used features, like schema validation/etc.. Will work on it...
>
>
> thanks, Sergey
>
> .LX Max Länzlinger wrote:
> > Hello all,
> >
> > I need a REST-Service preferable with CXFNonSpringJaxrsServlet. Given is
> > Tomcat, ssl, java 6.
> > I defined the servlet in web.xml with init param jaxrs.serviceclasses the
> > name of my service Class.
> > When starting Tomcat, CXFNonSpringJaxrsServlet.loadClass throws an
> > ClassNotFoundException of my service class.
> >
> > Questions:
> > 1) Do I need configure ssl specially, could it be that load.class
> > URLClassLoader$1.run cannot find my class due to ssl of tomcat??....
> > 2) Do I need - additionally to jaxrs.serviceClasses - add the parameter
> > jaxrs.providers? With same name of my service class? (I miss a complete
> > example for CXFNonSpringJaxrsServlet, the documentation does not swhow
> > the classes content)
> > 3) I actually need cxf for configuring/doing xsd-File Validation (because
> > the sun implementation cant do it), but what I don't know, is Spring
> > needed for this, or is CXFNonSpringJaxrsServlet enough?
> >
> >
> > Many thanks in advance!
> >
> > ________________________________
> > Ab dem 1. August sind nur noch Mail-Adressen
> > vorname.nachname@hrm-systems.ch in Betrieb. Andere Adressen werden ab dem
> > 1. August 2009 nicht mehr erreichbar sein.
> >
> > Dès le premier août seules les adresses email suivantes seront encore
> > valables: prenom.nom@hrm-systems.ch. Les courriels envoyés aux autres
> > adresses ne seront donc plus acheminés à partir du premier août 2009.
> >
> > Dal primo di agosto saranno validi solo i seguenti indirizzi email:
> > nome.cognome@hrm-systems.ch. La posta elettronica inviata agli altri
> > indirizzi non sarà più inoltrata a partire dal primo di agosto 2009.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Daniel Kulp <dk...@apache.org>.
Sergey,
On Thu June 25 2009 11:33:47 am Sergey Beryozkin wrote:
> I think ssl is not the issue here. I've used CXFNonSpringJaxrsServlet when
> working on TCK and to bypass this issue I had to copy
> org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet (only) to a given web
> app classes folder, I presuming CXF libs are in shared tomcat folder.
>
> May be we can do something similar to what Spring does by somehow making
> the child web app loader visible to the parent one loading CXF classes. For
> now please extract this class from CXF libs...
You really shouldn't need to do that. The Thread.contextClassLoader SHOULD
be the classloader of the application/war. Anything we do that dynamically
loads classes or anything should be using the contextClassLoader. That
should make it so the CXFNonSpringJaxrsServlet doesn't need to be munged in
that way.
Dan
>
> you may want to add jaxrs.providers if you need to add some custom
> providers in addition to those shipped with CXF JAX-RS
>
> > 3) I actually need cxf for configuring/doing xsd-File Validation (because
> > the sun implementation cant do it), but what I don't know, is Spring
> > needed for this, or is CXFNonSpringJaxrsServlet enough?
>
> Unfortunately not, it's not possible yet to do it with
> CXFNonSpringJaxrsServlet. I need to introduce the support for some commonly
> used features, like schema validation/etc.. Will work on it...
>
>
> thanks, Sergey
>
> .LX Max Länzlinger wrote:
> > Hello all,
> >
> > I need a REST-Service preferable with CXFNonSpringJaxrsServlet. Given is
> > Tomcat, ssl, java 6.
> > I defined the servlet in web.xml with init param jaxrs.serviceclasses the
> > name of my service Class.
> > When starting Tomcat, CXFNonSpringJaxrsServlet.loadClass throws an
> > ClassNotFoundException of my service class.
> >
> > Questions:
> > 1) Do I need configure ssl specially, could it be that load.class
> > URLClassLoader$1.run cannot find my class due to ssl of tomcat??....
> > 2) Do I need - additionally to jaxrs.serviceClasses - add the parameter
> > jaxrs.providers? With same name of my service class? (I miss a complete
> > example for CXFNonSpringJaxrsServlet, the documentation does not swhow
> > the classes content)
> > 3) I actually need cxf for configuring/doing xsd-File Validation (because
> > the sun implementation cant do it), but what I don't know, is Spring
> > needed for this, or is CXFNonSpringJaxrsServlet enough?
> >
> >
> > Many thanks in advance!
> >
> > ________________________________
> > Ab dem 1. August sind nur noch Mail-Adressen
> > vorname.nachname@hrm-systems.ch in Betrieb. Andere Adressen werden ab dem
> > 1. August 2009 nicht mehr erreichbar sein.
> >
> > Dès le premier août seules les adresses email suivantes seront encore
> > valables: prenom.nom@hrm-systems.ch. Les courriels envoyés aux autres
> > adresses ne seront donc plus acheminés à partir du premier août 2009.
> >
> > Dal primo di agosto saranno validi solo i seguenti indirizzi email:
> > nome.cognome@hrm-systems.ch. La posta elettronica inviata agli altri
> > indirizzi non sarà più inoltrata a partire dal primo di agosto 2009.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
If you prefer then you may want to register a Servlet filter with the
CXFServlet and it will get a chance to handle the ServletException. This
will work only if no ExceptionMappres have been found for a given exception.
At the moment JAXBExceptions produced by a JAXBElementProvider are wrapped
into WebApplicationExceptions which are caught by a default
WebApplicationException ExceptionMapper.
So for this specific case you need to register your custom
WebApplicationException ExceptionMapper which will check the cause of the
exception and if it a JAXB Exception then it will return a customized JAX-RS
Response object.
Cheers, Sergey
javamustang wrote:
>
> Hi Sergey,
>
> Its working !!!!!!!!!!!!!!!!!!!!!!!!!! :-)
>
> Thanks a lot for all your patient.
>
> Additionally to your last input, i had also to add again
> jaxrs:schemaLocation to make the link from the bean/service to the xsd to
> be used.
>
> Validation Documentation on http://cwiki.apache.org/CXF20DOC/jax-rs.html
> made me little problems but we solved it.
>
> Now i come to a next general question: my service is defined as response
> delivers xml.
> But when validation fales, it delivers f.i.
> HTTP/1.1 500 Internal Server Error
> Server: Apache-Coyote/1.1
> Date: Fri, 03 Jul 2009 14:44:26 GMT
> Content-Type: text/plain
> Content-Length: 175
> Connection: close
>
> JAXBException occurred : cvc-length-valid: Value 'hhhhhhhhhhellj' with
> length = '14' is not facet-valid with respect to length '5' for type
> '#AnonType_testdataserviceRequest'.
>
> It would be great if f.i a listener or filter in my server could catch
> this error and instead deliver xml (with an error code) back to the
> client.
>
>
> Many thanks for all again MAx
>
>
>
>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24334234.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi Sergey,
Its working !!!!!!!!!!!!!!!!!!!!!!!!!! :-)
Thanks a lot for all your patient.
Additionally to your last input, i had also to add again
jaxrs:schemaLocation to make the link from the bean/service to the xsd to be
used.
Validation Documentation on http://cwiki.apache.org/CXF20DOC/jax-rs.html
made me little problems but we solved it.
Now i come to a next general question: my service is defined as response
delivers xml.
But when validation fales, it delivers f.i.
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Date: Fri, 03 Jul 2009 14:44:26 GMT
Content-Type: text/plain
Content-Length: 175
Connection: close
JAXBException occurred : cvc-length-valid: Value 'hhhhhhhhhhellj' with
length = '14' is not facet-valid with respect to length '5' for type
'#AnonType_testdataserviceRequest'.
It would be great if f.i a listener or filter in my server could catch this
error and instead deliver xml (with an error code) back to the client.
Many thanks for all again MAx
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24324617.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
Your schema qualifies a serviceRequest element with a targetNamespace but your bean does expect an unqualified element. I believe
you need to update the XmlRootElement and add a namespace property. Also, you don't need to add an xsiLocation to a request body,
the server is already aware of the schema.
Hope it helps. You might also want to check the JAXB list
cheers, Sergey
----- Original Message -----
From: "javamustang" <ma...@gmx.ch>
To: <us...@cxf.apache.org>
Sent: Friday, July 03, 2009 9:44 AM
Subject: Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
>
> Hi Sergey,
>
> Thank you for all your help. Indeed i stuck with the xml, one root element
> not helps, i made a test application with minimal code which not works and
> sent it to you. Maybe you see where i stuck/probably missing any
> entries/definitions in my xml.
>
> Greetings from Zurich, MAx
> --
> View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24319705.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi Sergey,
Thank you for all your help. Indeed i stuck with the xml, one root element
not helps, i made a test application with minimal code which not works and
sent it to you. Maybe you see where i stuck/probably missing any
entries/definitions in my xml.
Greetings from Zurich, MAx
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24319705.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,
>
> Sergey,
>
> On Tue June 30 2009 10:43:26 am Sergey Beryozkin wrote:
>> Hi,
>>
>> I think the (tomcat) web app loader can not check directly inside WEB-INF,
>> so you need to put a schema resource to WEB-INF/classes and then try
>>
>> classpath:/myrequest.xsd
>>
>> By the way, does anyone know if it is possible to make CXF pick up
>> resources directly in WEB-INF ?
>
> The code for resolving the schemas should be updated to use the CXF
> ResourceManager. (and probably CatalogManager as well if you are not using
> that). The servlet installs a ResourceResolver in the ResourceManager that
> would resolve stuff in WEB-INF.
ResourceManager support is there now. It's very cool - thanks for a hint.
JAXRS endpoints relying on schemas, XSLT templates, users models can now have them picked up from /WEB-INF.
Will do the CatalogManager work a bit later ...
cheers, Sergey
>
> Dan
>
>
>>
>> cheers, Sergey
>>
>> javamustang wrote:
>> > Hi Sergey,
>> >
>> > Following my beans.xml (which i put inside WEB-INF). If this entry is all
>> > to do, would be cool!
>> > (I put my xsd inside WEB-INF)
>> >
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <beans xmlns="http://www.springframework.org/schema/beans"
>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> > xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>> > xsi:schemaLocation="
>> > http://www.springframework.org/schema/beans
>> > http://www.springframework.org/schema/beans/spring-beans.xsd
>> > http://cxf.apache.org/jaxrs
>> > http://cxf.apache.org/schemas/jaxrs.xsd">
>> >
>> > <!-- do not use import statements if CXFServlet init parameters link to
>> > this beans.xml -->
>> >
>> > <import resource="classpath:META-INF/cxf/cxf.xml" />
>> > <import
>> > resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>> > <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>> >
>> > <jaxrs:server id="customerService" address="/service1">
>> >
>> > <jaxrs:schemaLocations>
>> >
>> > <jaxrs:schemaLocation>classpath:WEB-INF/myrequest.xsd</jaxrs:schemaLocati
>> >on> </jaxrs:schemaLocations>
>> > <jaxrs:serviceBeans>
>> > <ref bean="myBean" />
>> > </jaxrs:serviceBeans>
>> > </jaxrs:server>
>> > <bean id="myBean" class="webservice.MyWebservice" />
>> > </beans>
>> >
>> > -----------------------------------------------------
>> > I tried also following version, which seems to find the file (wrong
>> > filename gives a warning during context start).
>> >
>> > <bean id="jaxbProvider"
>> > class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
>> > <property name="schemas">
>> > <list>
>> > <value>C:\dev\xsd\myrequest.xsd</value>
>> > </list>
>> > </property>
>> > </bean>
>> >
>> > -----------------------
>> > Do i need something else additionally, like f.i following?
>> > <jaxrs:properties>
>> > <entry key="schema-validation-enabled" value="true"></entry>
>> > </jaxrs:properties>
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Daniel Kulp <dk...@apache.org>.
Sergey,
On Tue June 30 2009 10:43:26 am Sergey Beryozkin wrote:
> Hi,
>
> I think the (tomcat) web app loader can not check directly inside WEB-INF,
> so you need to put a schema resource to WEB-INF/classes and then try
>
> classpath:/myrequest.xsd
>
> By the way, does anyone know if it is possible to make CXF pick up
> resources directly in WEB-INF ?
The code for resolving the schemas should be updated to use the CXF
ResourceManager. (and probably CatalogManager as well if you are not using
that). The servlet installs a ResourceResolver in the ResourceManager that
would resolve stuff in WEB-INF.
Dan
>
> cheers, Sergey
>
> javamustang wrote:
> > Hi Sergey,
> >
> > Following my beans.xml (which i put inside WEB-INF). If this entry is all
> > to do, would be cool!
> > (I put my xsd inside WEB-INF)
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <beans xmlns="http://www.springframework.org/schema/beans"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> > xsi:schemaLocation="
> > http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans.xsd
> > http://cxf.apache.org/jaxrs
> > http://cxf.apache.org/schemas/jaxrs.xsd">
> >
> > <!-- do not use import statements if CXFServlet init parameters link to
> > this beans.xml -->
> >
> > <import resource="classpath:META-INF/cxf/cxf.xml" />
> > <import
> > resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
> > <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
> >
> > <jaxrs:server id="customerService" address="/service1">
> >
> > <jaxrs:schemaLocations>
> >
> > <jaxrs:schemaLocation>classpath:WEB-INF/myrequest.xsd</jaxrs:schemaLocati
> >on> </jaxrs:schemaLocations>
> > <jaxrs:serviceBeans>
> > <ref bean="myBean" />
> > </jaxrs:serviceBeans>
> > </jaxrs:server>
> > <bean id="myBean" class="webservice.MyWebservice" />
> > </beans>
> >
> > -----------------------------------------------------
> > I tried also following version, which seems to find the file (wrong
> > filename gives a warning during context start).
> >
> > <bean id="jaxbProvider"
> > class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
> > <property name="schemas">
> > <list>
> > <value>C:\dev\xsd\myrequest.xsd</value>
> > </list>
> > </property>
> > </bean>
> >
> > -----------------------
> > Do i need something else additionally, like f.i following?
> > <jaxrs:properties>
> > <entry key="schema-validation-enabled" value="true"></entry>
> > </jaxrs:properties>
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
I reproduced the problem - so at the moment you need to explicitly register
JAXBElementProvider with schema resource locations injected into it, please
see this example on how to do it.
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
Or you can continue using jaxrs:schemaLocations but you still need to
explicitly register a jaxb provider....
thanks, Sergey
javamustang wrote:
>
> Hi Sergey,
>
> I did what you told and unfort. looks like before. I will look in it
> tomorrow again, many thanks- Max
>
>
>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24275727.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,
It's really a schema issue, your schema is apparently missing a global RootElement declaration
Ex :
<ns:RootElement xmlns:ns=http://foo/>
but the schema you provided is missing <xs:element name="RootElement" type="tns:rootElementType"/> (assuming a complex type is
global)
cheers, Sergey
----- Original Message -----
From: "javamustang" <ma...@gmx.ch>
To: <us...@cxf.apache.org>
Sent: Wednesday, July 01, 2009 2:35 PM
Subject: Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
>
> Hi Sergey,
>
> Thanks very much.
>
> With ElementProvider i get much further now, because now i get following
> message:
> JAXBException occurred : cvc-elt.1: Cannot find the declaration of element
> 'RootElement'.
>
> It seems to me the xsd is read in fine (because when its not wel formatted,
> i get message at startup that validation is disabled).
> Could it be my xml - sended from soapUI - needs some header
> declarations/link to the xsd File? (I looked in to your example some input
> xml like addbook2 have xmlns link to the xsd).
> Does the xsd-File need to have only 1 root element so that validation works?
>
> Many thanks for all, MAx
> --
> View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24289898.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi Sergey,
Thanks very much.
With ElementProvider i get much further now, because now i get following
message:
JAXBException occurred : cvc-elt.1: Cannot find the declaration of element
'RootElement'.
It seems to me the xsd is read in fine (because when its not wel formatted,
i get message at startup that validation is disabled).
Could it be my xml - sended from soapUI - needs some header
declarations/link to the xsd File? (I looked in to your example some input
xml like addbook2 have xmlns link to the xsd).
Does the xsd-File need to have only 1 root element so that validation works?
Many thanks for all, MAx
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24289898.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,
I fixed the issue with jaxrs:schemaLocations being ignored on the trunk but for now please
explicitly register org.apache.cxf.jaxrs.JAXBElementProvider provider (you can still use jaxrs:schemaLocations )
cheers, Sergey
----- Original Message -----
From: "javamustang" <ma...@gmx.ch>
To: <us...@cxf.apache.org>
Sent: Tuesday, June 30, 2009 5:06 PM
Subject: Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
>
> Hi Sergey,
>
> I did what you told and unfort. looks like before. I will look in it
> tomorrow again, many thanks- Max
>
>
> --
> View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24274737.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi Sergey,
I did what you told and unfort. looks like before. I will look in it
tomorrow again, many thanks- Max
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24274737.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
Hi,
I think the (tomcat) web app loader can not check directly inside WEB-INF,
so you need to put a schema resource to WEB-INF/classes and then try
classpath:/myrequest.xsd
By the way, does anyone know if it is possible to make CXF pick up resources
directly in WEB-INF ?
cheers, Sergey
javamustang wrote:
>
> Hi Sergey,
>
> Following my beans.xml (which i put inside WEB-INF). If this entry is all
> to do, would be cool!
> (I put my xsd inside WEB-INF)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd">
>
> <!-- do not use import statements if CXFServlet init parameters link to
> this beans.xml -->
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> <jaxrs:server id="customerService" address="/service1">
>
> <jaxrs:schemaLocations>
>
> <jaxrs:schemaLocation>classpath:WEB-INF/myrequest.xsd</jaxrs:schemaLocation>
> </jaxrs:schemaLocations>
> <jaxrs:serviceBeans>
> <ref bean="myBean" />
> </jaxrs:serviceBeans>
> </jaxrs:server>
> <bean id="myBean" class="webservice.MyWebservice" />
> </beans>
>
> -----------------------------------------------------
> I tried also following version, which seems to find the file (wrong
> filename gives a warning during context start).
>
> <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
> <property name="schemas">
> <list>
> <value>C:\dev\xsd\myrequest.xsd</value>
> </list>
> </property>
> </bean>
>
> -----------------------
> Do i need something else additionally, like f.i following?
> <jaxrs:properties>
> <entry key="schema-validation-enabled" value="true"></entry>
> </jaxrs:properties>
>
>
>
>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24273224.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi Sergey,
Following my beans.xml (which i put inside WEB-INF). If this entry is all to
do, would be cool!
(I put my xsd inside WEB-INF)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<!-- do not use import statements if CXFServlet init parameters link to
this beans.xml -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"
/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="customerService" address="/service1">
<jaxrs:schemaLocations>
<jaxrs:schemaLocation>classpath:WEB-INF/myrequest.xsd</jaxrs:schemaLocation>
</jaxrs:schemaLocations>
<jaxrs:serviceBeans>
<ref bean="myBean" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="myBean" class="webservice.MyWebservice" />
</beans>
-----------------------------------------------------
I tried also following version, which seems to find the file (wrong filename
gives a warning during context start).
<bean id="jaxbProvider"
class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
<property name="schemas">
<list>
<value>C:\dev\xsd\myrequest.xsd</value>
</list>
</property>
</bean>
-----------------------
Do i need something else additionally, like f.i following?
<jaxrs:properties>
<entry key="schema-validation-enabled" value="true"></entry>
</jaxrs:properties>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24272954.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
can you post some example please, how do you specify jaxrs:schemaLocations ?
it might be that you may need to add a leading slash, before the name of the
resource :
classpath:/schemas/myschema.xsd
I've fixed it on the trunk and
classpath:schemas/myschema.xsd
will also work now...
cheers, Sergey
javamustang wrote:
>
> Hi all,
>
> Thank you very much indeed for all your help. I'm very happy for your
> precicious answers as i'm beginner. I asked my boss and i may use Spring.
> So I managed to migrate and call my Rest Service to CFX and Spring.
>
> Just the validation resp. the entry jaxrs:schemaLocations seems have no
> effect at all.
>
> My Service consumes xml and produces xml, method ist post. What i expexted
> is, when the service is called and the incoming xml is invalid according
> the xsd, then the code inside my service is not run at all, but what
> happens is my code recieves the complex type (marshalled from xml) even
> when fields are not valid according the xsd. As if the
> jaxrs:schemaLocations has no effect at all.
>
> Is my expection wrong, that when xml is not valid my service code does not
> run and the framework makes some kind of response to the customer? Or do i
> have to code something more that it works and make a kind of response that
> it is invalid myself?..:-)
>
> Many thanks again for your help! MAx
>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24271811.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by javamustang <ma...@gmx.ch>.
Hi all,
Thank you very much indeed for all your help. I'm very happy for your
precicious answers as i'm beginner. I asked my boss and i may use Spring. So
I managed to migrate and call my Rest Service to CFX and Spring.
Just the validation resp. the entry jaxrs:schemaLocations seems have no
effect at all.
My Service consumes xml and produces xml, method ist post. What i expexted
is, when the service is called and the incoming xml is invalid according the
xsd, then the code inside my service is not run at all, but what happens is
my code recieves the complex type (marshalled from xml) even when fields are
not valid according the xsd. As if the jaxrs:schemaLocations has no effect
at all.
Is my expection wrong, that when xml is not valid my service code does not
run and the framework makes some kind of response to the customer? Or do i
have to code something more that it works and make a kind of response that
it is invalid myself?..:-)
Many thanks again for your help! MAx
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24270590.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: xsd Validation and CXFNonSpringJaxrsServlet and ssl
Posted by Sergey Beryozkin <se...@iona.com>.
Hi
I think ssl is not the issue here. I've used CXFNonSpringJaxrsServlet when
working on TCK and to bypass this issue I had to copy
org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet (only) to a given web
app classes folder, I presuming CXF libs are in shared tomcat folder.
May be we can do something similar to what Spring does by somehow making the
child web app loader visible to the parent one loading CXF classes. For now
please extract this class from CXF libs...
you may want to add jaxrs.providers if you need to add some custom providers
in addition to those shipped with CXF JAX-RS
> 3) I actually need cxf for configuring/doing xsd-File Validation (because
> the sun implementation cant do it), but what I don't know, is Spring
> needed for this, or is CXFNonSpringJaxrsServlet enough?
Unfortunately not, it's not possible yet to do it with
CXFNonSpringJaxrsServlet. I need to introduce the support for some commonly
used features, like schema validation/etc.. Will work on it...
thanks, Sergey
.LX Max Länzlinger wrote:
>
>
> Hello all,
>
> I need a REST-Service preferable with CXFNonSpringJaxrsServlet. Given is
> Tomcat, ssl, java 6.
> I defined the servlet in web.xml with init param jaxrs.serviceclasses the
> name of my service Class.
> When starting Tomcat, CXFNonSpringJaxrsServlet.loadClass throws an
> ClassNotFoundException of my service class.
>
> Questions:
> 1) Do I need configure ssl specially, could it be that load.class
> URLClassLoader$1.run cannot find my class due to ssl of tomcat??....
> 2) Do I need - additionally to jaxrs.serviceClasses - add the parameter
> jaxrs.providers? With same name of my service class? (I miss a complete
> example for CXFNonSpringJaxrsServlet, the documentation does not swhow the
> classes content)
> 3) I actually need cxf for configuring/doing xsd-File Validation (because
> the sun implementation cant do it), but what I don't know, is Spring
> needed for this, or is CXFNonSpringJaxrsServlet enough?
>
>
> Many thanks in advance!
>
> ________________________________
> Ab dem 1. August sind nur noch Mail-Adressen
> vorname.nachname@hrm-systems.ch in Betrieb. Andere Adressen werden ab dem
> 1. August 2009 nicht mehr erreichbar sein.
>
> Dès le premier août seules les adresses email suivantes seront encore
> valables: prenom.nom@hrm-systems.ch. Les courriels envoyés aux autres
> adresses ne seront donc plus acheminés à partir du premier août 2009.
>
> Dal primo di agosto saranno validi solo i seguenti indirizzi email:
> nome.cognome@hrm-systems.ch. La posta elettronica inviata agli altri
> indirizzi non sarà più inoltrata a partire dal primo di agosto 2009.
>
>
--
View this message in context: http://www.nabble.com/xsd-Validation-and-CXFNonSpringJaxrsServlet-and-ssl-tp24202869p24205614.html
Sent from the cxf-user mailing list archive at Nabble.com.