WSO2 AppServer v5.0.0无法找到InitialContext类?

时间:2012-09-26 12:44:13

标签: wso2

我正在尝试为新的WSO2 AppServer(版本5.0.0)运行一个非常简单的应用程序,但似乎有一些非常奇怪的事情。当我尝试访问执行简单JNDI查找的页面时,出现以下错误:

HTTP Status 500 - org.apache.jasper.JasperException: Unable to compile class for JSP     Generated servlet error: 
Only a type can be imported. javax.naming.InitialContext resolves to a package 
An error occurred at line: 11 in the jsp file: /jndi.jsp 
Generated servlet error: InitialContext cannot be resolved to a type 
An error occurred at line: 11 in the jsp file: /jndi.jsp Generated servlet error:
InitialContext cannot be resolved to a type

该页面仅包含以下代码:

<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%@page import="javax.naming.InitialContext" %>
<html>
    <head>
       <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>JNDI Test</title>
  </head>
 <body>
    <h1>JNDI Test</h1>
 <%
   InitialContext ctx = new InitialContext();
 %>     
 <p>Context: <%= ctx.getNameInNamespace() %>

   </body>
</html>

似乎tomcat编译器无法“看到”java运行时类,但我无法弄清楚原因。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

将jndi查找代码添加到单独的java类中,并从jsp页面调用它。