我正在尝试使用tomcat 8.5.23运行应用程序,但我一遍又一遍地得到同样的错误。每次我尝试启动tomcat并打开本地主机时,我都会收到HTTP状态500错误。 这是错误:org.apache.jasper.JasperException:在第[19]行处理JSP页面[/index.jsp]时发生异常。这是我的文件(index.jsp和IntagramWB.java)
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Web Services">
<meta name="keywords" content="JSP, Bootstap, HTML5">
<!-- including the jQuery file to the bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- including the bootstrap file -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<title> My Restful API</title>
<body>
<%@ page import = "com.mywebservices.InstagramWB" %>
<% InstagramWB insta = new InstagramWB(); %>
<% String details = insta.getDetails(); %>
<script>
var name = JSON.parse("<%= details %>");
document.getElementById("name").innerHTML = details.data.full_name;
</script>
<h1 id = "name"> </h1>
<h2>Last place: </h2>
</body>
</html>
我试图从java类调用一个方法。这是我的java文件:
package com.mywebservices;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class InstagramWB
{
public InstagramWB()
{}
public static String getDetails()
{
// Variable for the access token
String accessToken = "269891473.1677ed0.a60ed893764d4c5";
String replyInsta = "";
String jsonInsta = "";
URL url;
HttpURLConnection connection = null;
InputStream is = null;
try
{
// Endpoint to get the details of the user
String endpoint = "https://api.instagram.com/v1/users/self/?access_token="+accessToken;
// establishing the connection to the endpoint
url = new URL(endpoint);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
while ((replyInsta = reader.readLine()) != null)
{
jsonInsta = replyInsta;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return jsonInsta;
}
}
如果需要,这里也是我的文件夹结构
和例外:
答案 0 :(得分:0)
查看堆栈跟踪的“根本原因”部分。实际错误是java.lang.NoClassDefFoundError:InstagramWB
基本上,在第19行,当你做...
InstagramWB insta = new InstagramWB();
...找不到InstagramWB的.class文件。
您确定您的war文件已正确创建,并且InstagramWB类在其中可用吗?尝试使用任何解压缩实用程序解压缩war文件,例如Winzip,WinRAR等,并检查是否可以在其中找到此类的.class文件。