Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Eclipse Java Error working with managedBeans in JSF2.2

ServantForChristJava101Nov 30 2015 — edited Nov 30 2015

I have been working some java examples using JSF 2.2, Eclipse Java EE IDE (Luna Release 2 (4.4.2) and Java jre1.8.0_66 and I have run across an error. When I try to run the following xhtml file on using Run as Server (Apache Tomcat 8.0) I get an error.

The Java Class is as follows:

 

package com.luv2code.jsf.hello;
import javax.faces.bean.ManagedBean;



@ManagedBean
public class Student {

    
     private String sfirstName;
     private String slastName;
    
     // create a no-arg constructor
     public Student() {
        
     }

     public String getFirstName() {
         return sfirstName;
     }

     public void setFirstName(String sfirstName) {
         this.sfirstName = sfirstName;
     }

     public String getLastName() {
         return slastName;
     }

     public void setLastName(String slastName) {
         this.slastName = slastName;
     }
    
     // define public getter and setter methods to expose properties of the managed Bean
    
}

 

*** I had changed the variable name from firstName to sfirstName to see if that made a difference.

Also the XHTML file is :

 

<!DOCTYPE html>
<html lang="en"
     xmlns="
http://www.w3.org/1999/xhtml"
     xmlns:h="
http://xmlns.jcp.org/jsf/html"
     xmlns:a="
http://xmlns.jcp.org/jsf/passthrough">

     <h:head>
         <title> Student Registration</title>
     </h:head>
    
     <h:body>

         <h:form>
             First Name: <h:inputText value="#{student.sfirstName}"/>
             <br/><br/>
            
             Last Name: <:inputText value="#{student.slastName}" />
             <br/><br/>
            
             <h:commandButton value="Submit" action="student_response" />
             </h:form>
            
     </h:body>
     </html>

 

*** I have run other sample projects successfully but this is my first using a no arg constructor for the managedBean example.

The error I am getting is:

HTTP Status 500- Unresolved compilation problems
type Exception report
message unresolved compilation problem
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Unresolved compilation problems:
The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
String cannot be resolved to a type
String cannot be resolved to a type
Implicit super constructor Object() is undefined. Must explicitly invoke another constructor
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type

javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.Error: Unresolved compilation problems:
The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
String cannot be resolved to a type
String cannot be resolved to a type
Implicit super constructor Object() is undefined. Must explicitly invoke another constructor
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type
String cannot be resolved to a type

com.luv2code.jsf.hello.Student.<init>(Student.java:1)r

and if I hover ove sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186)
com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:100)
com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:80)
org.apache.el.parser.AstValue.getValue(AstValue.java:137)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
javax.faces.component.UIOutput.getValue(UIOutput.java:174)
javax.faces.component.UIInput.getValue(UIInput.java:291)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


and if I hover over String I see String cannot be resolved to a type and if I hover over Student (the no-arg constructor) I see Implicit constructor Object() is undefined. Must explicitly invoke another constructor.


I am not sure why it wont let me use the private String in m Student class.
Can anyone explain this or offer me some suggestion?

I am fairly new with Java, not even a year experience with Java EE and Eclipse.


Thank you!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 28 2015
Added on Nov 30 2015
0 comments
2,708 views