java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Cumulocity support for Jersey client 2.x
    via Stack Overflow by user1523029
    ,
  • Full run through for Dave
    via GitHub by aajenkins
    ,
  • Full run through
    via GitHub by aajenkins
    ,
  • Migrating from Spring-Jersey 1.x to 2.x
    via Stack Overflow by Ryan
    ,
  • I am just trying a very very simple rest service with Spring 4 and Jersey (JAX-RS required because of client requirements) and its turning out to be a harrowing experience just to get the ball rolling. The application, as soon as it deploys to Tomcat 8, gives me an error like this. The application should support JAXB marshaling of JSON/XML through content negotiation. 15-Mar-2014 14:56:11.468 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Spring WebApplicationInitializers detected on classpath: [org.glassfish.jersey.server.spring.SpringWebApplicationInitializer@17387686] 15-Mar-2014 14:56:11.543 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 15-Mar-2014 14:56:12.779 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable MultiException stack 1 of 3 java.lang.NullPointerException at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:113) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017) at org.jvnet.hk2.internal.ClazzCreator.methodMe(ClazzCreator.java:375) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:428) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:58) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:54) at jersey.repackaged.com.google.common.collect.Iterators$8.transform(Iterators.java:860) at jersey.repackaged.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at java.util.AbstractCollection.addAll(AbstractCollection.java:333) at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169) at jersey.repackaged.com.google.common.collect.Sets.newLinkedHashSet(Sets.java:292) at org.glassfish.jersey.internal.inject.Providers.getClasses(Providers.java:364) at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:186) at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:304) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1105) at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:292) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:422) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606) at org.glassfish.jersey.server.model.ComponentModelValidator.<init>(ComponentModelValidator.java:97) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:457) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162) at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:322) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) at javax.servlet.GenericServlet.init(GenericServlet.java:158) MultiException stack 2 of 3 java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:449) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:58) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:54) at jersey.repackaged.com.google.common.collect.Iterators$8.transform(Iterators.java:860) at jersey.repackaged.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at java.util.AbstractCollection.addAll(AbstractCollection.java:333) at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169) at jersey.repackaged.com.google.common.collect.Sets.newLinkedHashSet(Sets.java:292) at org.glassfish.jersey.internal.inject.Providers.getClasses(Providers.java:364) at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:186) at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:304) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1105) at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:292) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:422) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606) at org.glassfish.jersey.server.model.ComponentModelValidator.<init>(ComponentModelValidator.java:97) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:457) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162) at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:322) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) at javax.servlet.GenericServlet.init(GenericServlet.java:158) MultiException stack 3 of 3 java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:443) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606) at org.glassfish.jersey.server.model.ComponentModelValidator.<init>(ComponentModelValidator.java:97) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:457) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162) at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:322) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1236) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4910) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5192) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697) at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1646) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463) at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [2014-03-15 02:56:12,800] Artifact myapp (exploded): Artifact is deployed successfully at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:791) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1486) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:96) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1327) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1419) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:847) [2014-03-15 02:56:12,801] Artifact myapp (exploded): Deploy took 5,904 milliseconds at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322) at sun.rmi.transport.Transport$1.run(Transport.java:177) 15-Mar-2014 14:56:12.782 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet /myapp threw load() exception java.lang.NullPointerException at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:113) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017) at org.jvnet.hk2.internal.ClazzCreator.methodMe(ClazzCreator.java:375) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:428) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98) at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:58) at org.glassfish.jersey.internal.inject.ProviderToService.apply(ProviderToService.java:54) at jersey.repackaged.com.google.common.collect.Iterators$8.transform(Iterators.java:860) at jersey.repackaged.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at java.util.AbstractCollection.addAll(AbstractCollection.java:333) at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169) at jersey.repackaged.com.google.common.collect.Sets.newLinkedHashSet(Sets.java:292) at org.glassfish.jersey.internal.inject.Providers.getClasses(Providers.java:364) at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:186) at org.glassfish.jersey.message.internal.MessageBodyFactory.<init>(MessageBodyFactory.java:304) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1105) at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:292) at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:422) at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:114) at org.jvnet.hk2.internal.SingletonContext$1.compute(SingletonContext.java:102) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture$1.call(Cache.java:97) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at org.glassfish.hk2.utilities.cache.Cache$OriginThreadAwareFuture.run(Cache.java:154) at org.glassfish.hk2.utilities.cache.Cache.compute(Cache.java:199) at org.jvnet.hk2.internal.SingletonContext.findOrCreate(SingletonContext.java:153) at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2445) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:621) at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606) at org.glassfish.jersey.server.model.ComponentModelValidator.<init>(ComponentModelValidator.java:97) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:457) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162) at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:322) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289) at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:168) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) at javax.servlet.GenericServlet.init(GenericServlet.java:158) build.gradle file ============ apply plugin: 'java' apply plugin: 'war' sourceCompatibility = 1.5 version = '1.0' repositories { mavenCentral() } dependencies { compile group: 'org.springframework', name: 'spring-context', version: '4.0.2.RELEASE' compile group: 'org.springframework', name: 'spring-webmvc', version: '4.0.2.RELEASE' compile group: 'org.springframework', name: 'spring-web', version: '4.0.2.RELEASE' compile(group: 'org.springframework', name: 'spring-core', version: '4.0.2.RELEASE') { exclude group: 'commons-logging' } compile group: 'org.springframework', name: 'spring-orm', version: '4.0.2.RELEASE' compile 'org.slf4j:slf4j-api:1.7.6' compile 'org.slf4j:jcl-over-slf4j:1.7.6' compile 'org.slf4j:slf4j-log4j12:1.7.6' compile 'log4j:log4j:1.2.17' compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.6' compile 'org.glassfish.jersey.media:jersey-media-json-jackson' compile 'org.glassfish.jersey.ext:jersey-spring3:2.6' compile 'com.sun.jersey:jersey-core:1.18.1' compile('com.sun.jersey:jersey-json:1.18.1') exclude { group: "com.sun.xml.bind" } compile 'org.glassfish.jersey.core:jersey-server:2.6' compile 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.3.0' compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final' compile group: 'org.hibernate', name: 'hibernate-core', version: '4.3.4.Final' compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.4.Final' compile 'javax.validation:validation-api:1.1.0.Final' compile 'javax.inject:javax.inject:1' testCompile group: 'junit', name: 'junit', version: '4.11' } applicationContext.xml ================== <?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Scans within the base package of the application for @Components to configure as beans --> <context:component-scan base-package="com.test.myapp" /> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/> <!-- Services --> </beans> web.xml <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:/conf/spring/applicationContext.xml</param-value> </context-param> <servlet> <servlet-name>SpringApplication</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.test.myapp.application.MyApp</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringApplication</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> Finally, Jersey needs this MyApp class to bootstrap package com.test.myapp.application; import com.test.myapp.controllers.v1.FirstController; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.spring.scope.RequestContextFilter; public class MyApp extends ResourceConfig { public MyApp(){ register(RequestContextFilter.class); register(FirstController.class); } } FirstController.java package com.test.myapp.controllers.v1; import com.test.myapp.jaxb.v1.ErrorDetail; import com.test.myapp.jaxb.v1.ErrorResponse; import com.test.myapp.jaxb.v1.ObjectFactory; import com.test.myapp.jaxb.v1.RestResponse; import org.apache.log4j.Logger; import javax.annotation.PostConstruct; import javax.inject.Named; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Arrays; import java.util.Date; import java.util.List; @Named @Path("/v1/riskInfo") public class FirstController { private static Logger logger = Logger.getLogger(RiskInfoController.class); @PostConstruct public void initialize() { System.out.println("INITIALIZED*******"); } @Path("/first-action") @POST @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Consumes("application/x-www-form-urlencoded") public Response firstActionInfo(@Context HttpServletRequest req){ ErrorResponse errorResponse = objFactory.createErrorResponse(); errorResponse.setProcessedTime(new Date()); errorResponse.setIsRetry(false); ErrorDetail detail = objFactory.createErrorDetail(); detail.setMessage("SOMETHING WENT WRONG"); detail.setCode("NOT_OK"); List<ErrorDetail> problemList = Arrays.asList(detail); errorResponse.setProblem(problemList); RestResponse restResponse = objFactory.createRestResponse(); restResponse.setSystemResponse(objFactory.createError(errorResponse)); return Response.ok(restResponse).build(); } }
    via by satb,
  • Dropwizard 1.0.0 app fails to start after migration
    via by Jacek Furmankiewicz,
  • DW newbie gets NPE when running first project.
    via by Geoffry Roberts,
    • java.lang.NullPointerException at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:107) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,