1
resposta

HTTP Status 500 – Internal Server Error

Olá, estou tendo problema ao acessar a parte de edição dos produtos, sempre que clico em editar me vem um erro, estou usando o mysql 8.0:

GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/projeto-jpa-2] threw exception [org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.produto.form_jsp] with root cause
java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.produto.form_jsp

GRAVE: Servlet.service() for servlet [jsp] threw exception
java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.produto.form_jsp

Segue abaixo meu form.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>


<c:import url="../template/top.jsp" />
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">Novo produto</div>

        <div class="panel-body">
            <form action="${spring:mvcUrl('cadastraProduto').class}" method="post">
                <div class="form-group">
                    <label for="nome">
                        Nome:
                    </label>
                    <input type="text" class="form-control" name="nome" value="${produto.nome}">
                    <form:errors path="produto.nome" />
                </div>

                <div class="form-group">
                    <label for="nome">
                        Link da foto:
                    </label>
                    <input type="text" class="form-control" name="linkDaFoto" value="${produto.linkDaFoto}">
                    <form:errors path="produto.linkDaFoto" />
                </div>
                <div class="form-group">
                    <label for="nome">
                        Preço:
                    </label>
                    <input type="text" class="form-control" name="preco" value="${produto.preco}">
                    <form:errors path="produto.preco" />
                </div>
                <div class="form-group">
                    <label for="nome">
                        Loja:
                    </label>
                    <select name="loja.id" class="form-control">
                        <option value="selecione">Selecione</option>
                        <c:forEach items="${lojas}" var="loja">
                            <c:choose>
                                <c:when test="${produto.loja.id == loja.id }">
                                    <option value="${loja.id}" selected>${loja.nome}</option>    
                                </c:when>
                                <c:when test="${produto.loja.id != loja.id }">
                                    <option value="${loja.id}">${loja.nome}</option>    
                                </c:when>
                            </c:choose>
                        </c:forEach>
                    </select>
                    <form:errors path="produto.loja.id" />
                </div>
                <div class="form-group">
                    <label for="descricao">
                        Categoria:
                    </label><br>
                    <c:forEach items="${categorias}" var="categoria" varStatus="status">
                        <c:set var="contains" value="false"/>

                        <c:forEach items="${produto.categorias}" var="categoriaProduto" varStatus="statusProduto">
                            <c:if test="${categoriaProduto.id == categoria.id}">
                                <c:set var="contains" value="true"/>        
                            </c:if>
                        </c:forEach>    
                        <c:choose>    
                            <c:when test="${contains}">
                                 <input type="checkbox" name="categorias" value="${categorias[status.index].id}" checked> 
                                    ${categoria.nome}<br>
                                <c:set var="contains" value="false"/>        
                            </c:when>
                            <c:when test="${not contains }">
                                <input type="checkbox" name="categorias" value="${categorias[status.index].id}"> 
                                    ${categoria.nome}<br>
                            </c:when>
                        </c:choose>
                    </c:forEach>
                </div>
                <div class="form-group">
                    <label for="descricao">
                        Descrição:
                    </label>
                    <textarea name="descricao" class="form-control">${produto.descricao}</textarea>
                </div>
                <form:errors path="produto.descricao" />

                <c:if test="${produto.id != null}">
                    <div class="form-group">
                        <input type="submit" class="btn btn-success" value="Atualizar">
                        <input type="hidden" name="id" value="${produto.id}">
                    </div>
                </c:if>

                <c:if test="${produto.id == null}">
                    <div class="form-group">
                        <input type="submit" class="btn btn-success" value="Cadastrar">
                    </div>
                </c:if>

             </form>
        </div>
    </div>
</div>


</body>
</html>
1 resposta

Tem algum conflito nas dependência do seu projeto, verifique se o seu pom.xml está com as dependências igual abaixo:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.caelum</groupId>
    <artifactId>projeto-jpa-2</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Projeto JPA 2</name>
    <url>http://maven.apache.org</url>
    <properties>
        <spring.version>4.1.6.RELEASE</spring.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <!-- <scope>provided</scope> -->
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.2.1.Final</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <scope>runtime</scope>
        </dependency>


        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>

        <!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> 
            <version>2.6.9</version> </dependency> -->

        <!-- Hibernate EHCache API -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>4.3.5.Final</version>
        </dependency>
        <!-- EHCache uses slf4j for logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>

        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.5.Final</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.35</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>projeto-jpa-2</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>