Bonjour,
je développe une petite application web en Java EE avec un serveur Payara local.
Je suis confronté à une erreur dont je ne trouve pas la solution :/
L'ensemble de mes entités sont créées au lancement de l'application.
Je possède donc une table Etudiant permettant tout simplement de représenter un étudiant, j'ai également une classe Séminaire ayant pour but de créer des séminaires auxquels les étudiants pourront participer, il y a donc une 3ème créée afin de relier l'identifiant d'un étudiant à celui d'un séminaire.
Pour créer cette 3ème table, j'utilise un @JoinTable dans ma classe Seminaire.
(Les entités sont créées à l'aide du persistence.xml)
Voici le code de la classe Seminaire :
Voici le code de la classe SeminaireDAO (Application est développée en MVC) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package entities; @Entity public class Seminaire implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "SEC_ID") private Integer id; private String nomSeminaire; private String date; private String section; @ManyToMany(cascade=CascadeType.PERSIST) @JoinTable(name = "SEMINAIRE_ETUDIANT", joinColumns = { @JoinColumn(name = "SEC_ID") }, inverseJoinColumns = { @JoinColumn(name = "ETU_ID") }) private Set<Etudiant> etudiants = new HashSet<>(); }
La méthode etudiantInscrit vérifiera simplement si l'étudiant est déja inscrit ou non au séminaire sélectionné mais voila le problème est qu'ici la table Seminaire_Etudiant n'est pas reconnue (Du moins de ce que je pense avoir compris dans les erreurs).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package dao; @Stateless @LocalBean public class DAOSeminaire implements Serializable { @PersistenceContext(unitName="groupeA8") private EntityManager em; //Requête pour vérifier si l'étudiant est déja inscrit au séminaire public int etudiantInscrit(String idSec, String idEtu) { Query query = em.createQuery("SELECT COUNT(u) FROM Seminaire_Etudiant u WHERE u.SEC_ID = :idSec AND u.ETU_ID = :idEtu"); query.setParameter("idSec", idSec); query.setParameter("idEtu", idEtu); return ((Number) query.getSingleResult()).intValue(); } }
Voici donc les erreurs générées :
J'espère vous avoir donner assez d'informations pour pouvoir répondre à ce problème, merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 javax.ejb.EJBTransactionRolledbackException at com.sun.ejb.containers.BaseContainer.mapLocal3xException(BaseContainer.java:2414) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2196) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2117) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:90) at com.sun.proxy.$Proxy298.etudiantInscrit(Unknown Source) at dao.__EJB31_Generated__DAOSeminaire__Intf____Bean__.etudiantInscrit(Unknown Source) at sessionejb.GestionSeminaireEJB.etudiantInscrit(GestionSeminaireEJB.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:589) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:409) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4981) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:657) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:836) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:609) 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.GeneratedMethodAccessor142.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:609) at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72) at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52) at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:374) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4953) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4941) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:90) at com.sun.proxy.$Proxy288.etudiantInscrit(Unknown Source) at sessionejb.__EJB31_Generated__GestionSeminaireEJB__Intf____Bean__.etudiantInscrit(Unknown Source) at controller.SeminaireController.test(SeminaireController.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at javax.el.ELUtil.invokeMethod(ELUtil.java:263) at javax.el.BeanELResolver.invoke(BeanELResolver.java:494) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:215) at com.sun.el.parser.AstValue.getValue(AstValue.java:135) at com.sun.el.parser.AstValue.getValue(AstValue.java:203) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73) at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2019) at net.bootsfaces.component.dataTable.DataTableRenderer.generateBody(DataTableRenderer.java:285) at net.bootsfaces.component.dataTable.DataTableRenderer.encodeBegin(DataTableRenderer.java:137) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:540) at javax.faces.component.UIData.encodeBegin(UIData.java:1153) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1644) at javax.faces.render.Renderer.encodeChildren(Renderer.java:152) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:566) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1647) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170) at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199) at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:755) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:575) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) at java.lang.Thread.run(Thread.java:748) Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:664) at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:509) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4761) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2147) ... 99 more Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [SELECT COUNT(u) FROM Seminaire_Etudiant u WHERE u.SEC_ID = :idSec AND u.ETU_ID = :idEtu]. [21, 39] The abstract schema type 'Seminaire_Etudiant' is unknown. [48, 56] The state field path 'u.SEC_ID' cannot be resolved to a valid type. [70, 78] The state field path 'u.ETU_ID' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1746) at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:456) at dao.DAOSeminaire.etudiantInscrit(DAOSeminaire.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:589) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:409) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4981) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:657) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:836) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:609) 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.GeneratedMethodAccessor142.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:609) at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72) at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52) at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:895) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:835) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:374) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4953) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4941) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212) ... 97 more Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.4.payara-p2): org.eclipse.persistence.exceptions.JPQLException Exception Description: Problem compiling [SELECT COUNT(u) FROM Seminaire_Etudiant u WHERE u.SEC_ID = :idSec AND u.ETU_ID = :idEtu]. [21, 39] The abstract schema type 'Seminaire_Etudiant' is unknown. [48, 56] The state field path 'u.SEC_ID' cannot be resolved to a valid type. [70, 78] The state field path 'u.ETU_ID' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:349) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:118) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:104) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:88) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1744) ... 128 more
Partager