Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Uso do projeto loja com pom.xml com problema na classe Servidor

Bom dia ,

Poderia me ajudar nesse assunto sei que não faz parte do curso mas estou

tentando executar esse projeto loja através do maven , mas estou com erro

na classe do Servidor conforme erro abaixo :

na linha :

HttpServer server = GrizzlyHttpServerFactory.createHttpServer(uri, config);

com erro :

Description    Resource    Path    Location    Type
The type org.glassfish.jersey.internal.ProcessingException cannot be resolved. It is indirectly referenced from required .class files    Servidor.java    /voo/src/main/java/br/com/voo    line 25    Java Problem

codigo fonte :

import java.io.IOException;
import java.net.URI;

import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;

public class Servidor {

    public static void main(String[] args) throws IOException {
        HttpServer server = InicializaServidor();
        System.out.println("Servidor rodando");
        System.in.read();
        server.stop();
    }

     static HttpServer InicializaServidor() {
        ResourceConfig config = new ResourceConfig().packages("br.com.teste.loja");
        URI uri = URI.create("http://localhost:8080/");
        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(uri, config);
        return server;
    }
}

ficheiro pom.xml

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.4</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.grizzly/grizzly-framework -->
    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-framework</artifactId>
        <version>2.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.grizzly/grizzly-http -->
    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-http</artifactId>
        <version>2.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.grizzly/grizzly-http-server -->
    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-http-server</artifactId>
        <version>2.3.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.grizzly/grizzly-rcm -->
    <dependency>
        <groupId>org.glassfish.grizzly</groupId>
        <artifactId>grizzly-rcm</artifactId>
        <version>2.3.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/cglib -->
    <dependency>
        <groupId>org.glassfish.hk2.external</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.0-b21</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/asm-all-repackaged -->
    <dependency>
        <groupId>org.glassfish.hk2.external</groupId>
        <artifactId>asm-all-repackaged</artifactId>
        <version>2.2.0-b21</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>14.0.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.1</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-api -->
    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-api</artifactId>
        <version>2.2.0-b21</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-locator -->
    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-locator</artifactId>
        <version>2.2.0-b21</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-utils -->
    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-utils</artifactId>
        <version>2.2.0-b21</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-utils -->
    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-utils</artifactId>
        <version>2.2.0-b21</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.2</version>
    </dependency><!-- https://mvnrepository.com/artifact/org.glassfish.hk2.external/javax.inject -->
    <dependency>
        <groupId>org.glassfish.hk2.external</groupId>
        <artifactId>javax.inject</artifactId>
        <version>2.2.0-b21</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-grizzly2-http -->
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-grizzly2-http</artifactId>
        <version>2.4.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.9</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/osgi-resource-locator -->
    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>osgi-resource-locator</artifactId>
        <version>1.0.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/xmlpull/xmlpull -->
    <dependency>
        <groupId>xmlpull</groupId>
        <artifactId>xmlpull</artifactId>
        <version>1.1.3.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/xpp3/xpp3_min -->
    <dependency>
        <groupId>xpp3</groupId>
        <artifactId>xpp3_min</artifactId>
        <version>1.1.4c</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
    <dependency>
        <groupId>com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.4.6</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.5.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-common</artifactId>
        <version>2.5.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet-core -->
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <version>2.5.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-grizzly2-http -->
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-grizzly2-http</artifactId>
        <version>2.0-m05-2</version>
    </dependency>




    <dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
    </dependency>
2 respostas
solução!

Oi Paulo, tudo bom?

Pelo erro, parece que a classe org.glassfish.jersey.internal.ProcessingException não está no ClassPath do projeto.

Pelo que vi, essa classe faz parte do jar jersey-common, mas na versão 2.0 dele. Na versão 2.5.1 eu pelo menos não encontrei essa classe. Tenta mudar a versão e me avisa se funcionou.

Aproveitando, uma dica: se achar que o assunto não tem a ver com o tema do curso, dá pra escolher a opção "off-topic" na hora de postar a pergunta. :)

Obrigado pela ajuda.