相关疑难解决方法(0)

Java EE 6:目标无法访问,标识符'helloBean'已解析为null

我想尝试一个简单的JSF 2教程示例.

我在Eclipse中使用动态Web项目并发布到Glassfish 3服务器(运行 - >在服务器上运行).第一个index.xhtml页面正确加载,但是当我必须访问托管bean时,会显示以下错误:

/index.xhtml @14,48 value="#{helloBean.name}": Target Unreachable, identifier 'helloBean' resolved to null
Run Code Online (Sandbox Code Playgroud)

我已经看过关于这个主题的各种其他讨论,但是这些解决方案对我来说似乎永远不会起作用(例如,添加beans.xml,根据命名约定给托管bean命名等).

任何帮助,将不胜感激.

这是我目前正在使用的代码:

的index.xhtml

<?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:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <title>JSF 2.0 Hello World</title>
    </h:head>
    <h:body>
        <h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
        <h:form>
           <h:inputText value="#{helloBean.name}"></h:inputText>
           <h:commandButton value="Welcome Me" action="response"></h:commandButton>
        </h:form>
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

response.xhtml:

<?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://java.sun.com/jsf/html">

    <h:head>
        <title>JSF 2.0 Hello World</title>
    </h:head> …
Run Code Online (Sandbox Code Playgroud)

java java-ee java-ee-6 jsf-2 managed-bean

17
推荐指数
2
解决办法
5万
查看次数

目标无法访问,标识符在JSF 2.2中解析为null

我有JSF 2.2和CDI的问题,我的managerbean没有解决,出现此错误

"value ="#{userBean.user.name}":目标无法访问,标识符'userBean'已解析为null"

这是我的经理bean.

@ManagedBean
@RequestScoped
public class UserBean implements Serializable {
    private User user;

    public void setUser(user) {
        this.user = user;
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

我的观点是:

<h:form id="login-form">
    <h:outputText value="User"/>
    <h:inputText value="#{userBean.user.name}" id="username"/>

    <h:outputText value="Senha"/>
    <h:inputSecret value="#{userBean.user.password}" id="pasword"/>

    <h:commandButton id="button" value="Login" action="#{userBean.login}"/>

    <h:messages />
</h:form>
Run Code Online (Sandbox Code Playgroud)

jsf managed-bean jsf-2.2

17
推荐指数
3
解决办法
10万
查看次数

无法在Eclipse中将应用程序部署到Glassfish 4.1

我在Ubuntu上安装了Glassfish 4.1和Eclipse Luna.当我尝试运行一个简单的Web应用程序(jsp + servlet + java bean)时,我收到了以下错误:

Publishing to Glassfish 4 at localhost[domain1].. has encountered a problem. cannot Deploy mvcprj1 deploy is failing=Application with name [mvcprj1] is not deployed

glassfish服务器日志或eclipse控制台中都没有出现任何内容.

java eclipse glassfish java-ee

13
推荐指数
2
解决办法
3万
查看次数

PropertyNotFoundException:Target Unreachable,'null'返回null

你好,我有新的问题添加表格我的问题在这里

WARNING: /test.xhtml @24,173 value="#{userController.users.username}": Target Unreachable, 'null' returned null
javax.el.PropertyNotFoundException: /test.xhtml @24,173 value="#{userController.users.username}": Target Unreachable, 'null' returned null
        at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:93)
        at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
        at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
        at javax.faces.component.UIInput.validate(UIInput.java:934)
        at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
        at javax.faces.component.UIInput.processValidators(UIInput.java:691)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at javax.faces.component.UIForm.processValidators(UIForm.java:243)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
        at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at …
Run Code Online (Sandbox Code Playgroud)

java jsf

12
推荐指数
1
解决办法
5万
查看次数

尝试在构造函数中访问@Inject bean时出现NullPointerException

我有一个会话范围的bean:

@Named
@SessionScoped
public class SessionBean implements Serializable {

    private String someProperty;

    public String getSomeProperty() {
        return someProperty;
    }

}
Run Code Online (Sandbox Code Playgroud)

我想在请求范围的bean中注入它并使用它初始化:

@Named
@RequestScoped
public class RequestBean {

    @Inject
    private SessionBean sessionBean;  

    public RequestBean() {
        System.out.println(sessionBean.getProperty());
    }

}
Run Code Online (Sandbox Code Playgroud)

但是,它会引发以下异常:

java.lang.NullPointerException
    at com.example.RequestBean.<init>(RequestBean.java:42)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.jboss.weld.introspector.jlr.WeldConstructorImpl.newInstance(WeldConstructorImpl.java:206)
    at org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:117)
    at org.jboss.weld.bean.ManagedBean.createInstance(ManagedBean.java:336)
    at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.produce(ManagedBean.java:200)
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:292)
    ...
Run Code Online (Sandbox Code Playgroud)

这是怎么造成的,我该如何解决?

jsf constructor nullpointerexception cdi managed-bean

12
推荐指数
1
解决办法
1万
查看次数

如何引用JAR文件中提供的JSF托管bean?

我有一个具有以下结构的WAR文件:

在此输入图像描述

在JSF托管bean BusinessObjectTypeListController位于commons-web-1.0.jar/WEB-INF/lib和参考的BusinessObjectTypeListView.xhtml.当我运行我的Web应用程序并调用该视图时,出现以下错误:

javax.servlet.ServletException:/view/common/businessObjectTypeListView.xhtml @ 34,94 listener ="#{businessObjectTypeListController.selectData}":目标无法访问,标识符'businessObjectTypeListController'已解析为null

为什么找不到控制器类?它应该在classpath中,是吗?

java jar java-ee jsf-2 managed-bean

11
推荐指数
1
解决办法
1万
查看次数

错误:javax.el.PropertyNotFoundException:目标无法访问,'null'返回null

我在运行JSF页面时遇到了这个错误.

javax.el.PropertyNotFoundException:目标无法访问,'null'返回null ..

警告:/createStaff.xhtml @ 33,125 value ="#{staffBean.staff.firstName}":目标无法访问,'null'返回null javax.el.PropertyNotFoundException:/createStaff.xhtml @ 33,125 value ="#{staffBean.staff. firstName}":目标无法访问,'null'返回null

我不明白为什么我在使用value =时会遇到错误"#{staffBean.staff.firstName}".当我使用value = "#{staffBean.userName}"和value = "#{staffBean.passWord}"above 时没有问题.

这是我的createStaff.xhtml

<?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"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Create Staff</title>
    </h:head>
    <h:body>
        <f:view>
            <h:form>
                <p:panel id ="panel" header="Staff Creation">
                    <p:messages id="msgs" />
                    <h:panelGrid columns="3" columnClasses="label, value">
                        <h:outputText value="Username: *" />
                        <p:inputText id="username" value="#{staffBean.userName}"   required="true" label="Username">
                        </p:inputText>
                        <p:message for="username" />

                        <h:outputLabel for="pwd1" value="Password 1: *" …
Run Code Online (Sandbox Code Playgroud)

jsf el propertynotfoundexception

11
推荐指数
2
解决办法
5万
查看次数

Outcommented Facelets代码仍调用#{bean.action()}之类的EL表达式,并在#{bean.action}上导致javax.el.PropertyNotFoundException

我的Facelet中有以下代码片段:

<h:commandLink id="cmdbtn">
    <f:ajax event="click" execute="@form"
            listener="#{screenShotBean.takeScreenshot}" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

它工作正常,但当我像这样取消它,

<!--        <h:commandLink id="cmdbtn"> -->
<!--            <f:ajax event="click" execute="@form" -->
<!--                    listener="#{screenShotBean.takeScreenshot}" /> -->
<!--        </h:commandLink> -->
Run Code Online (Sandbox Code Playgroud)

然后它抛出以下异常:

javax.el.PropertyNotFoundException: Property 'takeScreenshot' not found on type monstage.test.com.ScreenShotBean
    at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
    at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
    at javax.el.BeanELResolver.property(BeanELResolver.java:325)
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
    at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
    at com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
    at com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:424)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at …
Run Code Online (Sandbox Code Playgroud)

jsf comments facelets el propertynotfoundexception

7
推荐指数
1
解决办法
3391
查看次数

javax.el.PropertyNotFoundException:目标无法访问,'null'在外键引用上返回null

我知道managedBean有问题,但我无法弄清楚它是什么

当我departmentManagedBean.department.faculty.facultyName从jsf页面尝试时,它给出一个如下的空指针:

javax.el.PropertyNotFoundException:/administrator/department/DepartmentRegistration.xhtml @ 30,260 value ="#{departmentRequestBean.department.faculty.facultyName}":目标无法访问,'null'返回null

javax.el.PropertyNotFoundException: /administrator/department/DepartmentRegistration.xhtml @30,260 value="#{departmentRequestBean.department.faculty.facultyName}": Target Unreachable, 'null' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.richfaces.component.util.InputUtils.findConverter(InputUtils.java:123)
at org.richfaces.component.util.InputUtils$1.getConverterByProperty(InputUtils.java:56)
at org.richfaces.component.util.InputUtils.getConvertedValue(InputUtils.java:148)
at org.richfaces.component.util.InputUtils.getConvertedValue(InputUtils.java:137)
at org.richfaces.renderkit.InputRendererBase.getConvertedValue(InputRendererBase.java:50)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) …
Run Code Online (Sandbox Code Playgroud)

jsf foreign-keys jpa-2.0

5
推荐指数
1
解决办法
2万
查看次数

javax.el.PropertyNotFoundException:在类型org.hibernate.collection.internal.PersistentSet上找不到属性

我试图从关联ManyToMany恢复数据,但我不能,这是我的代码.

实体产品:

@Entity
public class Produit implements Serializable {

@Id
@Column(name="Produit_ID")
@GeneratedValue
private Long id;
private String dq;
private String icForme;
private String ich;
private String icht;

@ManyToMany(cascade = {CascadeType.ALL})
 @JoinTable(name="produit_terminal", 
                joinColumns={@JoinColumn(name="Produit_ID")}, 
                inverseJoinColumns={@JoinColumn(name="Terminal_ID")})
    private Set<Terminal> terminals = new HashSet<Terminal>();

//getter setter
Run Code Online (Sandbox Code Playgroud)

实体终端:

@Entity
public class Terminal implements Serializable{

@Id
@GeneratedValue
@Column(name="Terminal_ID")
private Long id;
private String crimpkontakt;
private String equipment;
private String geometrie;
private String dcbt;
private String icb;
private String ak;

@ManyToMany(mappedBy="terminals")
private Set<Produit> produit = new HashSet<Produit>();

//getter …
Run Code Online (Sandbox Code Playgroud)

jsf many-to-many hibernate propertynotfoundexception

5
推荐指数
1
解决办法
4073
查看次数