Yapmak istediğim login girişi yapmak ama bunu PhaseListener ile kontrol etmek bu tarafta sorun yok gibi düşünüyorum. ben sayfadan kullanıcı adı ve şifre'yi alıyorum ve bana bir tane User dönderen metoduma gonderiyorum ve daha metoda girer girmez hata fırlatıyor.Daha öncede böyle bir hata almıştım casting işleminden dolayı kaynaklanıyor sanıyordum ve sayfadan çektiğim objecnin id'sini EntityManager'in find() metoduna yolluyordum acsting işlemine gerek kalmıyordu.. ama suan nesne değil sayfadan String değer yolluyorum.

login.xhtml

                <h:form>
                    <p><h:inputText   value="#{lm.user.userName}" /></p>
                    <p><h:inputText  value="#{lm.user.password}" /></p>

                    <h:commandButton action="#{lm.validateUser()}" value="Giris yap"/>
                    <h:commandButton action="#{userControls.createUser()}" value="User Ekle"/>
                </h:form>

User dönderen metodum

 private UserDeneme getUserName() {
        try {

            UserDeneme ud = remote.findByUserName(user);
            return ud;
        } catch (Exception e) {
            return null;
        }
    }

iş yapan metodum //hatayı buraya geldiğinde alıyorum //metodun parametresi olan user null gelmiyor iceri girer girmez hata aliyorum

  @Override
    public UserDeneme findByUserName(UserDeneme user) {

  //hatayı buraya geldiğinde alıyorum
  //metodun parametresi olan user null gelmiyor
        UserDeneme u = em.createQuery("SELECT s FROM userdeneme s WHERE s.username = :username", UserDeneme.class).
                setParameter("username", user.getUserName()).getSingleResult();

        return u;
    }

Aldığım hata :

WARNING:   EJB5184:A system exception occurred during an invocation on EJB BusinessImp, method: public com.yaz.entities.UserDeneme com.yaz.business.BusinessImp.findByUserName(com.yaz.entities.UserDeneme)
WARNING:   javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at $Proxy239.findByUserName(Unknown Source)
    at com.yaz.security.LoginManager.getUserName(LoginManager.java:83)
    at com.yaz.security.LoginManager.validateUser(LoginManager.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
    at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
    at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
Exception Description: Problem compiling [SELECT s FROM userdeneme s WHERE s.username = :username]. 
[14, 24] The abstract schema type 'userdeneme' is unknown.
[33, 43] The state field path 's.username' cannot be resolved to a valid type.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1605)
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:478)
    at com.yaz.business.BusinessImp.findByUserName(BusinessImp.java:32)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    ... 52 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [SELECT s FROM userdeneme s WHERE s.username = :username]. 
[14, 24] The abstract schema type 'userdeneme' is unknown.
[33, 43] The state field path 's.username' cannot be resolved to a valid type.
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:155)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:347)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:278)
    at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:116)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:102)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1583)
    ... 85 more

soruldu: 06 Ağu '13, 05:18

Mehmet%20KILIC's gravatar image

Mehmet KILIC
51191422
cevap kabul oranı: 20%

değiştirildi: 07 Ağu '13, 09:44

%C3%B6zcanacar's gravatar image

özcanacar ♦♦
17.2k59183183

Entity sinifim bu

@Entity
    @Table(name = "userdeneme")
    public class UserDeneme implements java.io.Serializable {

private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        private String userName;
        private String password;
        private int userRole;
        private String userDesc;

public Long getId() {
            return id;
        }

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

public String getUserName() {
            return userName;
        }

public void setUserName(String userName) {
            this.userName = userName;
        }

public String getPassword() {
            return password;
        }

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

public int getUserRole() {
            return userRole;
        }

public void setUserRole(int userRole) {
            this.userRole = userRole;
        }

public String getUserDesc() {
            return userDesc;
        }

public void setUserDesc(String userDesc) {
            this.userDesc = userDesc;
        }
    }
(06 Ağu '13, 05:41) Mehmet KILIC Mehmet%20KILIC's gravatar image

Merhaba

Entity sinifini UserDeneme olarak belirlemissen, JQL in de de UserDeneme diye tanimla.

SELECT s FROM userdeneme s yerine SELECT s FROM UserDeneme s yaz.

Selamlar

permanent link

cevaplandı: 06 Ağu '13, 05:32

mahmut_can's gravatar image

mahmut_can ♦
2.9k62552
cevap kabul oranı: 67%

Merhaba Denedim ama halen ayni hatayi aliyorum.

(06 Ağu '13, 05:38) Mehmet KILIC Mehmet%20KILIC's gravatar image

UserDeneme entity olarak tanimladin mi?

@Entity / @Id sinifinda var mi? Persistence.xml de tanimliyor musun?

(06 Ağu '13, 05:39) mahmut_can ♦ mahmut_can's gravatar image
1

s.username yerine s.userName olmasi gerek

(06 Ağu '13, 05:44) mahmut_can ♦ mahmut_can's gravatar image

teşekkür ederim ya şu query'ler beni bu hatalar yüzünden öldürecek :) tekrar teşekküler İyi Çalışmalar

(06 Ağu '13, 05:48) Mehmet KILIC Mehmet%20KILIC's gravatar image
1

Eclipse kullaniyorsan, hibernte tools u tavsiye derim. bu tür hatalari aninda gösterir.

(06 Ağu '13, 05:49) mahmut_can ♦ mahmut_can's gravatar image

netbeans kullanıyorum ama bunun yüzünden geçebilirim tavsiyeniz için teşekürler :)

(06 Ağu '13, 05:50) Mehmet KILIC Mehmet%20KILIC's gravatar image
6 yorumdan 5 tanesi gösteriliyor hepsini göster
Cevabınız
toggle preview

powered by BitNami OSQA