これが私が書いたSCCEです。私はJava Webアプリケーションプログラミングにまったく慣れていないため、何かが欠けている可能性が完全にあります。したがって、初心者が前進するためのアドバイスは本当にありがたいです。パッケージ名も参照してみましたが、うまくいきませんでした。web.xml でセッション Bean を参照する必要があるものはありますか? これらのファイルは、デプロイされた EAR ファイル内の WAR ファイルにあるためです。私はJavaサーバーフェイスとEE7を使用していることに注意してください。
GlassFish4 エラー
/index.xhtml @10,78 binding="#{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);
}
}