Solucionado (ver solução)

Importante

Você está vendo a versão anterior da nova experiência da Alura que estamos preparando para você. Em breve, ela ganha uma identidade visual novinha totalmente pensada em potencializar seus estudos!

Solucionado
(ver solução)
16
respostas

AULA 6 - NÃO CONSIGO PUBLICAR O SERVIÇO NO WILDFLY

Não estou conseguindo publicar o serviço no WildFly. Segui os mesmo procedimentos descritos no exercício e quando vou tentar abrir o wsdl em http://localhost:8080/estoque-web/EstoqueWS?wsdl dá um erro not found.

16 respostas
package br.com.caelum.estoque.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.FaultAction;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

/**
 * This class was generated by Apache CXF 2.7.13
 * 2018-07-24T15:54:31.680-03:00
 * Generated source version: 2.7.13
 * 
 */
@WebService(targetNamespace = "http://ws.estoque.caelum.com.br/", name = "EstoqueWS")
@XmlSeeAlso({ObjectFactory.class})
public interface EstoqueWS {

    @WebMethod(operationName = "TodosOsItens")
    @Action(input = "http://ws.estoque.caelum.com.br/EstoqueWS/TodosOsItensRequest", output = "http://ws.estoque.caelum.com.br/EstoqueWS/TodosOsItensResponse")
    @RequestWrapper(localName = "TodosOsItens", targetNamespace = "http://ws.estoque.caelum.com.br/", className = "br.com.caelum.estoque.ws.TodosOsItens")
    @ResponseWrapper(localName = "TodosOsItensResponse", targetNamespace = "http://ws.estoque.caelum.com.br/", className = "br.com.caelum.estoque.ws.TodosOsItensResponse")
    @WebResult(name = "itens", targetNamespace = "")
    public br.com.caelum.estoque.ws.ListaItens todosOsItens(
        @WebParam(name = "filtros", targetNamespace = "http://ws.estoque.caelum.com.br/")
        br.com.caelum.estoque.ws.Filtros filtros
    );

    @WebMethod(operationName = "CadastrarItem")
    @Action(input = "http://ws.estoque.caelum.com.br/EstoqueWS/CadastrarItemRequest", output = "http://ws.estoque.caelum.com.br/EstoqueWS/CadastrarItemResponse", fault = {@FaultAction(className = AutorizacaoFault.class, value = "http://ws.estoque.caelum.com.br/EstoqueWS/CadastrarItem/Fault/AutorizacaoException")})
    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
    @WebResult(name = "CadastrarItemResponse", targetNamespace = "http://ws.estoque.caelum.com.br/", partName = "result")
    public CadastrarItemResponse cadastrarItem(
        @WebParam(partName = "parameters", name = "CadastrarItem", targetNamespace = "http://ws.estoque.caelum.com.br/")
        CadastrarItem parameters,
        @WebParam(partName = "tokenUsuario", name = "tokenUsuario", targetNamespace = "http://ws.estoque.caelum.com.br/", header = true)
        TokenUsuario tokenUsuario
    ) throws AutorizacaoFault;
}
package br.com.caelum.estoque.ws;

import java.util.Arrays;

import javax.jws.WebService;

@WebService(endpointInterface="br.com.caelum.estoque.ws.EstoqueWS",serviceName="EstoqueWS", 
portName="EstoqueWSPort")
public class EstoqueWSImpl implements EstoqueWS {

    @Override
    public ListaItens todosOsItens(Filtros filtros) {
        System.out.println("Chamando todos os Itens");
        ListaItens listaItens = new ListaItens();
        listaItens.item = Arrays.asList(geraItem());
        return listaItens;
    }

    @Override
    public CadastrarItemResponse cadastrarItem(CadastrarItem parameters, TokenUsuario tokenUsuario) throws AutorizacaoFault {
        System.out.println("Chamando cadastarItem");
        CadastrarItemResponse resposta = new CadastrarItemResponse();
        resposta.setItem(geraItem());
        return resposta;
    }

    //método auxiliar
    private Item geraItem() {
        Item item = new Item();
        item.codigo = "MEA";
        item.nome = "MEAN";
        item.quantidade = 5;
        item.tipo = "Livro";
        return item;
    }

}

No Console não apresenta nada referente ao serviço, as classes foram criadas via cmd a partir do wsdl e o projeto foi add no servidor.

Alguém ?

Oi Paulo,

Aparentemente o código está correto.

Se não apareceu nada no console pode ser que o WildFly não tenha feito o deploy do projeto.

Faz o seguinte, na aba Servers clique na setinha para expandir o WildFly, clique com o botão direito em cima do projeto e escolha: Full Publish.

Após isso reinicie o servidor e veja se resolve.

Aproveitando, poste aqui todo o log que for impresso no console.

LOG

16:16:25,410 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final 16:16:25,605 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final 16:16:25,667 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.1.Final "Tweek" starting 16:16:26,867 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found estoquews-web.war in deployment directory. To trigger deployment create a file called estoquews-web.war.dodeploy 16:16:26,885 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 16:16:26,904 INFO [org.xnio] (MSC service thread 1-6) XNIO version 3.3.0.Final 16:16:26,914 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.3.0.Final 16:16:26,975 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension 16:16:26,978 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique. 16:16:26,981 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem 16:16:27,003 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem. 16:16:27,006 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 16:16:27,018 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors 16:16:27,027 INFO [org.jboss.as.security] (MSC service thread 1-4) JBAS013170: Current PicketBox version=4.0.21.Final 16:16:27,040 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem 16:16:27,046 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main] 16:16:27,071 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.8.Final starting 16:16:27,073 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017502: Undertow 1.1.8.Final starting 16:16:27,121 INFO [org.jboss.as.connector.logging] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final) 16:16:27,128 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010417: Started Driver service with driver-name = h2 16:16:27,197 INFO [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service 16:16:27,211 INFO [org.jboss.as.mail.extension] (MSC service thread 1-7) JBAS015400: Bound mail session [java:jboss/mail/Default] 16:16:27,349 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path C:\develop\wildfly-8.2.1.Final/welcome-content 16:16:27,556 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017525: Started server default-server. 16:16:27,565 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 4.0.7.Final 16:16:27,568 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017531: Host default-host starting 16:16:27,700 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080 16:16:27,847 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 16:16:27,876 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory C:\develop\wildfly-8.2.1.Final\standalone\deployments 16:16:27,877 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "estoquews-web.war" (runtime-name: "estoquews-web.war") 16:16:28,382 INFO [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final 16:16:28,696 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017534: Registered web context: /estoquews-web 16:16:28,752 INFO [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "estoquews-web.war" (runtime-name : "estoquews-web.war") 16:16:28,888 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management 16:16:28,889 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 16:16:28,889 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.2.1.Final "Tweek" started in 3699ms - Started 249 of 304 services (92 services are lazy, passive or on-demand)

Ao clicar no Full Publish ocorre o seguinte erro.

Error renaming C:\develop\wildfly-8.2.1.Final\standalone\tmp\tmp8540554980379931124.wsdl to C:\develop\wildfly-8.2.1.Final\standalone\deployments\estoquews-web.war\WEB-INF\classes\EstoqueWSServiceCap5.wsdl.

This may be caused by incorrect file permissions, or your server's temporary deploy directory may be on a different filesystem than the final destination.

You may adjust these settings in the server editor.

Oi Paulo,

Pelo log, a aplicação subiu com o contexto estoquews-web, então o endereço correto para acessar o WSDL deve ser: http://localhost:8080/estoquews-web/EstoqueWS?wsdl.

Veja se não era isso o problema.

Continua com erro pagina não encontrada. com o endereço http://localhost:8080/estoquews-web/EstoqueWS?wsdl

Oi Paulo,

Na sua mensagem anterior tinha dado um erro ao fazer o full publish.

Faz o seguinte então, entre no diretório onde está instalado seu WildFly, que deve ser C:\develop\wildfly-8.2.1.Final

Entre na pasta standalone e nela deve ter uma pasta chamada tmp. Acesse essa pasta tmp e apague todos os arquivos que estiverem nela.

Depois disso, acesse a pasta deployments e também apague todos os arquivos dentro dela.

Volte ao eclipse e tente fazer o full publish do projeto e inicializar o WildFly

Continua com o erro.

No eclipse surgiu uma pasta JSR-109 Web Services. Dentro da pasta C:\develop\wildfly-8.2.1.Final\standalone\deployments existe a pasta estoquews-web.war que não consigo excluir *Erro ao executar Full Publish Error renaming C:\develop\wildfly-8.2.1.Final\standalone\tmp\tmp1417170349060775221.wsdl to C:\develop\wildfly-8.2.1.Final\standalone\deployments\estoquews-web.war\WEB-INF\classes\EstoqueWSServiceCap5.wsdl.

This may be caused by incorrect file permissions, or your server's temporary deploy directory may be on a different filesystem than the final destination.

You may adjust these settings in the server editor.

Oi Paulo,

Pesquisando aqui vi que uma pessoa teve o mesmo problema, e no caso dela era porque o caminho do arquivo tinha ficado muito extenso no Windows.

Ela resolveu mudando o diretorio do wildfly.

Faz esse teste, renomeia a pasta do wildfly de wildfly-8.2.1.Final para apenas wildfly e mova ela para diretamente dentro do C:.

Daí o caminho do Wildfly vai ficar: C:\wildfly.

Meio bizarro isso, mas tente aí para ver se resolve.

O erro de pagina não encontrada continua, não informa nada relacionado ao serviço ao subir o servidor e ao tentar o Full Publish ocorre o erro:

Error renaming C:\wildfly\standalone\tmp\tmp450609480405516286.MF to C:\wildfly\standalone\deployments\estoquews-web.war\META-INF\MANIFEST.MF.

This may be caused by incorrect file permissions, or your server's temporary deploy directory may be on a different filesystem than the final destination.

You may adjust these settings in the server editor.

Oi Paulo,

Pois é, esse é um daqueles erros bizzaros que acontece do nada e não conseguimos resolver =/

O que eu recomendo é você excluir o Wildfly do Eclipse(meu superior: Window -> Preferences -> Server -> Runtime Environments)

Depois substituir o seu wildfly, baixando um novo do site(http://download.jboss.org/wildfly/8.2.1.Final/wildfly-8.2.1.Final.zip)

E então adicionar novamente o Wildfly no Eclipse, associar o projeto ao wildfly e testar novamente.

Já tinha feito isso, mas tentarei novamente.

solução!

Refiz o processo de geração das classes sem o -n e agora funcionou.