Package com.sun.jersey.api.container

Examples of com.sun.jersey.api.container.ContainerException


                try {
                    AbstractResource ar = IntrospectionModeller.createResource(o.getClass());
                    ResourceComponentDestructor rcd = new ResourceComponentDestructor(ar);
                    rcd.destroy(o);
                } catch (IllegalAccessException ex) {
                    throw new ContainerException("Unable to destroy resource", ex);
                } catch (InvocationTargetException ex) {
                    throw new ContainerException("Unable to destroy resource", ex);
                } catch (RuntimeException ex) {
                    throw new ContainerException("Unable to destroy resource", ex);
                }
            }
        }
View Full Code Here


            try {
                Object o = rcc.construct(hc);
                rci.inject(hc, o);
                return o;
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InvocationTargetException ex) {
                // Propagate the target exception so it may be mapped to a response
                throw new MappableContainerException(ex.getTargetException());
            } catch (WebApplicationException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here

                Object o = rcc.construct(hc);
                rci.inject(hc, o);
                Object po = ipcp.proxy(o);
                return po;
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InvocationTargetException ex) {
                // Propagate the target exception so it may be mapped to a response
                throw new MappableContainerException(ex.getTargetException());
            } catch (WebApplicationException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here

                if (!c.equals(EntityManagerFactory.class))
                    return null;
               
                // TODO localize error message
                if (!persistenceUnits.containsKey(pu.unitName()))
                    throw new ContainerException("Persistence unit '"+
                            pu.unitName()+
                            "' is not configured as a servlet parameter in web.xml");
                String jndiName = persistenceUnits.get(pu.unitName());
                ThreadLocalNamedInvoker<EntityManagerFactory> emfHandler =
                        new ThreadLocalNamedInvoker<EntityManagerFactory>(jndiName);
View Full Code Here

        // Commit the status and headers to the HttpServletResponse
        out.flush();

        RequestDispatcher d = servletContext.getRequestDispatcher(resolvedPath);
        if (d == null) {
            throw new ContainerException("No request dispatcher for: " + resolvedPath);
        }
               
        d = new RequestDispatcherWrapper(basePath, d, ui.getMatchedResources().get(0), model);
       
        try {
            d.forward(requestInvoker.get(), responseInvoker.get());
        } catch (Exception e) {
            throw new ContainerException(e);
        }
    }
View Full Code Here

                if (valueOf != null) {
                    try {
                        return CollectionValueOfExtractor.getInstance(
                                parameter, valueOf, parameterName, defaultValue);
                    } catch (Exception e) {
                        throw new ContainerException(ImplMessages.DEFAULT_COULD_NOT_PROCESS_METHOD(defaultValue, valueOf));
                    }
                }

                // Check for constructor with String parameter
                Constructor constructor = ReflectionHelper.getStringConstructor(c);
                if (constructor != null) {
                    try {
                        return CollectionStringConstructorExtractor.getInstance(
                                parameter, constructor, parameterName, defaultValue);
                    } catch (Exception e) {
                        throw new ContainerException(ImplMessages.DEFAULT_COULD_NOT_PROCESS_CONSTRUCTOR(defaultValue, constructor));
                    }
                }
            }
        } else if (parameter == String.class) {
            return new StringExtractor(parameterName, defaultValue);           
        } else if (parameter.isPrimitive()) {
            // Convert primitive to wrapper class
            parameter = PrimitiveMapper.primitiveToClassMap.get(parameter);
            if (parameter == null) {
                // Primitive type not supported
                return null;
            }
           
            // Check for static valueOf(String )
            Method valueOf = ReflectionHelper.getValueOfStringMethod(parameter);
            if (valueOf != null) {
                try {
                    Object defaultDefaultValue = PrimitiveMapper.primitiveToDefaultValueMap.get(parameter);
                    return new PrimitiveValueOfExtractor(valueOf, parameterName,
                            defaultValue, defaultDefaultValue);
                } catch (Exception e) {
                    throw new ContainerException(ImplMessages.DEFAULT_COULD_NOT_PROCESS_METHOD(defaultValue, valueOf));
                }
            }
        } else {
            // Check for static valueOf(String )
            Method valueOf = ReflectionHelper.getValueOfStringMethod(parameter);
            if (valueOf != null) {
                try {
                    return new ValueOfExtractor(valueOf, parameterName, defaultValue);
                } catch (Exception e) {
                    throw new ContainerException(ImplMessages.DEFAULT_COULD_NOT_PROCESS_METHOD(defaultValue, valueOf));
                }
            }

            // Check for constructor with String parameter
            Constructor constructor = ReflectionHelper.getStringConstructor(parameter);
            if (constructor != null) {
                try {
                    return new StringConstructorExtractor(constructor, parameterName, defaultValue);
                } catch (Exception e) {
                    throw new ContainerException(ImplMessages.DEFAULT_COULD_NOT_PROCESS_CONSTRUCTOR(defaultValue, constructor));
                }
            }
        }
               
        return null;
View Full Code Here

        } catch (InvocationTargetException ex) {
            Throwable target = ex.getTargetException();
            if (target instanceof WebApplicationException) {
                throw (WebApplicationException)target;
            } else {
                throw new ContainerException(target);
            }
        } catch (RuntimeException ex) {
            throw new ContainerException(ex);
        } catch (Exception ex) {
            throw new ContainerException(ex);
        }
    }
View Full Code Here

   
     private static Servlet getInstance(Class<? extends Servlet> c){       
         try{                             
             return c.newInstance();
         } catch (Exception e) {
             throw new ContainerException(e);
         }  
     }    
View Full Code Here

                request.getRequestHeaders().remove(HttpHeaders.CONTENT_ENCODING);
                try {
                    request.setEntityInputStream(
                            new GZIPInputStream(request.getEntityInputStream()));
                } catch (IOException ex) {
                    throw new ContainerException(ex);
                }
            }
        }
        return request;
    }
View Full Code Here

            byte[] requestEntity = out.toByteArray();
            printRequestEntity(requestEntity);
            request.setEntityInputStream(new ByteArrayInputStream(requestEntity));
            return request;
        } catch (IOException ex) {
            throw new ContainerException(ex);
        }

    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.container.ContainerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.