zoukankan      html  css  js  c++  java
  • The import test cannot be resolved

     最近使用Myeclipse开发EJB程序实例遇到的问题。

    EJB Project 名:EJBHello(Stateless)

    EJBHello.java代码:

    package test;
    
    import javax.ejb.Stateless;
    import javax.ejb.Remote;
    import test.EJBHelloRemote;
    @Stateless
    @Remote(EJBHelloRemote.class) 
    public class EJBHello implements EJBHelloRemote {
    	public String sayTime(){
    		return "这是第一个EJB测试程序,现在时间为:"+new java.util.Date();
    	}
    }
    

    EJBHelloRemote.java代码:

    package test;
    
    import javax.ejb.Remote;
    
    @Remote
    public interface EJBHelloRemote {
    	public String sayTime();
    }
    

    EJB程序客户端的Web项目:EJBHelloClient

    EJBHello.jsp代码:

    <%@page import="test.*,javax.naming.*"%>                          //ERROR:The import test cannot be resolved
    <%@ page language="java" 
        pageEncoding="ISO-8859-1"%>
    <%
        try {
            InitialContext ctx = new InitialContext();
            EJBHelloRemote hello = (EJBHelloRemote) ctx       //ERROR:EJBHelloRemote cannot be resolved to a type
                    .lookup("EJBHello/remote");
            out.print(hello.sayTime());
        } catch (NamingException e) {
            out.print(e.getMessage());
        }
    %>

    部署到JBoss EAP6.2后,打开网页,结果如下:  


    JBWEB000065: HTTP Status 500 - JBWEB004062: Unable to compile class for JSP:

    JBWEB000309: type JBWEB000066: Exception report

    JBWEB000068: message JBWEB004062: Unable to compile class for JSP:

    JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.

    JBWEB000070: exception

    org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP:

    JBWEB004060: An error occurred at line: 7 in the jsp file: /EJBHello.jsp
    EJBHelloRemote cannot be resolved to a type
    4: <%
    5: try {
    6: InitialContext ctx = new InitialContext();
    7: EJBHelloRemote hello = (EJBHelloRemote) ctx
    8: .lookup("EJBHello/remote");
    9: out.print(hello.sayTime());
    10: } catch (NamingException e) {


    JBWEB004060: An error occurred at line: 7 in the jsp file: /EJBHello.jsp
    EJBHelloRemote cannot be resolved to a type
    4: <%
    5: try {
    6: InitialContext ctx = new InitialContext();
    7: EJBHelloRemote hello = (EJBHelloRemote) ctx
    8: .lookup("EJBHello/remote");
    9: out.print(hello.sayTime());
    10: } catch (NamingException e) {


    JBWEB004211: Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:69)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:447)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    JBWEB000072: note JBWEB000073: The full stack trace of the root cause is available in the JBoss Web/7.2.2.Final-redhat-1 logs.

    JBoss Web/7.2.2.Final-redhat-1


      原因应该是JSP不能import EJBHello项目中的test包。So, 应该怎样导入呢?

    相信自己!!

     

  • 相关阅读:
    每天一个linux命令(31): /etc/group文件详解
    每天一个linux命令(15):tail 命令
    每天一个linux命令(30): chown命令
    每天一个linux命令(22):find 命令的参数详解
    每天一个linux命令(23):Linux 目录结构
    每天一个linux命令(17):whereis 命令
    每天一个linux命令(18):locate 命令
    每天一个linux命令(34):du 命令
    每天一个linux命令(25):linux文件属性详解
    ThinkPad E420功能键和快捷键 以及 Fn和Ctrl键功能切换的设置,插入鼠标后, 关闭触摸板
  • 原文地址:https://www.cnblogs.com/drl937676516/p/3588147.html
Copyright © 2011-2022 走看看