這是我寫的SCCE。我完全不熟悉java web應用程序編程,這意味着我完全有可能缺少某些東西。所以,對於新手前進的任何建議都非常感謝。我已經嘗試引用包名稱,但沒有運氣。有什麼我應該引用的web.xml中的會話bean?因爲這些文件位於已部署EAR文件內的WAR文件中。我應該注意到我正在使用java服務器端和EE7。Java EE應用程序以秒爲單位顯示當前服務器時間
GlassFish4錯誤
/index.xhtml @ 10,78結合= 「#{serverSessionBean.time}」:目標不可達,識別符 'ServerSessionBean'
指數歡迎文件
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title></title>
</h:head>
<h:body>
The current server time is:
<h:outputText binding="#{serverSessionBean.time}"/>
</h:body>
</html>
ServerSessionBean
package com.incredibleifs;
import java.util.Calendar;
import javax.ejb.Stateless;
import javax.inject.Named;
@Stateless(description = "A stateless session bean to hold server generic business methods such as getting the date and time")
@Named()
public class ServerSessionBean implements ServerSessionBeanLocal {
@Override
public int getTime() {
return Calendar.getInstance().get(Calendar.SECOND);
}
}
添加註釋命名失敗,甚至消除單/無國籍註釋之後。我仍然收到空引用。我編輯了我的帖子,指出我正在使用java EE 7 - 我不確定6和7是多麼不同 - 儘管我收集的內容已經不一樣了。 – 2014-11-08 19:37:18
@RichardBarker Java EE 7和6之間存在差異,但在這種情況下應用了答案,請參閱我的更新可能會幫助您解決問題。 – 2014-11-08 20:15:44
我編輯了我的代碼以匹配我目前擁有的代碼。但它仍然失敗。 – 2014-11-08 21:50:13