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

Spring Java Discussion :

Injection de dependance [Framework]


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Ingénieur étude et dévellopement
    Inscrit en
    Février 2009
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Ingénieur étude et dévellopement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2009
    Messages : 13
    Par défaut Injection de dependance
    Bonjour,
    Actuellement, je travaille sur un projet qui utilise le framework spring 2.5.
    Le projet est un logiciel dont les beans sont instancier par IOC de spring.
    J'arrive a effectuer des injection de classe dans des beans qui possede des tags @Component. Cependant j'arrive pas à injecter des beans dans de simple classe.

    En gros j'arrive à un injecter un bean dans un bean mais j'arrive pas a injecter un bean dans une classe.
    voici la classe qui fonctionne :
    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
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
     
    package gui;
     
     
    import entity.DemiOrbite;
    import entity.Plan;
    import entity.Telecommande1;
    import gui.composant.CustomMutableTreeNode;
    import gui.composant.MenuBar;
    import gui.composant.TextAreaAppender;
    import gui.composant.listeners.TreeSelectionListener;
     
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Properties;
     
    import javax.annotation.Resource;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
     
    import metier.plan.GestionnairePlan;
     
    import org.apache.log4j.Logger;
    import org.apache.log4j.PropertyConfigurator;
    import org.springframework.stereotype.Component;
     
     
     
     
     
    @SuppressWarnings("serial")
    @Component(value="mainUi")
    public class MainUi extends JFrame{
    	/**
             * Logger de la classe
             */
    	private Logger LOGGER = Logger.getLogger(MainUi.class);
     
    	/**
             * . le Panneau avec cesure verticale (Arbre/Info)
             */
    	private JSplitPane splitPanelPrincipalInfo = null;
     
    	/**
             * . le panneau avec cesure horizontale (panneau principal/panneau
             * d'informations)
             */
    	private JSplitPane splitPanelTreeDescription = null;
     
    	/**
             * . Le Panneau information
             */
    	private JTextArea informations = null;
     
    	/**
             * 
             */
    	@Resource(name="gestionnairePlan")
    	private GestionnairePlan gestionnairePlan; 
     
    	private JTree arbre;
     
    	private DefaultTreeModel root;
     
     
    	public void initialization(){
    		LOGGER.info("Initialisation de la fenêtre principale");
    		this.setTitle("Gtid for Taranis");
    		MenuBar menu = new MenuBar();
    		menu.initialization();
    		this.setJMenuBar(menu);
    		this.setSize(800, 600);
    		this.setContentPane(getSplitPanelPrincipalInfo());
    		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		this.setVisible(true);
    	}
     
     
    	public JSplitPane getSplitPanelPrincipalInfo() {
    		LOGGER.debug("Création du panel principal");
    		if (splitPanelPrincipalInfo == null) {
    			splitPanelPrincipalInfo = new JSplitPane();
    			splitPanelPrincipalInfo.setOrientation(JSplitPane.VERTICAL_SPLIT);
    			splitPanelPrincipalInfo.setBottomComponent(getInformations());
    			splitPanelPrincipalInfo.setTopComponent(getSplitPanelTreeDescription());
    			splitPanelPrincipalInfo.setOneTouchExpandable(true);
    			splitPanelPrincipalInfo.setDividerLocation(430);
    			splitPanelPrincipalInfo.setSize(700, 600);
    		}
     
    		return splitPanelPrincipalInfo;
    	}
     
     
     
     
     
    	public void setSplitPanelPrincipalInfo(JSplitPane splitPanelPrincipalInfo) {
    		this.splitPanelPrincipalInfo = splitPanelPrincipalInfo;
    	}
     
     
     
     
     
     
     
    	/**
             * This method initializes informations Reprend le logger à partir du
             * niveau info(le niveau debug ne sera pas affiché à l'écran)
             * 
             * @return javax.swing.JTextPane
             */
    	private JScrollPane getInformations() {
    		LOGGER.info("Récupération du panneau d'information");
    		if (informations == null) {
    			LOGGER.info("Creation du panneau d'information");
    			informations = new JTextArea();
    			informations.setAutoscrolls(true);
    			TextAreaAppender.setTextArea(informations);
    			informations.setRows(3);
     
    			Properties logProperties = new Properties();
    			logProperties.put("log4j.rootLogger", "INFO, TEXTAREA");
     
    			logProperties.put("log4j.appender.TEXTAREA",
    					"gui.composant.TextAreaAppender"); // Our
    																					// custom
    																					// appender
    			logProperties.put("log4j.appender.TEXTAREA.layout",
    					"org.apache.log4j.PatternLayout"); // See:
    														// http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html
    			logProperties.put("log4j.appender.TEXTAREA.layout.ConversionPattern",
    					"%d{HH:mm:ss} %5.5p : %m%n");
     
     
    			PropertyConfigurator.configure(logProperties);
     
     
     
    		}
    		//informations.setSize(200,600);
    		return new JScrollPane(informations);
    	}
     
     
     
    	public JSplitPane getSplitPanelTreeDescription() {
    		LOGGER.debug("Création du panel arbre");
    		if (splitPanelTreeDescription == null) {
    			splitPanelTreeDescription = new JSplitPane();
    			splitPanelTreeDescription.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    			splitPanelTreeDescription.setLeftComponent(getArbre());
    			splitPanelTreeDescription.setRightComponent(getAction());	
    			splitPanelPrincipalInfo.setOneTouchExpandable(true);
    			splitPanelPrincipalInfo.setDividerLocation(170);
    			splitPanelTreeDescription.setMinimumSize(new Dimension(300, 450));
    		}
     
    		return splitPanelTreeDescription;
     
    	}
     
     
    	public GestionnairePlan getGestionnairePlan() {
    		return gestionnairePlan;
    	}
     
     
     
     
    	public void setGestionnairePlan(GestionnairePlan gestionnairePlan) {
    		this.gestionnairePlan = gestionnairePlan;
    	}
     
     
    	public JScrollPane getArbre() {
    		gestionnairePlan.setPath("test.xml");
    		Plan plan = gestionnairePlan.getPlan();
     
    		//if(plan != null){
     
    			CustomMutableTreeNode  nodePlan = new CustomMutableTreeNode(plan);
    			for(DemiOrbite demiOrbite : plan.getListeDemiOrbite()){
    				CustomMutableTreeNode nodeDemiOrbite =  new CustomMutableTreeNode(demiOrbite);
    				nodePlan.add(nodeDemiOrbite);
    			/*	for(TC tc : demiOrbite.getListeTelecomande()){
    					CustomMutableTreeNode nodeTc = new CustomMutableTreeNode(tc);
    					nodeDemiOrbite.add(nodeTc);
    				} */
     
    			}
    			root = new DefaultTreeModel(nodePlan);
    			arbre = new JTree(root);
    			arbre.addMouseListener(new TreeSelectionListener());
     
    			JScrollPane myScrollPane = new JScrollPane(arbre);
     
     
     
    		//}
    		return myScrollPane;
    	}
     
     
    	private JPanel getAction() {
    		JPanel action = new JPanel();
    		JButton boutonAjouter = new JButton("Ajouter Tc1");
    		boutonAjouter.addActionListener(new ActionListener() {
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				if((arbre.getSelectionPath() != null) && (gestionnairePlan.getPlan() != null)){
    					TreePath myPath = arbre.getSelectionPath();
    					LOGGER.info(myPath);
    					CustomMutableTreeNode myParent =
    						(CustomMutableTreeNode)myPath.getLastPathComponent();
     
     
    					if(myParent.getUserObject()  instanceof DemiOrbite){
    						DemiOrbite demi = (DemiOrbite) myParent.getUserObject();
    						Telecommande1 tc1 = new Telecommande1();
    						tc1.setValue("test");
    						demi.getListeTelecomande().add(tc1);
    						myParent.add(new CustomMutableTreeNode(tc1));
    						root.reload(myParent);
    					}
    				}else{
     
    					LOGGER.info("Erreur : vueillez reselectionner un objet de l'abre");
    				}
     
    			}
     
    		});
    		action.add(boutonAjouter);
    		return action;
    	}
     
     
    }
    Voici la classe qui fonctionne pas :
    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
     
    package gui.composant;
     
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
     
    import javax.annotation.Resource;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
     
    import metier.plan.GestionnairePlan;
     
    import org.apache.log4j.Logger;
     
     
     
     
     
     
    @SuppressWarnings("serial")
    public class MenuBar extends JMenuBar{
     
    	/**
             * 
             */
    	@Resource
    	private GestionnairePlan gestionnairePlan; 
     
     
    	/**
             * 
             */
    	private JMenu Fichier = null;// = new JMenu();
    	/**
             * 
             */
    	private JMenuItem ouvrir = null;// = new JMenuItem();
    	/**
             * 
             */
    	private JMenuItem enregistrer = null;// = new JMenuItem();
    	/**
             * 
             */
    	private static Logger LOGGER = Logger.getLogger(MenuBar.class);
     
     
     
     
    	public void initialization(){
    		LOGGER.info("chargement de la barre");
    		Fichier = new JMenu("Fichier");
    		ouvrir = getOuvrir();
    		enregistrer = getEnregistrer();
    		Fichier.add(ouvrir);
    		Fichier.add(enregistrer);
    		this.add(Fichier);
     
    	}
     
    	public JMenuItem getOuvrir() {
    		ouvrir  = new JMenuItem("ouverture d'un plan"); 
    		ouvrir.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				LOGGER.info("ouverture d'un plan 2");
    			/*	JFileChooser choix = new JFileChooser();
    				FileNameExtensionFilter filter = new FileNameExtensionFilter(
    				        "xml","XML");
    				choix.setFileFilter(filter);
    				int retour=choix.showOpenDialog(null);
    				if(retour == JFileChooser.APPROVE_OPTION) {
     
     
     
    				    } */
    				String path = "D:/kalloubi/workspace/Prototype/test2.xml";
    				gestionnairePlan.lirePlan(path);
     
     
    			}
    		});
    		return ouvrir;
    	}
     
     
     
     
     
     
     
     
    	public void setOuvrir(JMenuItem ouvrir) {
    		this.ouvrir = ouvrir;
    	}
     
     
     
    	public JMenuItem getEnregistrer() {
    		enregistrer = new JMenuItem("enregistrement d'un plan");
    		enregistrer.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent e) {
    				LOGGER.info("enregistrement d'un plan");
    			}
    		});
    		return enregistrer;
    	}
     
     
    	public void setEnregistrer(JMenuItem enregistrer) {
    		this.enregistrer = enregistrer;
    	}
     
     
     
    	public JMenu getFichier() {
    		return Fichier;
    	}
     
    	public void setFichier(JMenu fichier) {
    		Fichier = fichier;
    	}
     
     
     
     
     
    }
    Voila mon fichier xml pour la config de spring :
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd">
     
     
     
     
    	 <!-- ANNOTATIONS POUR L'INJECTION DE DEPENDANCES -->
    	 <context:annotation-config />
     
     
    	 <!-- ANNOTATIONS POUR LA CREATION DE BEANS -->
    	 <context:component-scan base-package="dao.xml"/>
    	 <context:component-scan base-package="test"/>
    	 <context:component-scan base-package="metier.plan"/>	
    	 <context:component-scan base-package="gui"/>
    	 <context:component-scan base-package="gui.composant"/>
     
     
     
    </beans>
    voici la trace de l'erreur produit :
    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
     
    2011-04-07 14:50:55,333 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3]; startup date [Thu Apr 07 14:50:55 CEST 2011]; root of context hierarchy
    2011-04-07 14:50:55,380 [main] DEBUG org.springframework.util.ClassUtils - Class [org.apache.commons.collections.map.CaseInsensitiveMap] or one of its dependencies is not present: java.lang.ClassNotFoundException: org.apache.commons.collections.map.CaseInsensitiveMap
    2011-04-07 14:50:55,396 [main] DEBUG org.springframework.util.ClassUtils - Class [edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap] or one of its dependencies is not present: java.lang.ClassNotFoundException: edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap
    2011-04-07 14:50:55,443 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
    2011-04-07 14:50:55,490 [main] DEBUG org.springframework.beans.factory.xml.DefaultDocumentLoader - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
    2011-04-07 14:50:55,552 [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver - Loading schema mappings from [META-INF/spring.schemas]
    2011-04-07 14:50:55,552 [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver - Loaded schema mappings: {http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/jms/spring-jms-2.5.xsd=org/springframework/jms/config/spring-jms-2.5.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/jms/spring-jms.xsd=org/springframework/jms/config/spring-jms-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd}
    2011-04-07 14:50:55,568 [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-2.5.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-2.5.xsd
    2011-04-07 14:50:55,661 [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver - Found XML schema [http://www.springframework.org/schema/context/spring-context-2.5.xsd] in classpath: org/springframework/context/config/spring-context-2.5.xsd
    2011-04-07 14:50:55,677 [main] DEBUG org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader - Loading bean definitions
    2011-04-07 14:50:55,708 [main] DEBUG org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver - Loaded mappings [{http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/jms=org.springframework.jms.config.JmsNamespaceHandler, http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler, http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler}]
    2011-04-07 14:50:55,740 [main] DEBUG org.springframework.util.ClassUtils - Class [weblogic.management.Helper] or one of its dependencies is not present: java.lang.ClassNotFoundException: weblogic.management.Helper
    2011-04-07 14:50:55,740 [main] DEBUG org.springframework.util.ClassUtils - Class [com.ibm.websphere.management.AdminServiceFactory] or one of its dependencies is not present: java.lang.ClassNotFoundException: com.ibm.websphere.management.AdminServiceFactory
    2011-04-07 14:50:55,755 [main] DEBUG org.springframework.util.ClassUtils - Class [javax.persistence.EntityManagerFactory] or one of its dependencies is not present: java.lang.ClassNotFoundException: javax.persistence.EntityManagerFactory
    2011-04-07 14:50:55,818 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\kalloubi\workspace\Prototype\target\classes\dao\xml]
    2011-04-07 14:50:55,818 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\dao\xml] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/dao/xml/**/*.class]
    2011-04-07 14:50:55,818 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:dao/xml/**/*.class] to resources [file [D:\kalloubi\workspace\Prototype\target\classes\dao\xml\XmlGestionPlanFile.class]]
    2011-04-07 14:50:55,927 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\kalloubi\workspace\Prototype\target\classes\test]
    2011-04-07 14:50:55,927 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\test] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/test/**/*.class]
    2011-04-07 14:50:55,927 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:test/**/*.class] to resources [file [D:\kalloubi\workspace\Prototype\target\classes\test\Lecture.class]]
    2011-04-07 14:50:55,943 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\kalloubi\workspace\Prototype\target\classes\metier\plan]
    2011-04-07 14:50:55,943 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\metier\plan] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/metier/plan/**/*.class]
    2011-04-07 14:50:55,943 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:metier/plan/**/*.class] to resources [file [D:\kalloubi\workspace\Prototype\target\classes\metier\plan\GestionnairePlan.class]]
    2011-04-07 14:50:55,974 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\kalloubi\workspace\Prototype\target\classes\gui]
    2011-04-07 14:50:55,974 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/**/*.class]
    2011-04-07 14:50:55,989 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/**/*.class]
    2011-04-07 14:50:56,005 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\listeners] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/**/*.class]
    2011-04-07 14:50:56,005 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/**/*.class]
    2011-04-07 14:50:56,005 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:gui/**/*.class] to resources [file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\CustomMutableTreeNode.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\listeners\TreeSelectionListener.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar$1.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar$2.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroit.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitDemiOrbite.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitPlan.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitTC.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\TextAreaAppender$1.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\TextAreaAppender.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\MainUi$1.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\MainUi.class]]
    2011-04-07 14:50:56,021 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\kalloubi\workspace\Prototype\target\classes\gui\composant]
    2011-04-07 14:50:56,021 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/composant/**/*.class]
    2011-04-07 14:50:56,021 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\listeners] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/composant/**/*.class]
    2011-04-07 14:50:56,021 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus] for files matching pattern [D:/kalloubi/workspace/Prototype/target/classes/gui/composant/**/*.class]
    2011-04-07 14:50:56,021 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:gui/composant/**/*.class] to resources [file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\CustomMutableTreeNode.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\listeners\TreeSelectionListener.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar$1.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar$2.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\MenuBar.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroit.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitDemiOrbite.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitPlan.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\menus\MenuClicDroitTC.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\TextAreaAppender$1.class], file [D:\kalloubi\workspace\Prototype\target\classes\gui\composant\TextAreaAppender.class]]
    2011-04-07 14:50:56,036 [main] DEBUG org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loaded 6 bean definitions from location pattern [applicationContext.xml]
    2011-04-07 14:50:56,036 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@698403
    2011-04-07 14:50:56,036 [main] DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - 6 beans defined in org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3]; startup date [Thu Apr 07 14:50:55 CEST 2011]; root of context hierarchy
    2011-04-07 14:50:56,036 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
    2011-04-07 14:50:56,052 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
    2011-04-07 14:50:56,083 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' to allow for resolving potential circular references
    2011-04-07 14:50:56,099 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
    2011-04-07 14:50:56,099 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
    2011-04-07 14:50:56,099 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
    2011-04-07 14:50:56,114 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' to allow for resolving potential circular references
    2011-04-07 14:50:56,114 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
    2011-04-07 14:50:56,114 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
    2011-04-07 14:50:56,114 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
    2011-04-07 14:50:56,114 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' to allow for resolving potential circular references
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@104faf8]
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@162dbb6]
    2011-04-07 14:50:56,130 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@698403: defining beans [org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,xmlGestionPlanFile,gestionnairePlan,mainUi]; root of factory hierarchy
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'xmlGestionPlanFile'
    2011-04-07 14:50:56,130 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'xmlGestionPlanFile'
    2011-04-07 14:50:56,302 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'xmlGestionPlanFile' to allow for resolving potential circular references
    2011-04-07 14:50:56,302 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'xmlGestionPlanFile'
    2011-04-07 14:50:56,302 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'gestionnairePlan'
    2011-04-07 14:50:56,302 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'gestionnairePlan'
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Found injected field on class [metier.plan.GestionnairePlan]: ResourceElement for private dao.xml.XmlGestionPlanFile metier.plan.GestionnairePlan.lecteurPlan
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'gestionnairePlan' to allow for resolving potential circular references
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected field of bean 'gestionnairePlan': ResourceElement for private dao.xml.XmlGestionPlanFile metier.plan.GestionnairePlan.lecteurPlan
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'xmlGestionPlanFile'
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'gestionnairePlan'
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mainUi'
    2011-04-07 14:50:56,317 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'mainUi'
    2011-04-07 14:50:56,427 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Found injected field on class [gui.MainUi]: ResourceElement for private metier.plan.GestionnairePlan gui.MainUi.gestionnairePlan
    2011-04-07 14:50:56,442 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'mainUi' to allow for resolving potential circular references
    2011-04-07 14:50:56,442 [main] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected field of bean 'mainUi': ResourceElement for private metier.plan.GestionnairePlan gui.MainUi.gestionnairePlan
    2011-04-07 14:50:56,442 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'gestionnairePlan'
    2011-04-07 14:50:56,489 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'mainUi'
    2011-04-07 14:50:56,489 [main] DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - Publishing event in context [org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3]: org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@7a78d3]; startup date [Thu Apr 07 14:50:55 CEST 2011]; root of context hierarchy]
    2011-04-07 14:50:56,489 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'mainUi'
    2011-04-07 14:50:56,489 [main] INFO  gui.MainUi - Initialisation de la fenêtre principale
    2011-04-07 14:50:56,489 [main] INFO  gui.composant.MenuBar - chargement de la barre
    2011-04-07 14:50:56,505 [main] DEBUG gui.MainUi - Création du panel principal
    2011-04-07 14:50:56,505 [main] INFO  gui.MainUi - Récupération du panneau d'information
    2011-04-07 14:50:56,505 [main] INFO  gui.MainUi - Creation du panneau d'information
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at gui.composant.MenuBar$1.actionPerformed(MenuBar.java:77)
    	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    	at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
    	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
    	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)
    	at java.awt.Component.processMouseEvent(Component.java:6263)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    	at java.awt.Component.processEvent(Component.java:6028)
    	at java.awt.Container.processEvent(Container.java:2041)
    	at java.awt.Component.dispatchEventImpl(Component.java:4630)
    	at java.awt.Container.dispatchEventImpl(Container.java:2099)
    	at java.awt.Component.dispatchEvent(Component.java:4460)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    	at java.awt.Container.dispatchEventImpl(Container.java:2085)
    	at java.awt.Window.dispatchEventImpl(Window.java:2475)
    	at java.awt.Component.dispatchEvent(Component.java:4460)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Alors si quelqu'un serait m'expliquer comment injecter un bean dans une classe , ca serait sympa.

    Je remercie tout ceux qui prenne le temps de lire ou de répondre à ce poste.

    @++

  2. #2
    Membre averti
    Homme Profil pro
    Ingénieur étude et dévellopement
    Inscrit en
    Février 2009
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Ingénieur étude et dévellopement
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2009
    Messages : 13
    Par défaut
    Bon finalement j'ai trouve.
    Il faut utiliser l'annotation @Configurable disponible avec spring et plus précisément avec aspectJ et spring-aspects.

    La solution que j'ai applique est preciser à l'adresse suivante :
    http://vaadin.com/wiki/-/wiki/Main/S...%20Integration

    Voila !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Injection de dependance et Lazy<T>
    Par topolino dans le forum C#
    Réponses: 1
    Dernier message: 13/11/2014, 13h40
  2. [Glassfish][EJB3 Stateless]Injection de dependance marche pas.
    Par AbdouPoulou dans le forum Glassfish et Payara
    Réponses: 9
    Dernier message: 18/12/2009, 15h51
  3. Réponses: 7
    Dernier message: 30/07/2009, 22h33
  4. Réponses: 10
    Dernier message: 16/08/2008, 00h51
  5. Réponses: 9
    Dernier message: 06/08/2007, 01h37

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