2017-11-09 4 views
1

Tomcat 8.5.23을 사용하여 응용 프로그램을 실행하려고하는데 반복해서 같은 오류가 계속 발생합니다. 내가 바람둥이를 시작하고 로컬 호스트를 열려고 할 때마다 HTTP 상태 500 오류가 계속 발생합니다. 다음과 같은 오류입니다. org.apache.jasper.JasperException : [19] 라인에서 JSP 페이지 [/index.jsp]를 처리하는 중 예외가 발생했습니다. 그리고 여기 내 파일 (index.jsp를하고 IntagramWB.java)HTTP 상태 500 - 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> 

내가 자바 클래스의 메소드를 호출하는 것을 시도하고있다. 여기 내 자바 파일 :

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; 
} 
} 

또한 여기 내 폴더 구조가 필요하다면.
Folders structure

및 예외 : 당신의 스택 트레이스의 '근본 원인'섹션에서
exceptions

+0

수업을 컴파일하고 배포 했습니까? 그것은'WEB-INF/classes' 폴더에 있어야합니다. –

답변

0

봐. 실제 오류 java.lang.NoClassDefFoundError가 있습니다 : InstagramWB

기본적으로

, 라인 당신이하고있는 19 ...

InstagramWB insta = new InstagramWB(); 

... 그것은 InstagramWB의의 .class 파일을 찾을 수 없습니다.

war 파일이 올바르게 생성되었으며 InstagramWB 클래스를 사용할 수 있습니까? 예를 들어 unzip 유틸리티를 사용하여 war 파일의 압축을 해제하십시오. Winzip, WinRAR 등을 실행하고이 클래스의 .class 파일을 찾을 수 있는지 확인하십시오.

+0

/tomcat/webapps에 넣고 바람둥이를 시작하면 war 파일이 자동으로 압축이 해제됩니다. 나는 그것을 검사했고 .class 파일은 거기에있다. – scrapy

+0

어떤 이유로 든 클래스 로더가 찾을 수 없기 때문에이 오류가 발생합니다. Tomcat의 클래스 경로 및 클래스로드에 대한이 기사를 참조하십시오. 그러면 이유를 디버깅 할 방향을 제시 할 수 있습니다. https://www.mulesoft.com/tcat/tomcat-classpath – Saurabh