IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

Probleme avec JSP


Sujet :

Servlets/JSP Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 6
    Par défaut Probleme avec JSP
    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:
    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
    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.
    faces-config.xml
    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
    <?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>
    le ManagedBean
    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
    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 premiere page JSP
    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
     
    <%@ 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 page JSP ou le resultat doit s'afficher
    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
    <%@ 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>
    la SessionBean que l'on souhaite appeler dans le ManageBean JSF
    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
    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);
     
    	}
    }
    help please pouvez vous nous aider
    merci d'avance

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    383
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 383
    Par défaut
    Est-ce que le problème ne viendrait pas de la configuration

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    <managed-property>
    			<property-name>article</property-name>
    			<property-class>entity.Article</property-class>
    			<value></value>
    			<!--<property-class>java.lang.String</property-class>-->
    </managed-property>
    Où si tu mets :
    il va essayer d'initialiser l'article avec une chaine vide ?

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 6
    Par défaut
    si j'enleve les balise <value></value>
    il me met une erreur sur la balise <managed-property>

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    383
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 383
    Par défaut
    Essaye de mettre <null-value/> ?

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 6
    Par défaut
    oui c'est ce que je venais d'essayer et effectivement ca m'a enlever cette erreur mais une nouvelle est apparue: nullpointeurexception

  6. #6
    Membre du Club
    Inscrit en
    Octobre 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Octobre 2008
    Messages : 10
    Par défaut Pouquoi tu te sent obliger de metre un <managed-property>
    Le <managed-property> c'est pour initialiser les champs du managed-bean ici tu en a pas besoin parce que tu na pas de valeur a initialiser il faut juste l'enlever

Discussions similaires

  1. probleme avec <jsp:include
    Par riadhhwajdii dans le forum JSF
    Réponses: 1
    Dernier message: 15/07/2009, 14h35
  2. probleme avec jsp
    Par chady dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 04/06/2009, 13h29
  3. probleme avec jsp:useBean
    Par hypothese dans le forum Taglibs
    Réponses: 2
    Dernier message: 13/08/2008, 16h43
  4. probleme avec jsp
    Par crossmen dans le forum Struts 1
    Réponses: 1
    Dernier message: 15/05/2007, 21h02
  5. problem avec jsp téléchargement fichier
    Par ramssis20 dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 30/01/2007, 12h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo