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

Struts 1 Java Discussion :

tree struts : java.lang.ClassCastException


Sujet :

Struts 1 Java

  1. #1
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 11
    Par défaut tree struts : java.lang.ClassCastException
    salut

    j'ai rencontrer lors de la creation de mon arbre un probleme d'execution
    voila la trace d'erreur :



    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
    java.lang.ClassCastException: com.cap.tree.action.ProductTreeBrowseAction
    	at org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:280)
    	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
    	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
    	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
    	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    	at java.lang.Thread.run(Unknown Source)
    si qlq a deja rencontrer un probleme pareil ou il a une idée peu m'aidé

    merci d'avance

  2. #2
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Ben, comme l'indique le message d'erreur, c'est un problème de cast.
    Avec le code de l'Action ProductTreeBrowseAction, on pourra peut-être t'aider.

  3. #3
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 11
    Par défaut
    Salut

    Merci pour votre interet
    voila mon Action

    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
    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
    package com.cap.tree.action;
     
     
    import java.util.Hashtable;
    import com.cc.framework.adapter.struts.ActionContext;
    import com.cc.framework.adapter.struts.FormActionContext;
    import com.cc.framework.common.Algorithm;
    import com.cc.framework.common.CheckState;
    import com.cc.framework.ui.control.ControlActionContext;
    import com.cc.framework.ui.control.TreeControl;
    import com.cc.framework.ui.model.Checkable;
    import com.cc.framework.ui.model.TreeNodeDataModel;
    import com.cc.framework.util.TreeHelp;
    import com.cc.sample.action.CCAction;
    import com.cc.sample.common.Forwards;
    import com.cc.sample.common.Messages;
    import com.cc.sample.dbaccess.DBProduct;
    import com.cc.sample.presentation.dsp.ProductGroupDsp;
     
    /**
     * This Class is responsible to instantiate our TreeControl.
     * This Class also implements the Methode which are called if
     * an Event in our TreeControl occurs.
     *
     * @author              <a href="mailto:gschulz@scc-gmbh.com">Gernot Schulz</a>
     * @version     $Revision: 1.7 $
     */
    public class ProductTreeBrowseAction extends CCAction {
     
    	/**
             * The name of the bean for our control in the session
             */
    	protected String BEANNAME;
     
    	/**
             * Inner class which checks the checked items
             */
    	private static class CollectCheckedAlg implements Algorithm {
     
    		/**
                     * Collection for the checked items found
                     */
    		private Hashtable items = new Hashtable();
     
    		/**
                     * Constructor
                     */
    		public CollectCheckedAlg() {
     
    			super();
    		}
     
    		/**
                     * @see com.cc.framework.common.Algorithm#execute(String uniqueId, Object obj)
                     */
    		public boolean execute(String uniqueId, Object obj) throws Exception {
    						if (obj instanceof Checkable) {
    				TreeNodeDataModel node = (TreeNodeDataModel) obj;
    				Checkable checkable = (Checkable) obj;
     
    				if (checkable.getCheckState() == CheckState.CHECKED.toInt()) {
    					items.put(node.getUniqueKey(), obj);								
    				}
    			}
     
    			return true;
    		}
     
    		/**
                     * Returns the checked items
                     */
    		public Hashtable getcheckedItems() {
    			return items;
    		}
    	}
     
     
     
    	// ----------------------------------
    	//           methods
    	// ----------------------------------
     
    	/**
             * Constructor for StocksBrowseAction.
             */
    	public ProductTreeBrowseAction() {
    		super();		
    		BEANNAME = "products";
    	}
     
    	/**
             * @see com.cc.framework.adapter.struts.FrameworkAction#doExecute(com.cc.framework.adapter.struts.ActionContext)
             */
    	public void doExecute(ActionContext ctx) throws Exception {
     
    		try {
    			refreshTree(ctx);
    		} catch (Throwable t) {
    			log.error("Error", t);
     
    			ctx.addError(Messages.ERROR_INIT_FORMBEAN, t);
    		}
     
    		// Dialog anzeigen
    		ctx.forwardToInput();		
    	}
     
    	/**
             * Initializ the Tree with the Display-Data
             * @param               ctx             ActionContext
             * @throws      java.lang.Exception
             */
    	private void refreshTree(ActionContext ctx) throws Exception {
     
    		// In this Example we check if the Tree already
    		// exists, so we do not populte it again.
    		// So the Tree does not collaps if we reenter the Page
    		if (null != ctx.session().getAttribute(BEANNAME)) {
    			return;
    		} 
     
    		// first we get the Data for our Tree
    		ProductGroupDsp data = DBProduct.fetch();
     
    		// secondly create the TreeControl and populate it
    		// with the Data to display
    		TreeControl products = new TreeControl();
    		products.setDataModel(data);
     
    		// third put the TreeControl into the Session-Object.
    		// Our Control is a statefull Object.
    		// Normaly  you can use an Objectmanager or an other
    		// workflow Component that manage the Livecyle of the
    		// our TreeControl-Object.
    		ctx.session().setAttribute(BEANNAME, products);
    	}
     
     
    	// ------------------------------------------------
    	//          Tree-Control  Event Handler
        // ------------------------------------------------
     
    	/**
             * This Method is called when the TreeLabel is clicked 
             * In our Example we switch to the DetailView, which shows
             * more Information about the node.
             * @param       ctx             ControlActionContext
             * @param       key     UniqueKey, as created in the Datamodel (e.g. the Primarykey)
             */
    	public void  products_onDrilldown(ControlActionContext ctx, String key) throws Exception {
     
    		// highlight the node
    		((TreeControl) ctx.control()).select(key);
     
    		ctx.forwardByName(Forwards.DRILLDOWN, key);
    	}
     
    	/**
             * This Method is call if a Node with an unknown number of 
             * Childs is clicked.
             * @param       ctx             ControlActionContext
             * @param       key     UniqueKey, as created in the Datamodel (e.g. the Primarykey)
             */
    	public void products_onExpandEx(ControlActionContext ctx, String key) throws Exception {
    			}
     
    	/**
             * This Method is call if the save button is clicked
             * @param ctx FormActionContext
             */
    	public void save_onClick(FormActionContext ctx) throws Exception {
     
    		Hashtable items = new Hashtable(); 
     
    		try {
     
    			TreeControl control = (TreeControl) ctx.session().getAttribute(BEANNAME);
     
    			CollectCheckedAlg collector = new CollectCheckedAlg();
     
    			TreeHelp.iterateNodes((TreeNodeDataModel)control.getDataModel(), collector);
     
    			items = collector.getcheckedItems();
     
    			// process items
     
    		} catch (Throwable t) {
    			log.error("Error", t);
    			ctx.addError(Messages.ERROR, t);
    		}
     
    		if (!ctx.hasErrors()) {
    			ctx.addGlobalMessage(Messages.MESSAGE, "Items checked: " + items.size());
    		}
     
    		// back to the jsp
    		ctx.forwardToInput();
    	}
     
     
     
     
    }

    Merci d'avance

  4. #4
    Membre régulier
    Inscrit en
    Mai 2007
    Messages
    11
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 11
    Par défaut
    salut

    j'attend tjr de votre aide c urgent

    merci d'avance

  5. #5
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Je ne connais pas cet API mais ici, il y a quelque chose qui me choque :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    			TreeNodeDataModel node = (TreeNodeDataModel) obj;
    			Checkable checkable = (Checkable) obj;
    tu castes le même objet par deux classes différentes.

Discussions similaires

  1. pb java.lang.ClassCastException: $Proxy84
    Par chakala dans le forum Wildfly/JBoss
    Réponses: 10
    Dernier message: 15/03/2007, 14h21
  2. JSP javamail java.lang.ClassCastException
    Par itr dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 14/06/2006, 17h01
  3. [EJB3] java.lang.ClassCastException
    Par n00noors dans le forum Java EE
    Réponses: 9
    Dernier message: 21/02/2006, 15h06
  4. Réponses: 16
    Dernier message: 10/01/2006, 22h02
  5. [Struts] java.lang.NoClassDefFoundError
    Par Zephoria dans le forum Struts 1
    Réponses: 2
    Dernier message: 08/02/2005, 10h51

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