You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sergey Beryozkin <se...@progress.com> on 2008/12/02 18:40:04 UTC

Re: Support for Regular Expressions in @Path Annotation using CXF JAX-RS

Hi Bruce

Can you give me a favour and clarify on one of the path expressions.



<snip/>
@Path("{base:base.+suffix}/{tail}")
<mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)> 

can you give me a favor and resend this @Path value, possibly in quotes, 
should it read :
"@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)" ?

or can be be that a mail reader has encoded the @Path("{base:base.+suffix}/{tail}") ?

Thanks, Sergey



----- Original Message ----- 
From: "Maxfield, Bruce D. (LNG-DAY)" <Br...@LexisNexis.com>
To: <us...@cxf.apache.org>
Sent: Tuesday, November 25, 2008 3:39 PM
Subject: Support for Regular Expressions in @Path Annotation using CXF JAX-RS


It appears that the regular expression matching within CXF JAX-RS is not
working properly.  I've used a recent (probably 11/20) 2.2 Trunk Release
of CXF to perform these tests along side Jersey 1.0. Below is the test
case code followed by a series of side-by-side test cases using CXF and
Jersey:

 

-------------------------------------------------

--------- RESOURCE CODE  ------------

-------------------------------------------------

 

 

package com.example.simpleJaxRsResources;

 

 

import javax.ws.rs.GET;

import javax.ws.rs.Produces;

import javax.ws.rs.Path;

import javax.ws.rs.MatrixParam;

import javax.ws.rs.PathParam;

import javax.ws.rs.core.Context;

import javax.ws.rs.core.UriInfo;

 

//@Path("{base:base.+}/{tail}")  - Failed to parse

//@Path("base/{tail}")

//@Path("{base}/{tail}")

//@Path("{base}/{tail}")

//@Path("{base:base.+}/{tail}")

//@Path("{base:.+base}/{tail}")

@Path("{base:base.+suffix}/{tail}")
<mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)> 

@Produces("text/plain")

public class FirstResource {

            

            @GET

            public String getFirstResource(@PathParam("base") String
base, 

                                    @PathParam("tail") String tail,

                                    @MatrixParam("matrixParam") String
matrixParm,

                                    @Context UriInfo info) {

                        

                        return "Full Request URI: " +
info.getRequestUri() + "\n" +

                        "base: " + base + "\n" +

                        "tail: " + tail + "\n" +                   

                        "matrixParm=" + matrixParm;

            }

 

}

----------------------------------------------

------ TEST CASE RESULTS --------

----------------------------------------------

 

 

- USE OF REGEX IN @Path TEST RESULTS -

Using Ecplise 3.2, Apache Tomcat 5.5, Jersey 1.0 and CXF latest build.

 

=======================================

Test #1 - @Path("{base:base.+}/{tail}")

=======================================

 

---- JERSEY ----

Full Request URI: http://localhost:8088/Jersey_10/base_suffix/tail

base: base_suffix

tail: tail

matrixParm=null

 

---- CXF ----

Triggered an exception during Tomcat application start-up with the
following text in the Eclipse console:

 

Error creating bean with name 'RestCXF_01': Error setting property
values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:

PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property
'serviceBeans' threw exception; nested exception is
java.util.regex.PatternSyntaxException: Illegal repetition near index 0

/{base:base.+}/([^/]+?)(/.*)?

 

 

=======================================

Test #2 - @Path("{base:.+base}/{tail}")

=======================================

 

---- JERSEY ----

Full Request URI: http://localhost:8089/Jersey_10/prefixbase/tail

base: prefixbase

tail: tail

matrixParm=null

 

 

---- CXF ----

Triggered an exception during Tomcat application start-up with the
following text in the Eclipse console:

 

Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:

PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property
'serviceBeans' threw exception; nested exception is
java.util.regex.PatternSyntaxException: Illegal repetition near index 0

/{base:.+base}/([^/]+?)(/.*)?

 

 

=============================================

Test #2 - @Path("{base:base.+suffix}/{tail}")

=============================================

 

---- JERSEY ----

Full Request URI: http://localhost:8089/Jersey_10/base_core_suffix/tail

base: base_core_suffix

tail: tail

matrixParm=null

 

---- CXF ----

Triggered an exception during Tomcat application start-up with the
following text in the Eclipse console:

 

Error creating bean with name 'RestCXF_01': Error setting property
values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:

PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property
'serviceBeans' threw exception; nested exception is
java.util.regex.PatternSyntaxException: Illegal repetition near index 0

/{base:base.+suffix}/([^/]+?)(/.*)?

 

 




RE: Support for Regular Expressions in @Path Annotation using CXF JAX-RS

Posted by "Maxfield, Bruce D. (LNG-DAY)" <Br...@lexisnexis.com>.
:)

-----Original Message-----
From: Sergey Beryozkin [mailto:sergey.beryozkin@progress.com] 
Sent: Wednesday, December 03, 2008 1:19 PM
To: users@cxf.apache.org
Subject: Re: Support for Regular Expressions in @Path Annotation using
CXF JAX-RS

Custom regular expressions are supported on the trunk now and I'll merge
it into 2.1.x too. They would've been supported anyway but 
thanks to this original email and some great help from Marc Hadley of
Sun we have it now.
I think the only thing which is not supported now is the ability to
provide a custom regular expression with range quantifiers :

@Path("{bar:\\d\\{3\\}}")

as I could not figure out how to capture it with my brains starting to
melt - need to review my copy of Mastering Regular 
Exprerssions - that should be fun. In meantime you can do
@Path("{bar:\\d\\d\\d}") and I'll fix this specific issue asap

Cheers, Sergey


----- Original Message ----- 
From: "Sergey Beryozkin" <se...@progress.com>
To: <us...@cxf.apache.org>
Sent: Tuesday, December 02, 2008 5:40 PM
Subject: Re: Support for Regular Expressions in @Path Annotation using
CXF JAX-RS


> Hi Bruce
>
> Can you give me a favour and clarify on one of the path expressions.
>
>
>
> <snip/>
> @Path("{base:base.+suffix}/{tail}")
> <mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)>
> can you give me a favor and resend this @Path value, possibly in
quotes, should it read :
> "@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)" ?
>
> or can be be that a mail reader has encoded the
@Path("{base:base.+suffix}/{tail}") ?
>
> Thanks, Sergey
>
>
>
> ----- Original Message ----- 
> From: "Maxfield, Bruce D. (LNG-DAY)" <Br...@LexisNexis.com>
> To: <us...@cxf.apache.org>
> Sent: Tuesday, November 25, 2008 3:39 PM
> Subject: Support for Regular Expressions in @Path Annotation using CXF
JAX-RS
>
>
> It appears that the regular expression matching within CXF JAX-RS is
not
> working properly.  I've used a recent (probably 11/20) 2.2 Trunk
Release
> of CXF to perform these tests along side Jersey 1.0. Below is the test
> case code followed by a series of side-by-side test cases using CXF
and
> Jersey:
>
>
>
> -------------------------------------------------
>
> --------- RESOURCE CODE  ------------
>
> -------------------------------------------------
>
>
>
>
>
> package com.example.simpleJaxRsResources;
>
>
>
>
>
> import javax.ws.rs.GET;
>
> import javax.ws.rs.Produces;
>
> import javax.ws.rs.Path;
>
> import javax.ws.rs.MatrixParam;
>
> import javax.ws.rs.PathParam;
>
> import javax.ws.rs.core.Context;
>
> import javax.ws.rs.core.UriInfo;
>
>
>
> //@Path("{base:base.+}/{tail}")  - Failed to parse
>
> //@Path("base/{tail}")
>
> //@Path("{base}/{tail}")
>
> //@Path("{base}/{tail}")
>
> //@Path("{base:base.+}/{tail}")
>
> //@Path("{base:.+base}/{tail}")
>
> @Path("{base:base.+suffix}/{tail}")
> <mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)>
> @Produces("text/plain")
>
> public class FirstResource {
>
>
>            @GET
>
>            public String getFirstResource(@PathParam("base") String
> base,
>                                    @PathParam("tail") String tail,
>
>                                    @MatrixParam("matrixParam") String
> matrixParm,
>
>                                    @Context UriInfo info) {
>
>
>                        return "Full Request URI: " +
> info.getRequestUri() + "\n" +
>
>                        "base: " + base + "\n" +
>
>                        "tail: " + tail + "\n" +
>                        "matrixParm=" + matrixParm;
>
>            }
>
>
>
> }
>
> ----------------------------------------------
>
> ------ TEST CASE RESULTS --------
>
> ----------------------------------------------
>
>
>
>
>
> - USE OF REGEX IN @Path TEST RESULTS -
>
> Using Ecplise 3.2, Apache Tomcat 5.5, Jersey 1.0 and CXF latest build.
>
>
>
> =======================================
>
> Test #1 - @Path("{base:base.+}/{tail}")
>
> =======================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI: http://localhost:8088/Jersey_10/base_suffix/tail
>
> base: base_suffix
>
> tail: tail
>
> matrixParm=null
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error creating bean with name 'RestCXF_01': Error setting property
> values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index
0
>
> /{base:base.+}/([^/]+?)(/.*)?
>
>
>
>
>
> =======================================
>
> Test #2 - @Path("{base:.+base}/{tail}")
>
> =======================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI: http://localhost:8089/Jersey_10/prefixbase/tail
>
> base: prefixbase
>
> tail: tail
>
> matrixParm=null
>
>
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error setting property values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index
0
>
> /{base:.+base}/([^/]+?)(/.*)?
>
>
>
>
>
> =============================================
>
> Test #2 - @Path("{base:base.+suffix}/{tail}")
>
> =============================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI:
http://localhost:8089/Jersey_10/base_core_suffix/tail
>
> base: base_core_suffix
>
> tail: tail
>
> matrixParm=null
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error creating bean with name 'RestCXF_01': Error setting property
> values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index
0
>
> /{base:base.+suffix}/([^/]+?)(/.*)?
>
>
>
>
>
>
>
> 



Re: Support for Regular Expressions in @Path Annotation using CXF JAX-RS

Posted by Sergey Beryozkin <se...@progress.com>.
Custom regular expressions are supported on the trunk now and I'll merge it into 2.1.x too. They would've been supported anyway but 
thanks to this original email and some great help from Marc Hadley of Sun we have it now.
I think the only thing which is not supported now is the ability to provide a custom regular expression with range quantifiers :

@Path("{bar:\\d\\{3\\}}")

as I could not figure out how to capture it with my brains starting to melt - need to review my copy of Mastering Regular 
Exprerssions - that should be fun. In meantime you can do @Path("{bar:\\d\\d\\d}") and I'll fix this specific issue asap

Cheers, Sergey


----- Original Message ----- 
From: "Sergey Beryozkin" <se...@progress.com>
To: <us...@cxf.apache.org>
Sent: Tuesday, December 02, 2008 5:40 PM
Subject: Re: Support for Regular Expressions in @Path Annotation using CXF JAX-RS


> Hi Bruce
>
> Can you give me a favour and clarify on one of the path expressions.
>
>
>
> <snip/>
> @Path("{base:base.+suffix}/{tail}")
> <mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)>
> can you give me a favor and resend this @Path value, possibly in quotes, should it read :
> "@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)" ?
>
> or can be be that a mail reader has encoded the @Path("{base:base.+suffix}/{tail}") ?
>
> Thanks, Sergey
>
>
>
> ----- Original Message ----- 
> From: "Maxfield, Bruce D. (LNG-DAY)" <Br...@LexisNexis.com>
> To: <us...@cxf.apache.org>
> Sent: Tuesday, November 25, 2008 3:39 PM
> Subject: Support for Regular Expressions in @Path Annotation using CXF JAX-RS
>
>
> It appears that the regular expression matching within CXF JAX-RS is not
> working properly.  I've used a recent (probably 11/20) 2.2 Trunk Release
> of CXF to perform these tests along side Jersey 1.0. Below is the test
> case code followed by a series of side-by-side test cases using CXF and
> Jersey:
>
>
>
> -------------------------------------------------
>
> --------- RESOURCE CODE  ------------
>
> -------------------------------------------------
>
>
>
>
>
> package com.example.simpleJaxRsResources;
>
>
>
>
>
> import javax.ws.rs.GET;
>
> import javax.ws.rs.Produces;
>
> import javax.ws.rs.Path;
>
> import javax.ws.rs.MatrixParam;
>
> import javax.ws.rs.PathParam;
>
> import javax.ws.rs.core.Context;
>
> import javax.ws.rs.core.UriInfo;
>
>
>
> //@Path("{base:base.+}/{tail}")  - Failed to parse
>
> //@Path("base/{tail}")
>
> //@Path("{base}/{tail}")
>
> //@Path("{base}/{tail}")
>
> //@Path("{base:base.+}/{tail}")
>
> //@Path("{base:.+base}/{tail}")
>
> @Path("{base:base.+suffix}/{tail}")
> <mailto://@Path(%22%7bbase:base.+suffix%7d/%7btail%7d%22)>
> @Produces("text/plain")
>
> public class FirstResource {
>
>
>            @GET
>
>            public String getFirstResource(@PathParam("base") String
> base,
>                                    @PathParam("tail") String tail,
>
>                                    @MatrixParam("matrixParam") String
> matrixParm,
>
>                                    @Context UriInfo info) {
>
>
>                        return "Full Request URI: " +
> info.getRequestUri() + "\n" +
>
>                        "base: " + base + "\n" +
>
>                        "tail: " + tail + "\n" +
>                        "matrixParm=" + matrixParm;
>
>            }
>
>
>
> }
>
> ----------------------------------------------
>
> ------ TEST CASE RESULTS --------
>
> ----------------------------------------------
>
>
>
>
>
> - USE OF REGEX IN @Path TEST RESULTS -
>
> Using Ecplise 3.2, Apache Tomcat 5.5, Jersey 1.0 and CXF latest build.
>
>
>
> =======================================
>
> Test #1 - @Path("{base:base.+}/{tail}")
>
> =======================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI: http://localhost:8088/Jersey_10/base_suffix/tail
>
> base: base_suffix
>
> tail: tail
>
> matrixParm=null
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error creating bean with name 'RestCXF_01': Error setting property
> values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index 0
>
> /{base:base.+}/([^/]+?)(/.*)?
>
>
>
>
>
> =======================================
>
> Test #2 - @Path("{base:.+base}/{tail}")
>
> =======================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI: http://localhost:8089/Jersey_10/prefixbase/tail
>
> base: prefixbase
>
> tail: tail
>
> matrixParm=null
>
>
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error setting property values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index 0
>
> /{base:.+base}/([^/]+?)(/.*)?
>
>
>
>
>
> =============================================
>
> Test #2 - @Path("{base:base.+suffix}/{tail}")
>
> =============================================
>
>
>
> ---- JERSEY ----
>
> Full Request URI: http://localhost:8089/Jersey_10/base_core_suffix/tail
>
> base: base_core_suffix
>
> tail: tail
>
> matrixParm=null
>
>
>
> ---- CXF ----
>
> Triggered an exception during Tomcat application start-up with the
> following text in the Eclipse console:
>
>
>
> Error creating bean with name 'RestCXF_01': Error setting property
> values; nested exception is
> org.springframework.beans.PropertyBatchUpdateException; nested
> PropertyAccessExceptions (1) are:
>
> PropertyAccessException 1:
> org.springframework.beans.MethodInvocationException: Property
> 'serviceBeans' threw exception; nested exception is
> java.util.regex.PatternSyntaxException: Illegal repetition near index 0
>
> /{base:base.+suffix}/([^/]+?)(/.*)?
>
>
>
>
>
>
>
>