Précédent   Forum des professionnels en informatique > Java > Général Java > Persistance > JPA
JPA Forum d'entraide sur l'API de persistance JPA (Java Persistence API)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 08/02/2012, 14h17   #1
Candidat au titre de Membre du Club
 
Homme Bassem Smida
Développeur Java
Inscription : septembre 2011
Messages : 30
Détails du profil
Informations personnelles :
Nom : Homme Bassem Smida
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : septembre 2011
Messages : 30
Points : 11
Points : 11
Par défaut Erreur "javax.ejb.EJBException"

Bonjour,

J'utilise l'utilitaire de génération des pages JSF CRUD de NetBeans 7.1 à partir d'un SGBD Postgres.

La génération se passe bien mais lorsque je lance l'application web j'obtiens l'exception suivante:
Citation:
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy287.findRange(Unknown Source)
at dao.__EJB31_Generated__DistributeurFacade__Intf____Bean__.findRange(Unknown Source)
at mbeans.DistributeurController$1.createPageDataModel(DistributeurController.java:58)
at mbeans.DistributeurController.getItems(DistributeurController.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:116)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.parser.AstEqual.getValue(AstEqual.java:54)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:413)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1750)
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:1756)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
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 javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
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 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERREUR: les r?f?rences entre bases de donn?es ne sont pas impl?ment?es : ? bitaka.public.distributeur ?
Position : 124
Error Code: 0
Call: SELECT clevd AS a1, actif AS a2, activite AS a3, garantie AS a4, raison_soc AS a5, tva AS a6, type AS a7, n_cin AS a8 FROM Bitaka.public.distributeur LIMIT ? OFFSET ?
bind => [2 parameters bound]
Query: ReadAllQuery(referenceClass=Distributeur sql="SELECT clevd AS a1, actif AS a2, activite AS a3, garantie AS a4, raison_soc AS a5, tva AS a6, type AS a7, n_cin AS a8 FROM Bitaka.public.distributeur LIMIT ? OFFSET ?")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2551)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:418)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1097)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at dao.AbstractFacade.findRange(AbstractFacade.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
... 56 more
Caused by: org.postgresql.util.PSQLException: ERREUR: les r?f?rences entre bases de donn?es ne sont pas impl?ment?es : ? bitaka.public.distributeur ?
Position : 124
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)
... 100 more
Voila mon persistence.xml
Code :
1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="WebApplication14PU" transaction-type="JTA">
    <jta-data-source>kaka</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties/>
  </persistence-unit>
</persistence>
Quelqu'un saurait-il me dire d'où vient le problème ?

Merci d'avance pour votre aide.
Linos1003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/02/2012, 09h08   #2
Expert Confirmé
 
Homme
Ingénieur développement logiciels
Inscription : juin 2007
Messages : 2 261
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels

Informations forums :
Inscription : juin 2007
Messages : 2 261
Points : 2 582
Points : 2 582
A mon avis t'es en train de faire un mélange de requêtes natives et requêtes objet dans la même requête. Peut-on voir ton entité Distributeur ?
Quel type de requête veux tu faire ? Du natif ou objet ? Peut-on voir comment invoques tu ta requête ?
DevServlet est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 14h30   #3
Candidat au titre de Membre du Club
 
Homme Bassem Smida
Développeur Java
Inscription : septembre 2011
Messages : 30
Détails du profil
Informations personnelles :
Nom : Homme Bassem Smida
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : septembre 2011
Messages : 30
Points : 11
Points : 11
Citation:
Envoyé par DevServlet Voir le message
A mon avis t'es en train de faire un mélange de requêtes natives et requêtes objet dans la même requête. Peut-on voir ton entité Distributeur ?
Quel type de requête veux tu faire ? Du natif ou objet ? Peut-on voir comment invoques tu ta requête ?
Voilà la classe distributeur
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package entity;
 
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
 
/**
 *
 * @author Megatrix
 */
@Entity
@Table(name = "distributeur", catalog = "Bitaka", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Distributeur.findAll", query = "SELECT d FROM Distributeur d"),
    @NamedQuery(name = "Distributeur.findByClevd", query = "SELECT d FROM Distributeur d WHERE d.clevd = :clevd"),
    @NamedQuery(name = "Distributeur.findByType", query = "SELECT d FROM Distributeur d WHERE d.type = :type"),
    @NamedQuery(name = "Distributeur.findByGarantie", query = "SELECT d FROM Distributeur d WHERE d.garantie = :garantie"),
    @NamedQuery(name = "Distributeur.findByRaisonSoc", query = "SELECT d FROM Distributeur d WHERE d.raisonSoc = :raisonSoc"),
    @NamedQuery(name = "Distributeur.findByActivite", query = "SELECT d FROM Distributeur d WHERE d.activite = :activite"),
    @NamedQuery(name = "Distributeur.findByActif", query = "SELECT d FROM Distributeur d WHERE d.actif = :actif"),
    @NamedQuery(name = "Distributeur.findByTva", query = "SELECT d FROM Distributeur d WHERE d.tva = :tva")})
public class Distributeur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "clevd", nullable = false)
    private Integer clevd;
    @Size(max = 70)
    @Column(name = "type", length = 70)
    private String type;
    @Size(max = 160)
    @Column(name = "garantie", length = 160)
    private String garantie;
    @Size(max = 100)
    @Column(name = "raison_soc", length = 100)
    private String raisonSoc;
    @Size(max = 100)
    @Column(name = "activite", length = 100)
    private String activite;
    @Column(name = "actif")
    private Boolean actif;
    @Size(max = 255)
    @Column(name = "tva", length = 255)
    private String tva;
    @JoinColumn(name = "n_cin", referencedColumnName = "n_cin")
    @ManyToOne
    private Identite nCin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clevd")
    private List<Revendeur> revendeurList;
 
    public Distributeur() {
    }
 
    public Distributeur(Integer clevd) {
        this.clevd = clevd;
    }
 
    public Integer getClevd() {
        return clevd;
    }
 
    public void setClevd(Integer clevd) {
        this.clevd = clevd;
    }
 
    public String getType() {
        return type;
    }
 
    public void setType(String type) {
        this.type = type;
    }
 
    public String getGarantie() {
        return garantie;
    }
 
    public void setGarantie(String garantie) {
        this.garantie = garantie;
    }
 
    public String getRaisonSoc() {
        return raisonSoc;
    }
 
    public void setRaisonSoc(String raisonSoc) {
        this.raisonSoc = raisonSoc;
    }
 
    public String getActivite() {
        return activite;
    }
 
    public void setActivite(String activite) {
        this.activite = activite;
    }
 
    public Boolean getActif() {
        return actif;
    }
 
    public void setActif(Boolean actif) {
        this.actif = actif;
    }
 
    public String getTva() {
        return tva;
    }
 
    public void setTva(String tva) {
        this.tva = tva;
    }
 
    public Identite getNCin() {
        return nCin;
    }
 
    public void setNCin(Identite nCin) {
        this.nCin = nCin;
    }
 
    @XmlTransient
    public List<Revendeur> getRevendeurList() {
        return revendeurList;
    }
 
    public void setRevendeurList(List<Revendeur> revendeurList) {
        this.revendeurList = revendeurList;
    }
 
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (clevd != null ? clevd.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 Distributeur)) {
            return false;
        }
        Distributeur other = (Distributeur) object;
        if ((this.clevd == null && other.clevd != null) || (this.clevd != null && !this.clevd.equals(other.clevd))) {
            return false;
        }
        return true;
    }
 
    @Override
    public String toString() {
        return "entity.Distributeur[ clevd=" + clevd + " ]";
    }
}
Linos1003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 14h52   #4
Expert Confirmé
 
Homme
Ingénieur développement logiciels
Inscription : juin 2007
Messages : 2 261
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels

Informations forums :
Inscription : juin 2007
Messages : 2 261
Points : 2 582
Points : 2 582
Et laquelle des NamedQuery as-tu invoquée ? Peut-on voir le bout de code lançant la requête ?
DevServlet est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 15h08   #5
Candidat au titre de Membre du Club
 
Homme Bassem Smida
Développeur Java
Inscription : septembre 2011
Messages : 30
Détails du profil
Informations personnelles :
Nom : Homme Bassem Smida
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : septembre 2011
Messages : 30
Points : 11
Points : 11
Citation:
Envoyé par DevServlet Voir le message
Et laquelle des NamedQuery as-tu invoquée? peut-on voir le bout de code lançant la requête?
En fait, je l'ai invoqué à partir d'une page JSF.
Voila la page, dès que je clique sur le lien qui l’amène, l'exception se déclenche.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
 
    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListDistributeurTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:outputText escape="false" value="#{bundle.ListDistributeurEmpty}" rendered="#{distributeurController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{distributeurController.items.rowCount > 0}">
                    <h:outputText value="#{distributeurController.pagination.pageFirstItem + 1}..#{distributeurController.pagination.pageLastItem + 1}/#{distributeurController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{distributeurController.previous}" value="#{bundle.Previous} #{distributeurController.pagination.pageSize}" rendered="#{distributeurController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{distributeurController.next}" value="#{bundle.Next} #{distributeurController.pagination.pageSize}" rendered="#{distributeurController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{distributeurController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_clevd}"/>
                            </f:facet>
                            <h:outputText value="#{item.clevd}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_type}"/>
                            </f:facet>
                            <h:outputText value="#{item.type}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_garantie}"/>
                            </f:facet>
                            <h:outputText value="#{item.garantie}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_raisonSoc}"/>
                            </f:facet>
                            <h:outputText value="#{item.raisonSoc}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_activite}"/>
                            </f:facet>
                            <h:outputText value="#{item.activite}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_actif}"/>
                            </f:facet>
                            <h:outputText value="#{item.actif}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_tva}"/>
                            </f:facet>
                            <h:outputText value="#{item.tva}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListDistributeurTitle_NCin}"/>
                            </f:facet>
                            <h:outputText value="#{item.NCin}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{distributeurController.prepareView}" value="#{bundle.ListDistributeurViewLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{distributeurController.prepareEdit}" value="#{bundle.ListDistributeurEditLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{distributeurController.destroy}" value="#{bundle.ListDistributeurDestroyLink}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{distributeurController.prepareCreate}" value="#{bundle.ListDistributeurCreateLink}"/>
                <br />
                <br />
                <h:commandLink value="#{bundle.ListDistributeurIndexLink}" action="/index" immediate="true" />
            </h:form>
        </ui:define>
    </ui:composition>
</html>
DistributeurController
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package web;
 
import entity.Distributeur;
import web.util.JsfUtil;
import web.util.PaginationHelper;
import session.DistributeurFacade;
 
import java.io.Serializable;
import java.util.ResourceBundle;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
 
@ManagedBean(name = "distributeurController")
@SessionScoped
public class DistributeurController implements Serializable {
 
    private Distributeur current;
    private DataModel items = null;
    @EJB
    private session.DistributeurFacade ejbFacade;
    private PaginationHelper pagination;
    private int selectedItemIndex;
 
    public DistributeurController() {
    }
 
    public Distributeur getSelected() {
        if (current == null) {
            current = new Distributeur();
            selectedItemIndex = -1;
        }
        return current;
    }
 
    private DistributeurFacade getFacade() {
        return ejbFacade;
    }
 
    public PaginationHelper getPagination() {
        if (pagination == null) {
            pagination = new PaginationHelper(10) {
 
                @Override
                public int getItemsCount() {
                    return getFacade().count();
                }
 
                @Override
                public DataModel createPageDataModel() {
                    return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()}));
                }
            };
        }
        return pagination;
    }
 
    public String prepareList() {
        recreateModel();
        return "List";
    }
 
    public String prepareView() {
        current = (Distributeur) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return "View";
    }
 
    public String prepareCreate() {
        current = new Distributeur();
        selectedItemIndex = -1;
        return "Create";
    }
 
    public String create() {
        try {
            getFacade().create(current);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DistributeurCreated"));
            return prepareCreate();
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            return null;
        }
    }
 
    public String prepareEdit() {
        current = (Distributeur) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return "Edit";
    }
 
    public String update() {
        try {
            getFacade().edit(current);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DistributeurUpdated"));
            return "View";
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            return null;
        }
    }
 
    public String destroy() {
        current = (Distributeur) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        performDestroy();
        recreatePagination();
        recreateModel();
        return "List";
    }
 
    public String destroyAndView() {
        performDestroy();
        recreateModel();
        updateCurrentItem();
        if (selectedItemIndex >= 0) {
            return "View";
        } else {
            // all items were removed - go back to list
            recreateModel();
            return "List";
        }
    }
 
    private void performDestroy() {
        try {
            getFacade().remove(current);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DistributeurDeleted"));
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
        }
    }
 
    private void updateCurrentItem() {
        int count = getFacade().count();
        if (selectedItemIndex >= count) {
            // selected index cannot be bigger than number of items:
            selectedItemIndex = count - 1;
            // go to previous page if last page disappeared:
            if (pagination.getPageFirstItem() >= count) {
                pagination.previousPage();
            }
        }
        if (selectedItemIndex >= 0) {
            current = getFacade().findRange(new int[]{selectedItemIndex, selectedItemIndex + 1}).get(0);
        }
    }
 
    public DataModel getItems() {
        if (items == null) {
            items = getPagination().createPageDataModel();
        }
        return items;
    }
 
    private void recreateModel() {
        items = null;
    }
 
    private void recreatePagination() {
        pagination = null;
    }
 
    public String next() {
        getPagination().nextPage();
        recreateModel();
        return "List";
    }
 
    public String previous() {
        getPagination().previousPage();
        recreateModel();
        return "List";
    }
 
    public SelectItem[] getItemsAvailableSelectMany() {
        return JsfUtil.getSelectItems(ejbFacade.findAll(), false);
    }
 
    public SelectItem[] getItemsAvailableSelectOne() {
        return JsfUtil.getSelectItems(ejbFacade.findAll(), true);
    }
 
    @FacesConverter(forClass = Distributeur.class)
    public static class DistributeurControllerConverter implements Converter {
 
        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
            if (value == null || value.length() == 0) {
                return null;
            }
            DistributeurController controller = (DistributeurController) facesContext.getApplication().getELResolver().
                    getValue(facesContext.getELContext(), null, "distributeurController");
            return controller.ejbFacade.find(getKey(value));
        }
 
        java.lang.Integer getKey(String value) {
            java.lang.Integer key;
            key = Integer.valueOf(value);
            return key;
        }
 
        String getStringKey(java.lang.Integer value) {
            StringBuffer sb = new StringBuffer();
            sb.append(value);
            return sb.toString();
        }
 
        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
            if (object == null) {
                return null;
            }
            if (object instanceof Distributeur) {
                Distributeur o = (Distributeur) object;
                return getStringKey(o.getClevd());
            } else {
                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + DistributeurController.class.getName());
            }
        }
    }
}
DistributeurFacede
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package session;
 
import entity.Distributeur;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
 
@Stateless
public class DistributeurFacade extends AbstractFacade<Distributeur> {
    @PersistenceContext(unitName = "WebApplication1PU")
    private EntityManager em;
 
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
 
    public DistributeurFacade() {
        super(Distributeur.class);
    }
 
}
AbstractFacade
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package session;
 
import java.util.List;
import javax.persistence.EntityManager;
 
/**
 *
 * @author Megatrix
 */
public abstract class AbstractFacade<T> {
    private Class<T> entityClass;
 
    public AbstractFacade(Class<T> entityClass) {
        this.entityClass = entityClass;
    }
 
    protected abstract EntityManager getEntityManager();
 
    public void create(T entity) {
        getEntityManager().persist(entity);
    }
 
    public void edit(T entity) {
        getEntityManager().merge(entity);
    }
 
    public void remove(T entity) {
        getEntityManager().remove(getEntityManager().merge(entity));
    }
 
    public T find(Object id) {
        return getEntityManager().find(entityClass, id);
    }
 
    public List<T> findAll() {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        cq.select(cq.from(entityClass));
        return getEntityManager().createQuery(cq).getResultList();
    }
 
    public List<T> findRange(int[] range) {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        cq.select(cq.from(entityClass));
        javax.persistence.Query q = getEntityManager().createQuery(cq);
        q.setMaxResults(range[1] - range[0]);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }
 
    public int count() {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        javax.persistence.criteria.Root<T> rt = cq.from(entityClass);
        cq.select(getEntityManager().getCriteriaBuilder().count(rt));
        javax.persistence.Query q = getEntityManager().createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }
}
Linos1003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2012, 15h38   #6
Expert Confirmé
 
Homme
Ingénieur développement logiciels
Inscription : juin 2007
Messages : 2 261
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels

Informations forums :
Inscription : juin 2007
Messages : 2 261
Points : 2 582
Points : 2 582
Essaye d'expliquer de façon concise ton problème, il n'y a pas d'intérêt à mettre tout le code de ton projet.

Quelle est la méthode exacte de ton controller déclenchant l'exception ?
DevServlet est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h07.


 
 
 
 
Partenaires

Hébergement Web