bonjour a tous
Nous souhaitons creer une application utilisant JPA pour la persistance, EJB3 pour la couche metier, et JSF pour le coté client Web
Les outil que nous utilisons
JOSS 4.2.1
MySQL 5
JDK1.5
Eclipse Ganymede
JSF 1.2
Lors de l'execution nous avons l'erreur suivante:
faces-config.xmlCode:
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 javax.servlet.ServletException: javax.faces.FacesException: Error performing conversion of value ' of type class java.lang.String to type class entity.Article for managed bean articleBean. javax.faces.webapp.FacesServlet.service(FacesServlet.java:256) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) cause mère javax.faces.FacesException: javax.faces.FacesException: Error performing conversion of value ' of type class java.lang.String to type class entity.Article for managed bean articleBean. com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:537) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45) org.apache.el.parser.AstValue.getTarget(AstValue.java:42) org.apache.el.parser.AstValue.invoke(AstValue.java:127) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91) javax.faces.component.UICommand.broadcast(UICommand.java:383) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) cause mère javax.faces.FacesException: Error performing conversion of value ' of type class java.lang.String to type class entity.Article for managed bean articleBean. com.sun.faces.config.ManagedBeanFactoryImpl.getConvertedValueConsideringPrimitives(ManagedBeanFactoryImpl.java:971) com.sun.faces.config.ManagedBeanFactoryImpl.setPropertiesIntoBean(ManagedBeanFactoryImpl.java:644) com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:317) com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:527) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45) org.apache.el.parser.AstValue.getTarget(AstValue.java:42) org.apache.el.parser.AstValue.invoke(AstValue.java:127) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91) javax.faces.component.UICommand.broadcast(UICommand.java:383) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de JBossWeb/2.0.1.GA.
le ManagedBeanCode:
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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <managed-bean> <managed-bean-name>articleBean</managed-bean-name> <managed-bean-class>managebean.ArticleBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>article</property-name> <property-class>entity.Article</property-class> <value></value> <!--<property-class>java.lang.String</property-class>--> </managed-property> <managed-property> <property-name>description</property-name> <property-class>java.lang.String</property-class> <value></value> </managed-property> </managed-bean> <navigation-rule> <display-name>Test</display-name> <from-view-id>/Test.jsp</from-view-id> <navigation-case> <from-action>#{articleBean.actionbouton}</from-action> <from-outcome>REUSSI</from-outcome> <to-view-id>/resultat.jsp</to-view-id> </navigation-case> </navigation-rule> </faces-config>
la premiere page JSPCode:
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 package managebean; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import service.Gestion_articleRemote; import entity.Article; public class ArticleBean { private Article article; private String description; public String getDescription() { description=article.getDescriptionArticle(); return description; } public void setDescription(String description) { this.description = description; } public Article getArticle() throws NamingException { return article; } public void setArticle(Article article) { this.article = article; } public String actionbouton() throws NamingException { Gestion_articleRemote remote = context(); article = remote.afficherArticle("toto"); return "REUSSI"; } public Gestion_articleRemote context() throws NamingException { final Context context = new InitialContext(); Gestion_articleRemote remote = (Gestion_articleRemote) context .lookup("Gestion_article/remote"); return remote; } private static Context InitialContext() throws NamingException { return new InitialContext(); } }
la page JSP ou le resultat doit s'afficherCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ 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-1"> <title>article</title> </head> <body> <f:view> <h:form> <h:commandButton action="#{articleBean.actionbouton}" id="btn1" value="action"></h:commandButton> </h:form> </f:view> </body> </html>
la SessionBean que l'on souhaite appeler dans le ManageBean JSFCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ 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-1"> <title>Insert title here</title> </head> <body> <f:view> <h:outputText id="txt1" value="#{articleBean.description}"></h:outputText> </f:view> </body> </html>
help please pouvez vous nous aiderCode:
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 package service; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import entity.Article; @Stateless public class Gestion_article implements Gestion_articleRemote, Gestion_articleLocal { @PersistenceContext (unitName="Projet_ISP") EntityManager isp; public Article afficherArticle(String id_article) { Article art; art=isp.find(Article.class, id_article); return art; } public void creerArticle(Article article) { isp.persist(article); } }
merci d'avance