Merhabalar...

Jsf ve Jpa kullanarak üye girişi yapmak istiyorum fakat pek tatmin edici kod örnekleri bulamadım internette kendi çalıştırdığım kodda şöyle bir hata fırlatıyor

--> javax.servlet.ServletException: Unexpected error processing managed bean loginCRUD
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)

SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/webProjem] threw exception [Unexpected error processing managed bean loginCRUD] with root cause
java.lang.NullPointerException

JSF de yeniyim yardımlarınızı bekliyorum...

soruldu: 04 May '12, 09:40

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

değiştirildi: 04 May '12, 10:51

%C3%B6zcanacar's gravatar image

özcanacar ♦♦
17.2k59183183

Kodu gormeden hatayi anlamak zor, hata nerden geliyorsa ilgili kod parcacigini kopyalarsaniz daha iyi yardimci olabiliriz.

(04 May '12, 10:06) CemIkta ♦ CemIkta's gravatar image

Gerc ekten kod u görmeden bisey söylemek zor ama, sanki, loginCRUD Bean nin icine Inject ettigin bisey Null gibi geliyor bana. Belki baska bir Bean ve ya EntityManager.

(04 May '12, 10:09) mceliksoy ♦ mceliksoy's gravatar image

Sorunu çözdüm

Persistence.xml dosyasında managed property kısmında kullanılmayan boş bir property vardı bütün bunlar bu küçücük şeyden çıktı...

İlgilenen herkese teşekkür ederim.

permanent link

cevaplandı: 04 May '12, 11:29

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

Eger Netbeans IDE 7.1.2'yi yuklersen samples icinde JPA + JSF login demosu var.

New Project den Samples > Java Web > JSF JPA (Java EE 6)

Ayrica JPA + JSF ile CRUD ve listeleme islemleri ornegi de var.

New Project den Samples > Java Web > JSF JPA CRUD (Java EE 6)

Kolay gelsin.

permanent link

cevaplandı: 07 May '12, 05:34

CemIkta's gravatar image

CemIkta ♦
19.9k29125190
cevap kabul oranı: 36%

LoginCRUD u Managed Bean olarak kullandım

public class LoginCRUD {

private static final long serialVersionUID = 1L;  
private Login login = new Login();

public Login getLogin() { return login; } public void setLogin(Login login) { this.login = login; }

public String Giris() {

EntityManagerFactory emf = Persistence.createEntityManagerFactory("webProjem"); EntityManager em = emf.createEntityManager();

Query q = em.createQuery("SELECT l FROM Login l WHERE l.username =: user And l.password =: pass"); q.setParameter("user", login.getUsername()); q.setParameter("pass", login.getPassword());

List<login> l = (List<login>) q.getSingleResult(); if(l.get(0).getUsername() != null && l.get(0).getPassword() != null) { return "index";

}
 else
 return "";

}

permanent link

cevaplandı: 04 May '12, 10:55

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

**JSF SAYFAM**

<%@ page language="java" contentType="text/html; charset=ISO-8859-9" pageEncoding="ISO-8859-9"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">
<title>Login</title>
</head>
<body>
    <f:view>
    <h:form id="helloForm">
        <Center>
        <h2>Login Page</h2>
        <br /> <br />
        <table>
    <tr>
        <td><h:outputLabel for="input1">
            <h:outputText id="nameLabel" value="User Name" />
            </h:outputLabel>
        </td>
        <td><h:inputText id="input1"
            value="#{loginCRUD.login.username}" size="20" />
        </td>
    </tr>
    <tr>
        <td><h:outputLabel for="input2">

            <h:outputText id="passwordLabel" value="Password" />
        </h:outputLabel>
        </td>
        <td><h:inputSecret id="input2"
            value="#{loginCRUD.login.password}" size="20" />
        </td>
    </tr>
    <tr>
        <td></td>
        <td><h:commandButton id="logon" action="#{loginCRUD.Giris}"
                        value="Giriş">
        </h:commandButton>
        </td>
    </tr>
</table>
</Center>
</h:form>
</f:view>
</body>
</html>
permanent link

cevaplandı: 04 May '12, 10:59

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

değiştirildi: 04 May '12, 11:00

Login Sayfamda şu şekilde

package pojo;

import java.io.Serializable; import javax.persistence.*; import java.util.List;

@Entity @Table(name="login") public class Login implements Serializable { private static final long serialVersionUID = 1L;

@Id
@Column(name="LoginID", unique=true, nullable=false)
private int loginID;

@Column(name="Adres", length=100)
private String adres;

@Column(name="Hesapno")
private int hesapno;

@Column(name="Password", length=20)
private String password;

@Column(name="Username", length=20)
private String username;

//bi-directional many-to-one association to Roller
@ManyToOne
@JoinColumn(name="RoleID")
private Roller roller;

//bi-directional many-to-one association to Sepet
@OneToMany(mappedBy="login")
private List<Sepet> sepets;

public Login() {
}

public int getLoginID() {
    return this.loginID;
}

public void setLoginID(int loginID) {
    this.loginID = loginID;
}

public String getAdres() {
    return this.adres;
}

public void setAdres(String adres) {
    this.adres = adres;
}

public int getHesapno() {
    return this.hesapno;
}

public void setHesapno(int hesapno) {
    this.hesapno = hesapno;
}

public String getPassword() {
    return this.password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getUsername() {
    return this.username;
}

public void setUsername(String username) {
    this.username = username;
}

public Roller getRoller() {
    return this.roller;
}

public void setRoller(Roller roller) {
    this.roller = roller;
}

public List<Sepet> getSepets() {
    return this.sepets;
}

public void setSepets(List<Sepet> sepets) {
    this.sepets = sepets;
}

}

permanent link

cevaplandı: 04 May '12, 11:02

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

Hocam bu kadar çok şeyi buraya yazmaktansa http://pastebin.com gibi siteleri kullanabiliriz, ayrıca syntax desteği sayesinde daha güzel görünür ;)

(04 May '12, 16:18) rahmanyazgan ♦ rahmanyazgan's gravatar image

Hata olarak dönen log kısmı da şöyle :)

HTTP Status 500 -

type Exception report

message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Unexpected error processing managed bean loginCRUD javax.faces.webapp.FacesServlet.service(FacesServlet.java:321) root cause

com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed bean loginCRUD com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:394) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:258) com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:191) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) org.apache.el.parser.AstValue.getValue(AstValue.java:147) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) javax.faces.component.UIOutput.getValue(UIOutput.java:164) com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:351) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:160) javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) javax.faces.render.Renderer.encodeChildren(Renderer.java:164) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646) com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:427) com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:229) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) root cause

com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed property ' com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:113) com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:349) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:258) com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:191) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) org.apache.el.parser.AstValue.getValue(AstValue.java:147) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) javax.faces.component.UIOutput.getValue(UIOutput.java:164) com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:351) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:160) javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) javax.faces.render.Renderer.encodeChildren(Renderer.java:164) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646) com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:427) com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:229) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) root cause

java.lang.NullPointerException com.sun.faces.mgbean.ManagedBeanBuilder.getPropertyDescriptor(ManagedBeanBuilder.java:385) com.sun.faces.mgbean.ManagedBeanBuilder.bakeBeanProperty(ManagedBeanBuilder.java:313) com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:103) com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:349) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:258) com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:191) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) org.apache.el.parser.AstValue.getValue(AstValue.java:147) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:106) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190) javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178) javax.faces.component.UIOutput.getValue(UIOutput.java:164) com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:351) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:160) javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) javax.faces.render.Renderer.encodeChildren(Renderer.java:164) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646) com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:427) com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:229) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135) javax.faces.webapp.FacesServlet.service(FacesServlet.java:309) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.

Apache Tomcat/7.0.27

permanent link

cevaplandı: 04 May '12, 11:06

O%C4%9EUZ's gravatar image

OĞUZ
66111316
cevap kabul oranı: 18%

Cevabınız
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
×86

Soruldu: 04 May '12, 09:40

Görüntüleme: 1,762 kez

Son güncelleme: 07 May '12, 05:34

powered by BitNami OSQA