Я использую майку, и я развертываю свой API через Tomcat 8.5.35, но всегда возникает ошибка HTTP 500 - PullRequest
0 голосов
/ 20 марта 2019

это мой код. Я использую IntelliJ, и я использую tomcat 8.5.35 для развертывания моего API, и я использую Джерси, чтобы получить эту ошибку «HTTP Status 500 - Servlet.init () для исключения выброса сервлета из jersey-servlet« Я не смог устранить ошибку , У вас есть идея?

это файл Pom.xml моего проекта

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>patientinformationdisplayer</groupId>
    <artifactId>displayer</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <version>2.8</version>
    </dependency>

        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-storage</artifactId>
            <version>5.0.0</version>
        </dependency>


    </dependencies>
</project>

это файл Web.xml моего проекта

<?xml version="1.0" encoding="UTF-8"?>
<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_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>jersey 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>patientinformationdisplayer</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>jersey application</servlet-name>
    <url-pattern>/jersey/*</url-pattern>
    </servlet-mapping>
</web-app>

а это мой класс java

package patientinformationdisplayer;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;
import com.microsoft.azure.storage.blob.CloudBlockBlob;

import javax.ws.rs.*;



@Path("/get")
public class InfoGetter {

    public static final String storageConnectionString = "i just hide it here"
    CloudStorageAccount storageAccount;
    CloudBlobClient blobClient = null;
    CloudBlobContainer container = null;

    @Path("{id_of_patient}")
    @GET
    public void getPatientCase( @PathParam("id_of_patient") String id_of_patient)
    {
        try {
            this.storageAccount = CloudStorageAccount.parse(storageConnectionString);
            this.blobClient = storageAccount.createCloudBlobClient();
            this.container = blobClient.getContainerReference("patientdata");
            this.container.createIfNotExists(BlobContainerPublicAccessType.CONTAINER, new BlobRequestOptions(), new OperationContext());
            CloudBlockBlob blob = this.container.getBlockBlobReference(id_of_patient);
            blob.deleteIfExists();
        } catch (StorageException ex) {
            System.out.println(String.format("Error returned from the service. Http code: %d and error code: %s", ex.getHttpStatusCode(), ex.getErrorCode()));
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

    }






    }

ошибка, которую я получил здесь

HTTP Status 500 – Internal Server Error
Type Exception Report

Message Servlet.init() for servlet [jersey application] threw exception

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet.init() for servlet [jersey application] threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.base/java.lang.Thread.run(Thread.java:844)
Root Cause

java.lang.NoClassDefFoundError: com/microsoft/azure/storage/StorageException
	java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
	java.base/java.lang.Class.getDeclaredMethods(Class.java:2268)
	org.glassfish.jersey.server.model.IntrospectionModeller$2.run(IntrospectionModeller.java:236)
	java.base/java.security.AccessController.doPrivileged(Native Method)
	org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:230)
	org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:170)
	org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:118)
	org.glassfish.jersey.server.model.IntrospectionModeller.access$000(IntrospectionModeller.java:80)
	org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:111)
	org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:108)
	org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
	org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:108)
	org.glassfish.jersey.server.model.Resource.from(Resource.java:744)
	org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:398)
	org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163)
	org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323)
	org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:320)
	org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
	org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.base/java.lang.Thread.run(Thread.java:844)
Root Cause

java.lang.ClassNotFoundException: com.microsoft.azure.storage.StorageException
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1328)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1156)
	java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
	java.base/java.lang.Class.getDeclaredMethods(Class.java:2268)
	org.glassfish.jersey.server.model.IntrospectionModeller$2.run(IntrospectionModeller.java:236)
	java.base/java.security.AccessController.doPrivileged(Native Method)
	org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:230)
	org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:170)
	org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:118)
	org.glassfish.jersey.server.model.IntrospectionModeller.access$000(IntrospectionModeller.java:80)
	org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:111)
	org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:108)
	org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
	org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:108)
	org.glassfish.jersey.server.model.Resource.from(Resource.java:744)
	org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:398)
	org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163)
	org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323)
	org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
	org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
	org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
	org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:320)
	org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
	org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.base/java.lang.Thread.run(Thread.java:844)
Note The full stack trace of the root cause is available in the server logs.

Apache Tomcat/8.5.35
...