Merhaba Jsf çalışırken yaptığım bir ornek hatayla karşılaştım çözemiyorum yardımcı olursanız sevinirim..

Ekle butonuna basınca resolved 'bean ' to null hatası alıyorum

IndexBean

@ManagedBean(name = "bean")
@SessionScoped
public class IndexBean implements Serializable{

@EJB
PersonService personService;

Person person = new Person();
Phone personelPhone = new Phone();
Phone businessPhone = new Phone();

List<Phone> phoneList = new ArrayList<Phone>();

public Person getPerson() {
    return person;
}

public void setPerson(Person person) {
    this.person = person;
}

public Phone getPersonelPhone() {
    return personelPhone;
}

public void setPersonelPhone(Phone personelPhone) {
    this.personelPhone = personelPhone;
}

public Phone getBusinessPhone() {
    return businessPhone;
}

public void setBusinessPhone(Phone businessPhone) {
    this.businessPhone = businessPhone;
}

public void save() {
    phoneList.add(personelPhone);
    phoneList.add(businessPhone);
    person.setPhone(phoneList);

    personService.save(person);
}

PersonService

@Stateless
public class PersonService {

@EJB
private PersonFacade personFacade;

public PersonService() {
}

public void save(Person person){
    personFacade.create(person);
}

}

PersonFacade

@Stateless
public class PersonFacade extends AbstractFacade<Person> {
@PersistenceContext(unitName = "phoneList")
private EntityManager em;

@Override
protected EntityManager getEntityManager() {
    return em;
}

public PersonFacade() {
    super(Person.class);
}

}

Index.xhtml

    <h:body>
    <h:form>
        <h:panelGrid columns="2">
            <h:outputLabel value="Adı : " />
            <h:inputText value="#{bean.person.ad}" />

            <h:outputLabel value="Soyad : " />
            <h:inputText value="#{bean.person.soyad}" />

            <h:outputLabel value="Kişişel Numarası : " />
            <h:inputText value="#{bean.personelPhone.number}" />

            <h:outputLabel value="İş Numarası : " />
            <h:inputText value="#{bean.businessPhone.number}" />
        </h:panelGrid>
        <h:commandButton action="#{bean.save()}" value="Kişiyi Ekle"/>
    </h:form>
</h:body>

persistence.xml

 <persistence-unit name="phoneList" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>domain.Person</class>
<class>domain.Phone</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/sample-01"/>
  <property name="javax.persistence.jdbc.password" value="app"/>
  <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
  <property name="javax.persistence.jdbc.user" value="app"/>
  <property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>

Person Sınıfı

@Entity
public class Person implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@Column(nullable = false)
private String ad;
@Column(nullable = false)
private String soyad;

@OneToMany
private List<Phone> phone;

public String getAd() {
    return ad;
}

public void setAd(String ad) {
    this.ad = ad;
}

public String getSoyad() {
    return soyad;
}

public void setSoyad(String soyad) {
    this.soyad = soyad;
}

public List<Phone> getPhone() {
    return phone;
}

public void setPhone(List<Phone> phone) {
    this.phone = phone;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Person)) {
        return false;
    }
    Person other = (Person) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "domain.Person[ id=" + id + " ]";
}

StackTrace

org.apache.myfaces.view.facelets.el.ContextAwarePropertyNotFoundException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:79)
at org.apache.myfaces.shared.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:81)
at org.apache.myfaces.shared.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:548)
at org.apache.myfaces.shared.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:1009)
at org.apache.myfaces.shared.renderkit.html.HtmlTextRendererBase.getConvertedValue(HtmlTextRendererBase.java:355)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:658)
at javax.faces.component.UIInput.validate(UIInput.java:594)
at javax.faces.component.UIInput.processValidators(UIInput.java:274)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
at javax.faces.component.UIForm.processValidators(UIForm.java:213)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1427)
at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1456)
at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:74)
at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1563)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1412)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:812)
at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:38)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
     Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
at org.apache.el.parser.AstValue.getTarget(AstValue.java:97)
at org.apache.el.parser.AstValue.getType(AstValue.java:81)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:171)
at      org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:75)
... 40 more

soruldu: 03 Oca '15, 05:24

erdemaky's gravatar image

erdemaky
1112
cevap kabul oranı: 0%

değiştirildi: 03 Oca '15, 14:32

Hocam import'u javax.faces.bean.ManagedBean'den aldığınıza emin misiniz ?

(03 Oca '15, 11:21) Amadeus Amadeus's gravatar image

evet eminim

(03 Oca '15, 13:31) erdemaky erdemaky's gravatar image

person sınıfı eklendi

(03 Oca '15, 14:29) erdemaky erdemaky's gravatar image

@ManagedBean(name = "bean")

bunun yerine

@ManagedBean(name = "indexBean") denermisiniz. Sanki bean ismi ile match edemiyor.

(03 Oca '15, 19:37) Turgay Can Turgay%20Can's gravatar image

yine olmadı

(04 Oca '15, 04:53) erdemaky erdemaky's gravatar image

http://tomee.apache.org/jpa-concepts.html

Bu sayfada buldum cevabı persistence.xml ile alakalı bir sorun varmış :D

(04 Oca '15, 05:35) erdemaky erdemaky's gravatar image

Sorunun cevabı neyse onu net bir şekilde yazınız.

(04 Oca '15, 08:20) rahmanyazgan ♦ rahmanyazgan's gravatar image

@rahmanyazgan, hocam persistence.xml de problem varsa muhtemel transaction type tanımlamasında olabilir. Ama alınan hatayı JSF bazında sorulduğundan, sorunun içeriği ile örtüşmüyor.

(04 Oca '15, 14:38) Turgay Can Turgay%20Can's gravatar image
8 yorumdan 5 tanesi gösteriliyor hepsini göster
Bu soruya ilk cevap veren sen ol!
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×281
×14
×3
×3

Soruldu: 03 Oca '15, 05:24

Görüntüleme: 684 kez

Son güncelleme: 04 Oca '15, 14:38

powered by BitNami OSQA