0

私は StackOverflow ネットワーク全体を検索しましたが、さまざまな解決策に関する多くの質問を見ましたが、何の助けにもなりません...質問を重複としてマークしないでください。

こんにちは、Java初心者です。ジャージーレストWebサービスを使用して単純なWebサービスを作成するのに何日も費やしています。そこで、プロジェクトに HelloUblu というクラスを作成しました。このコードを別のプロジェクトで試してみましたが、うまくいきましたが、このプロジェクトではそれらの問題があります。主な問題は「プロバイダー クラスが見つかりません。»

ご助力ありがとうございます

私はEclipse Photon、Windows 7、Maven 4、Jersey Tomcat 9、JAVASE-1.8(jre1.8.0_181)に取り組んでいます

私の進路

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>com.ublu.msm</groupId>
    <artifactId>msm_backend</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>msm_server Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20170516</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.2.Final</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.1.0</version>
            <type>maven-plugin</type>
        </dependency>
    </dependencies>
    <build>
        <finalName>msm_backend</finalName>
    </build>
</project>

Web.XML

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">
    <display-name>Msm_Backend</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Jersey Web Application</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.ublu.msm.msm_backend</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

私のクラス: HelloUblu.java

    package com.ublu.msm.msm_backend.soa.server;

import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import com.sun.jersey.api.client.ClientResponse.Status;

@Path("helloublu")
public class HelloUblu {
    public HelloUblu() {
    }

    @GET
    @Produces("application/xml")
    public String getXml() {
        return "<bonjour>Bonjour UBLU</bonjour>";
    }

    @GET
    @Path("{id}")
    @Produces("application/xml")
    public Response getXmlWithParams(@PathParam("id") String id,
            @DefaultValue("all") @HeaderParam("name") String name) {
        System.out.println(id);
        System.out.println(name);
        return Response.status(Status.OK).entity("<bonjour>Bonjour UBLU de la part de " + name + "</bonjour>").build();
    }

}

ログ (情報: プロバイダー クラスが見つかりません。)

    oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server version:        Apache Tomcat/9.0.12
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server built:          Sep 4 2018 22:13:41 UTC
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server number:         9.0.12.0
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Name:               Windows 7
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Version:            6.1
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Architecture:          amd64
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Java Home:             C:\Program Files\Java\jdk1.8.0_181\jre
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Version:           1.8.0_181-b13
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Vendor:            Oracle Corporation
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_BASE:         C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 9.0
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.base=C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dwtp.deploy=C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 9.0\endorsed
oct. 12, 2018 10:38:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dfile.encoding=Cp1252
oct. 12, 2018 10:38:19 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFOS: Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
oct. 12, 2018 10:38:19 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFOS: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
oct. 12, 2018 10:38:19 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFOS: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
oct. 12, 2018 10:38:20 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFOS: OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
oct. 12, 2018 10:38:26 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["http-nio-8080"]
oct. 12, 2018 10:38:27 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
oct. 12, 2018 10:38:27 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["ajp-nio-8009"]
oct. 12, 2018 10:38:27 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
oct. 12, 2018 10:38:27 PM org.apache.catalina.startup.Catalina load
INFOS: Initialization processed in 12883 ms
oct. 12, 2018 10:38:28 PM org.apache.catalina.core.StandardService startInternal
INFOS: Démarrage du service [Catalina]
oct. 12, 2018 10:38:28 PM org.apache.catalina.core.StandardEngine startInternal
INFOS: Starting Servlet Engine: Apache Tomcat/9.0.12
oct. 12, 2018 10:38:38 PM org.apache.jasper.servlet.TldScanner scanJars
INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
oct. 12, 2018 10:38:38 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFOS: Déploiement du descripteur de configuration [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\CrunchifyRESTJerseyExample.xml]
oct. 12, 2018 10:38:38 PM org.apache.catalina.startup.HostConfig deployDescriptor
AVERTISSEMENT: The path attribute with value [/CrunchifyRESTJerseyExample] in deployment descriptor [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\CrunchifyRESTJerseyExample.xml] has been ignored
oct. 12, 2018 10:38:38 PM org.apache.catalina.startup.SetContextPropertiesRule begin
AVERTISSEMENT: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CrunchifyRESTJerseyExample' did not find a matching property.
oct. 12, 2018 10:38:43 PM org.apache.jasper.servlet.TldScanner scanJars
INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
oct. 12, 2018 10:38:44 PM com.sun.jersey.api.core.servlet.WebAppResourceConfig init
INFOS: Scanning for root resource and provider classes in the Web app resource paths:
  /WEB-INF/lib
  /WEB-INF/classes
oct. 12, 2018 10:38:44 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFOS: Root resource classes found:
  class com.crunchify.restjersey.HelloUblu
  class com.crunchify.restjersey.CtoFService
  class com.crunchify.restjersey.FtoCService
oct. 12, 2018 10:38:44 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFOS: No provider classes found.
oct. 12, 2018 10:38:44 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFOS: Initiating Jersey application, version 'Jersey: 1.19.4 05/24/2017 03:46 PM'
oct. 12, 2018 10:38:45 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFOS: Deployment of deployment descriptor [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\CrunchifyRESTJerseyExample.xml] has finished in [6 750] ms
oct. 12, 2018 10:38:45 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFOS: Déploiement du descripteur de configuration [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\msm_backend.xml]
oct. 12, 2018 10:38:45 PM org.apache.catalina.startup.HostConfig deployDescriptor
AVERTISSEMENT: The path attribute with value [/msm_backend] in deployment descriptor [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\msm_backend.xml] has been ignored
oct. 12, 2018 10:38:45 PM org.apache.catalina.startup.SetContextPropertiesRule begin
AVERTISSEMENT: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:msm_backend' did not find a matching property.
oct. 12, 2018 10:38:52 PM org.apache.jasper.servlet.TldScanner scanJars
INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
oct. 12, 2018 10:38:52 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFOS: Deployment of deployment descriptor [C:\Users\Wilfried\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\msm_backend.xml] has finished in [7 116] ms
oct. 12, 2018 10:38:52 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["http-nio-8080"]
oct. 12, 2018 10:38:52 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["ajp-nio-8009"]
oct. 12, 2018 10:38:52 PM org.apache.catalina.startup.Catalina start
INFOS: Server startup in 25008 ms

MAVEN ビルド クリーン インストール

    [INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< msm_backend:msm_backend >-----------------------
[INFO] Building msm_backend 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ msm_backend ---
[INFO] Deleting C:\Users\Wilfried\workspace2\msm_backend\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ msm_backend ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ msm_backend ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 61 source files to C:\Users\Wilfried\workspace2\msm_backend\target\classes
[INFO] /C:/Users/Wilfried/workspace2/msm_backend/msm_backend/src/main/java/com/ublu/msm/msm_backend/StructureManager.java: Some input files use unchecked or unsafe operations.
[INFO] /C:/Users/Wilfried/workspace2/msm_backend/msm_backend/src/main/java/com/ublu/msm/msm_backend/StructureManager.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ msm_backend ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ msm_backend ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ msm_backend ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-war-plugin:3.2.1:war (default-war) @ msm_backend ---
[INFO] Packaging webapp
[INFO] Assembling webapp [msm_backend] in [C:\Users\Wilfried\workspace2\msm_backend\target\msm_backend-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Wilfried\workspace2\msm_backend\WebContent]
[INFO] Webapp assembled in [1113 msecs]
[INFO] Building war: C:\Users\Wilfried\workspace2\msm_backend\target\msm_backend-0.0.1-SNAPSHOT.war
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ msm_backend ---
[INFO] Installing C:\Users\Wilfried\workspace2\msm_backend\target\msm_backend-0.0.1-SNAPSHOT.war to C:\Users\Wilfried\.m2\repository\msm_backend\msm_backend\0.0.1-SNAPSHOT\msm_backend-0.0.1-SNAPSHOT.war
[INFO] Installing C:\Users\Wilfried\workspace2\msm_backend\pom.xml to C:\Users\Wilfried\.m2\repository\msm_backend\msm_backend\0.0.1-SNAPSHOT\msm_backend-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.234 s
[INFO] Finished at: 2018-10-12T23:17:55+02:00
[INFO] ------------------------------------------------------------------------
4

0 に答える 0