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, 应该怎样导入呢?

 

相信自己!!

 

 

转载于:https://www.cnblogs.com/drl937676516/p/3588147.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值