2
respostas

Erro ao migrar projeto gerenciador para maven

Olá, estou tentando migrar as dependências do projeto gerenciador e exclui todos os arquivos jar e migrei para dependências dentro do arquivo pom.xml

Porém quando rodo o projeto recebo a seguinte mensagem de erro:

dez. 07, 2021 2:11:27 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/gerenciador] threw exception [A uri absoluta [http://java.sun.com/jsp/jstl/core] não pode ser resolvida pelo web.xml ou pelos arquivos jar instalados com esta aplicação] with root cause
org.apache.jasper.JasperException: A uri absoluta [http://java.sun.com/jsp/jstl/core] não pode ser resolvida pelo web.xml ou pelos arquivos jar instalados com esta aplicação

meu arquivo pom.xml

<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>br.com.alura</groupId>
    <artifactId>gerenciador</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

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

        <!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.4.12.v20180830</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/fluent-hc -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.5.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.10</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/com.thoughtworks.xstream/xstream -->
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.18</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>


    </dependencies>
    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.1</version>
            </plugin>
        </plugins>
    </build>
</project>
2 respostas

Oi David,

Acredito que pela versão do servidor que você está utilizando vai precisar substituir a dependência do JSTL por essa:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
    <version>2.0.0</version>
</dependency>

Olá prof. Rodrigo,

Mesmo trocando a dependência ainda tenho o erro:

dez. 15, 2021 9:29:22 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/gerenciador] threw exception [A uri absoluta [http://java.sun.com/jsp/jstl/core] não pode ser resolvida pelo web.xml ou pelos arquivos jar instalados com esta aplicação] with root cause
org.apache.jasper.JasperException: A uri absoluta [http://java.sun.com/jsp/jstl/core] não pode ser resolvida pelo web.xml ou pelos arquivos jar instalados com esta aplicação
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:54)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:251)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:122)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:435)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1450)

Segue abaixo como está o jsp formLogin.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:url value="/entrada" var="linkEntradaServlet"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form action="${linkEntradaServlet }" method="post">
        Login: <input type="text" name="login" />
        Senha: <input type="password" name="senha" />
        <input type="hidden" name="acao" value="Login">
        <input type="submit" />
    </form>
</body>
</html>

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software