Probleme with my Servlet and #FormDataParam Jersey - java

I have a problem with my web-services using Jersey. I have a form composed of two inputs, one of type "file" and one of type "text".
The problem is that when I only use the input of type "file", everything works fine, but when I add the second one, of type "text", my servlet can't even start properly.
Here is the exception I have when I start my servlet :
avr. 28, 2015 5:16:17 PM org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: La servlet /SemRecSysWS a généré une exception "load()"
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public java.lang.String fr.checksem.semrecsys.Gestion.insertSKOS(java.io.InputStream,org.openrdf.rio.RDFFormat) at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[text/plain; charset=utf-8], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class fr.checksem.semrecsys.Gestion, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor#1a533161]}, definitionMethod=public java.lang.String fr.checksem.semrecsys.Gestion.insertSKOS(java.io.InputStream,org.openrdf.rio.RDFFormat), parameters=[Parameter [type=class java.io.InputStream, source=fichier, defaultValue=null], Parameter [type=class org.openrdf.rio.RDFFormat, source=Format, defaultValue=null]], responseType=class java.lang.String}, nameBindings=[]}']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:500)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:167)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:327)
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:324)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:315)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3954)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
at java.lang.Thread.run(Unknown Source)
Here is the function where I try to access to the file and the text
#POST
#Path("/initSKOS")
#Consumes(MediaType.MULTIPART_FORM_DATA)
#Produces(MediaType.TEXT_PLAIN + ";charset=utf-8")
public String insertSKOS(#FormDataParam("fichier") InputStream uploadedInputStream, #FormDataParam("Format") RDFFormat format) {
....
}
I have tried with every type for my variable format, but that doesn't change anything.
And here is my web.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="SemRecSysWS" version="3.0">
<display-name>RecWS</display-name>
<servlet>
<servlet-name>fr.checksem.semrecsys.TestWS</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>fr.checksem.semrecsys</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>fr.checksem.semrecsys.TestWS</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I don't know if you completely understood my problem, I tried to be as clear as possible.
Thanks in advance

You need to register the MultiPartFeature in your web.xml. You can simply add an <init-param> to the Jersey servlet
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
See explanation of problem here
See other configuring options here

Related

Can't change mappedfile to false in Apache Tomcat 8.5

I'm trying to run a Java Webb Application using Apache Tomcat 8.5 through my Netbeans IDE. However, one of the functions in the jsp files has a large file size that exceeds the 65535 byte limit for Tomcat.
To combat this, I tried going into Tomcat's web.xml file and changing the mappedfile param value to false, as seen below.
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>mappedfile</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
However, when I restarted the server and ran the program again, the error persisted. Confused, I checked the web.xml file again, only to find that the mappedfile param had gone back to true. As seen below.
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>mappedfile</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
I tried over and over again, and every time the value keeps reverting back to true when I start up the server again. I couldn't find anybody else talking about this error when I looked it up, so I'm not sure how to fix this. What should I do to make sure it stays false?
EDIT:
This is the error i'm getting when I try to run it in its current state.
An error occurred at line: [237] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 8.5\work\Catalina\localhost\vendor-portal\org\apache\jsp\WEB_002dINF\views\SAA\AddNewSaaForm_jsp.java]
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
Stacktrace:]
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [237] in the generated java file: [C:\Program Files\Apache Software Foundation\Tomcat 8.5\work\Catalina\localhost\vendor-portal\org\apache\jsp\WEB_002dINF\views\SAA\AddNewSaaForm_jsp.java]
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:556)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:380)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:350)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:597)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:383)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:331)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:232)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:194)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:462)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:388)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:316)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1183)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:902)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:232)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:194)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at com.hbc.vp.context.LoginFilter.doFilter(LoginFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:194)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:194)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:624)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1651)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Tomcat Deploy .war file doesn't run

I'm trying to deploy my .war file from Tomcat 8 with Ja, for running it in Postman. However, when I try to deploy and it is not shown in Postman. Below are the given exceptions that causes this issue. What can i do to solve this problem?
org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [C:\Users\berkt\eclipse-workspace\Test\apache-tomcat-8.5.32\webapps\Restful.war]
04-Jul-2018 14:08:31.081 INFO [localhost-startStop-1] org.apache.catalina.startup.ContextConfig.processServletContainerInitializers Unable to process ServletContainerInitializer for [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer]. This is most likely due to a class defined in the #HandlesTypes annotation being missing. Enable DEBUG level logging for the full stack trace.
04-Jul-2018 14:08:31.541 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Restful]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Also, i'm using this xml file:
<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns = "http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id = "WebApp_ID" version = "3.0">
<display-name>User Management</display-name>
<servlet>
<servlet-name>Jersey RESTful Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>TestRestful</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey RESTful Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

Oracle Weblogic: The root element web-app is missing in the descriptor file

I am trying to use JAX-RS to create a web service hosted on an Oracle Weblogic server. I am new to this technology, so I just followed tutorials given by my instructor. Here is my code:
WebContent/WEB-INF/web.xml
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.edu.cs157b.restful </param-name>
<param-value>AssignmentTwo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</servlet>
WebContent/WEB-INF/weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.5/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.2</wls:weblogic-version>
<wls:context-root>AssignmentTwo</wls:context-root>
</wls:weblogic-web-app>
Here is the error I am getting
<Mar 11, 2014 5:32:16 PM PDT> <Error> <HTTP> <BEA-101064> <[WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
Truncated. see log file for complete stacktrace
>
<Mar 11, 2014 5:32:16 PM PDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1394584335621" for task "6". Error is: "weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml."
weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1473)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
Truncated. see log file for complete stacktrace
Caused By: weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
Truncated. see log file for complete stacktrace
>
<Mar 11, 2014 5:32:16 PM PDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating distribute task for application "_auto_generated_ear_".>
<Mar 11, 2014 5:32:16 PM PDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: [HTTP:101064][WebAppModule(_auto_generated_ear_:AssignmentTwo)] Error parsing descriptor in Web appplication "/**/AssignmentTwo/WebContent"
weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
at weblogic.application.descriptor.VersionMunger.init(VersionMunger.java:485)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:86)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:62)
at weblogic.application.descriptor.VersionMunger.<init>(VersionMunger.java:50)
at weblogic.servlet.internal.WebAppReader2.<init>(WebAppReader2.java:47)
at weblogic.servlet.internal.WebAppDescriptor$MyWebAppDescriptor.createXMLStreamReader(WebAppDescriptor.java:275)
at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:406)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:778)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:787)
at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:142)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1446)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:342)
at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:355)
at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:383)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:233)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:749)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1238)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:252)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:172)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
[Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1473)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:244)
at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:681)
at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
Truncated. see log file for complete stacktrace
Caused By: weblogic.application.descriptor.MissingRootElementException: [Munger:2156204]The root element web-app is missing in the descriptor file /**/AssignmentTwo/WebContent/WEB-INF/web.xml.
at weblogic.application.descriptor.BasicMunger2._onStartElement(BasicMunger2.java:506)
at weblogic.application.descriptor.BasicMunger2.next(BasicMunger2.java:441)
at weblogic.application.descriptor.VersionMunger._next(VersionMunger.java:342)
at weblogic.application.descriptor.VersionMunger.next(VersionMunger.java:230)
at weblogic.application.descriptor.VersionMunger.consumeInputStream(VersionMunger.java:595)
Truncated. see log file for complete stacktrace
>
The root element web-app is missing in the descriptor file
Your web.xml is missing the root element <web-app>. The nesting is also incorrect. The <servlet-mapping> element is a top-level element like the <servlet> element, not nested inside it.
Your web.xml should have a structure similar to this:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.edu.cs157b.restful </param-name>
<param-value>AssignmentTwo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</web-app>
If you use an IDE (like Netbeans, Eclipse) when you create a Web-app it will generate a valid web.xml for you. If you create a REST web service it will probably even configure a JAX-RS web.xml for you.

Netbeans 7.4 JAX-RS Servlet Class

I'm trying to develop JAX-RS under NetBeans 7.4 (which came out today) and GlassFish 4 server.
Apparently NetBeans 7.4 should use Jersey 2.0 however looking at libraries inside the project under libraries->GlassFish Server I see only a couple of generic jars:
javax.servlet-api.jar
javax.ws.rs-api.jar
...
So I'm not sure whether Jersey and which version is the server using.
So the first question is: how do I need to use the same JAX-RS implementation at run time as at compile time or not? and hwo do I know what version I'm using under NetBeans 7.4?
Now using com.sun.jersey.spi.container.servlet.ServletContainer as Servlet class inside web.xml returns
SEVERE: WebModule[/TestApplication]Error loading WebappClassLoader (delegate=true; repositories=WEB-INF/classes/) com.sun.jersey.spi.container.servlet.ServletContainer
while using org.glassfish.jersey.spi.container.servlet.ServletContainer
SEVERE: WebModule[/TestApplication]Error loading WebappClassLoader (delegate=true; repositories=WEB-INF/classes/) org.glassfish.jersey.spi.container.servlet.ServletContainer
So the second question is: what is the correct Servlet class?
Adding the libraries Jersey 2.0 downloaded from https://jersey.java.net/download.html under WEB-INF/lib and using the latter Servlet Class yields:
[2013-10-15T18:05:45.136+0200] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=35 _ThreadName=admin-listener(5)] [timeMillis: 1381853145136] [levelValue: 1000] [[
Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [Ref<ContainerRequest>] with qualifiers [#Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject org.glassfish.jersey.server.internal.routing.UriRoutingContext(Ref<ContainerRequest>, ProcessingProviders)]
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Ref<ContainerRequest>] with qualifiers [#Default] at injection point [[BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject org.glassfish.jersey.server.internal.routing.UriRoutingContext(Ref<ContainerRequest>, ProcessingProviders)]
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:403)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:325)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:177)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:208)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:519)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:505)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:480)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:536)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:216)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)
]]
EDIT:
Removing libraries from the lib/ folder inside WEB-INF (as Michal Gajdos suggested) avoids runtime errors. Thus the web.xml now is
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/webresources/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
However the JAX-RS still doesn't want to start and nothing is shown on server log. Is there any other directive I'm missing?
Bump!
The correct HttpServlet class in Jersey 2.x is
org.glassfish.jersey.servlet.ServletContainer
Change your web.xml to use this one and you should be fine.
Note: Your application should not contain libs that are already present on the classpath of GF (it may lead to similar exception as yours).
Jersey 2 has completely changed way of working see jersey deployment documentation CHPT 4.
First of all there's no web.xml configuration anymore, remove everything you added inside it because it's not needed anymore to start the Jersey server.
All you need is to add
#ApplicationPath("webresources")
#Path("/people")
#Stateless
public class PersonResource extends Application
{
...
#GET
#Path("/getpeople")
#Produces(
{
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML
})
...
As you can see the #ApplicationPath defined in javax.ws.rs.ApplicationPath substitutes the previous web xml root path configuration and the Resource class must extend application which is defined inside javax.ws.rs.core.Application.
That's it, actually NetBeans 7.4 doesn't help much regarding this and will compile even with a wrong web.xml without any hint unfortunately.

Jersey setup on app engine

I recently added jersey to my app engine project, everything works great on my local machine but when I try to access the page on the deployed site I get errors. I think I might be including an unsupported class, but I don't think I'm using any. Most of my code is an exact copy from this guide to setting up jQuery upload
Here is my code:
#GET
#Path("/url")
public Response getCallbackUrl() {
/* this is /_ah/upload and it redirects to its given path */
String url = blobstoreService.createUploadUrl("/rest/file");
return Response.ok(new FileUrl(url), MediaType.APPLICATION_JSON).build();
}
web.xml:
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.thedailycaption</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
here is the error I am getting:
Uncaught exception from servlet
java.lang.NullPointerException
at com.sun.jersey.spi.container.ContainerRequest.<init>(ContainerRequest.java:188)
at com.sun.jersey.spi.container.servlet.WebComponent.createRequest(WebComponent.java:450)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:380)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.thedailycaption.Controller.FacebookLogin.doFilter(FacebookLogin.java:165)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
Here are the errors on startup:
java.lang.SecurityException: Unable to get members for class com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider
at com.google.appengine.runtime.Request.process-51d788e4ae40f0dc(Request.java)
at java.lang.Class.getDeclaredMethods(Class.java:253)
at com.sun.jersey.core.reflection.MethodList.getAllDeclaredMethods(MethodList.java:70)
at com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:64)
at com.sun.jersey.core.spi.component.ComponentConstructor.getPostConstructMethods(ComponentConstructor.java:131)
at com.sun.jersey.core.spi.component.ComponentConstructor.<init>(ComponentConstructor.java:123)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:165)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
and
com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider: The provider class, class com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.SecurityException: Unable to get members for class com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider
at com.google.appengine.runtime.Request.process-51d788e4ae40f0dc(Request.java)
at java.lang.Class.getDeclaredMethods(Class.java:253)
at com.sun.jersey.core.reflection.MethodList.getAllDeclaredMethods(MethodList.java:70)
at com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:64)
at com.sun.jersey.core.spi.component.ComponentConstructor.getPostConstructMethods(ComponentConstructor.java:131)
at com.sun.jersey.core.spi.component.ComponentConstructor.<init>(ComponentConstructor.java:123)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:165)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
and
com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider: The provider class, class com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.SecurityException: Unable to get members for class com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider
at com.google.appengine.runtime.Request.process-51d788e4ae40f0dc(Request.java)
at java.lang.Class.getDeclaredMethods(Class.java:253)
at com.sun.jersey.core.reflection.MethodList.getAllDeclaredMethods(MethodList.java:70)
at com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:64)
at com.sun.jersey.core.spi.component.ComponentConstructor.getPostConstructMethods(ComponentConstructor.java:131)
at com.sun.jersey.core.spi.component.ComponentConstructor.<init>(ComponentConstructor.java:123)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:165)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:207)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:163)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1310)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168)
and
com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider: The provider class, class com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.SecurityException: Unable to get members for class com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider
at com.google.appengine.runtime.Request.process-51d788e4ae40f0dc(Request.java)
at java.lang.Class.getDeclaredMethods(Class.java:253)
at com.sun.jersey.core.reflection.MethodList.getAllDeclaredMethods(MethodList.java:70)
at com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:64)
at com.sun.jersey.core.spi.component.ComponentConstructor.getPostConstructMethods(ComponentConstructor.java:131)
at com.sun.jersey.core.spi.component.ComponentConstructor.<init>(ComponentConstructor.java:123)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:165)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
and
Uncaught exception from servlet
java.lang.ExceptionInInitializerError
at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:83)
at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:176)
at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:282)
at com.sun.xml.bind.v2.runtime.property.ArrayProperty.<init>(ArrayProperty.java:69)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.<init>(ArrayERProperty.java:88)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.<init>(ArrayElementProperty.java:100)
at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.<init>(ArrayElementNodeProperty.java:62)
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:33)
You need to add
<init-param>
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
<param-value>true</param-value>
</init-param>
to web.xml
This prevents classes that use reflection, which is not allowed on app engine.

Categories

Resources