Hello Paul,
I'm using a Tomcat 6.0.18 on Linux. I've isolated a small test case:
@Path("/")
public class Test{
// Some mock locale data to work on
private static List<Locale> locales = new ArrayList<Locale>();
static{
locales.add( new Locale("en"));
locales.add( new Locale("da"));
}
@GET
@Produces("text/html")
public Response get() {
assert(locales != null);
assert(locales.size() > 0);
// This is where exceptions are swallowed
Variant.languages(
(Locale[])locales.toArray())
.build();
// If we made it here, all is fine
return Response.status(Response.Status.OK).build();
}
Using the generic version of toArray(T[]) does not lead to problems.
/Casper
On Thu, Apr 2, 2009 at 9:38 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Hi,
> I just tried this with 1.0.3-SNAPSHOT and GF logs the following:
>
> EVERE: StandardWrapperValve[Jersey Web Application]: PWC1406:
> Servlet.service() for servlet Jersey Web Application threw exception
> java.lang.ClassCastException: [Ljava.lang.Object;
> at
> com.sun.jersey.samples.helloworld.resources.HelloWorldResource.getClichedMessage(HelloWorldResource.java:45)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
>
>
> What Web container are you using?
>
> Paul.
>
> On Apr 2, 2009, at 9:25 AM, Paul Sandoz wrote:
>
>
> On Apr 1, 2009, at 8:53 PM, Casper Bang wrote:
>
> It's the unchecked cast that causes it, I just didn't expect Jersey to
> swallow the exception
>
>
> Agreed, i have to fix this and log the exception. All unreported runtime
> exceptions will be passed through to the servlet.
>
> Paul.
>
> . While I love varargs, an overloaded Variant.languages(Collection) would
> really be handy. ;)
>
> /Casper
>
>
> javax.servlet.ServletException: non-HTTP request or response
>>>
>>>
>>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:241)
>>> So I agree with Felipe, a snipped would be handy. :)
>>>
>>> Bizarre error though, I agree.
>>
>> Marc.
>>
>>
>>
>>> 2009/4/1 Felipe Gaścho <fgaucho_at_gmail.com>
>>> do you have a code snippet ?
>>>
>>> On Wed, Apr 1, 2009 at 8:02 PM, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
>>> > On Apr 1, 2009, at 12:07 PM, Felipe Gaścho wrote:
>>> >
>>> >> @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
>>> >>
>>> >> I know the return type depends of some parameter in the request .. but
>>> >> which one ? how to choose between JSON and XML in runtime ?
>>> >>
>>> >> may I choose this through a browser url ? or I need to create a http
>>> >> request in other way ?
>>> >>
>>> > You can use Request.selectVariant at runtime to have the JAX-RS impl
>>> select
>>> > the best matching representation from a set of available ones.
>>> >
>>> >
>>> https://jsr311.dev.java.net/nonav/releases/1.0/javax/ws/rs/core/Request.html
>>> #selectVariant(java.util.List)
>>> >
>>> > Marc.
>>> >
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>>
>>> Please help to test this application:
>>> http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
>
>