+ Répondre à la discussion
Affichage des résultats 1 à 17 sur 17
  1. #1
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut Exception "java.lang.NullPointerException"

    Bonjour,

    Je suis entrain de développez une application en JEE sous Hibernate , Spring , JSF primefaces mais lors de l’exécution j'obtient l’exception suivante:

    Code :
    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
    GRAVE: "Servlet.service()" pour la servlet jsp a lancé une exception
    java.lang.NullPointerException
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
    	at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:58)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
    	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    	at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:198)
    	at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
    	at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:454)
    	at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:635)
    	at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1033)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_p_005fdataTable_005f0(News_jsp.java:210)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_h_005fform_005f0(News_jsp.java:170)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_f_005fview_005f0(News_jsp.java:125)
    	at org.apache.jsp.Views.News_jsp._jspService(News_jsp.java:88)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    9 mai 2012 16:17:00 com.sun.faces.lifecycle.LifecycleImpl phase
    ATTENTION: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@1bef4c6) threw exception
    javax.faces.FacesException: org.apache.jasper.JasperException: An exception occurred processing JSP page /Views/News.jsp at line 15
     
    12: <body>
    13: 	<f:view>
    14: 		<h:form prependId="false">
    15: 			<p:dataTable id="basic" var="News" binding="#{NewsBean.newsTable}"
    16: 				value="#{NewsBean.newsList}">
    17: 				<p:column id="modelHeader">
    18: 					<f:facet name="idNews">  
     
     
    Stacktrace:
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:419)
    	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /Views/News.jsp at line 15
     
    12: <body>
    13: 	<f:view>
    14: 		<h:form prependId="false">
    15: 			<p:dataTable id="basic" var="News" binding="#{NewsBean.newsTable}"
    16: 				value="#{NewsBean.newsList}">
    17: 				<p:column id="modelHeader">
    18: 					<f:facet name="idNews">  
     
     
    Stacktrace:
    	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    	... 18 more
    Caused by: javax.faces.FacesException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:209)
    	at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
    	at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:454)
    	at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:635)
    	at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1033)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_p_005fdataTable_005f0(News_jsp.java:210)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_h_005fform_005f0(News_jsp.java:170)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_f_005fview_005f0(News_jsp.java:125)
    	at org.apache.jsp.Views.News_jsp._jspService(News_jsp.java:88)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    	... 28 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:147)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
    	at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:58)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
    	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    	at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:198)
    	... 39 more
    Caused by: java.lang.NullPointerException
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
    	... 60 more
    9 mai 2012 16:17:00 org.apache.catalina.core.StandardWrapperValve invoke
    GRAVE: "Servlet.service()" pour la servlet Faces Servlet a généré une exception
    java.lang.NullPointerException
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
    	at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:58)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
    	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    	at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:198)
    	at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
    	at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:454)
    	at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:635)
    	at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1033)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_p_005fdataTable_005f0(News_jsp.java:210)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_h_005fform_005f0(News_jsp.java:170)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_f_005fview_005f0(News_jsp.java:125)
    	at org.apache.jsp.Views.News_jsp._jspService(News_jsp.java:88)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    Voici le code de ma classe News.java
    Code :
    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
    package ma.it.model;
     
    // Generated 7 mai 2012 12:58:17 by Hibernate Tools 3.4.0.CR1
     
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import static javax.persistence.GenerationType.IDENTITY;
    import javax.persistence.Id;
    import javax.persistence.Table;
    /**
     * News generated by hbm2java
     */
    @Entity
    @Table(name = "news", catalog = "bdd_itrekrute")
    public class News implements java.io.Serializable {
     
    	private Integer idNews;
    	private String titre;
    	private String description;
     
    	public News() {
    	}
     
    	public News(String titre, String description) {
    		this.titre = titre;
    		this.description = description;
    	}
     
    	@Id
    	@GeneratedValue(strategy = IDENTITY)
    	@Column(name = "idNews", unique = true, nullable = false)
    	public Integer getIdNews() {
    		return this.idNews;
    	}
     
    	public void setIdNews(Integer idNews) {
    		this.idNews = idNews;
    	}
     
    	@Column(name = "titre")
    	public String getTitre() {
    		return this.titre;
    	}
     
    	public void setTitre(String titre) {
    		this.titre = titre;
    	}
     
    	@Column(name = "description")
    	public String getDescription() {
    		return this.description;
    	}
     
    	public void setDescription(String description) {
    		this.description = description;
    	}
    	@Override
    	public String toString() 
    	{
    		return "id "+ this.idNews +" titre : "+this.titre+" description "+this.description;
    	}
     
    }
    ci-dessous le code de la page NewsBean.java :

    Code :
    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
    package ma.it.bean;
     
    import java.io.*;
    import java.util.List;
     
    import javax.annotation.PostConstruct;
     
    import ma.it.service.NewsService;
    import ma.it.model.News;
     
    import org.primefaces.component.datatable.DataTable;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;
     
     
    @Component("NewsBean")
    @Scope("session")
    public class NewsBean implements Serializable{
    	private transient NewsService newsService;
    	private transient DataTable NewsTable;
    	private List<News> NewsList;
     
    	@PostConstruct
    	public void init() {
    		this.NewsList=this.newsService.findAll();
    	}
    	public DataTable getNewsTable() {
    		return NewsTable;
    	}
     
    	public void setNewsTable(DataTable newsTable) {
    		this.NewsTable = newsTable;
    	}
    	public List<News> getNewsList() {
    		return NewsList;
    	}
    	public void setNewsList(List<News> newsList) {
    		this.NewsList = newsList;
    	}
     
    	}
    Et finalement , voici le code de la page News.jsp :
    Code :
    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
    <%@ page contentType="text/html" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://primefaces.prime.com.tr/ui" prefix="p"%>
     
    <!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:form prependId="false">
    			<p:dataTable id="basic" var="News" binding="#{NewsBean.newsTable}"
    				value="#{NewsBean.newsList}">
    				<p:column id="modelHeader">
    					<f:facet name="idNews">  
                        idNews 
                </f:facet>
    					<h:outputText value="#{News.idNews}" />
    				</p:column>
     
    				<p:column>
    					<f:facet name="titre">  
                        Titre  
                </f:facet>
    					<h:outputText value="#{News.titre}" />
    				</p:column>
     
    			</p:dataTable>
    		</h:form>
     
    	</f:view>
    </body>
    </html>
    Est ce quelqu'un a une idée sur la solution de cet erreur ????

  2. #2
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Ta variable this.newsService n'est pas initialisée.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    public class NewsBean implements Serializable{
    	private transient NewsService newsService;
    	private transient DataTable NewsTable;
    	private List<News> NewsList;
     
    	@PostConstruct
    	public void init() {
    		this.NewsList=this.newsService.findAll(); // newsService non initialisé
    	}
    Au passage, en général en java, on ne commence pas le nom d'une variable par une majuscule : NewsTable => newsTable

  3. #3
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    Merci de votre réponse , mais ça ne marche toujours pas , j'ai toujours la même exception que ce soit avec ou sans instanciation de l'objet newsListe sinon est ce que vous pouvez me valider la requête HQL de sélection parce que je débute avec hibernate :

    Code :
    return sessionFactory.getCurrentSession().createQuery(" from  News news").list();

  4. #4
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Citation Envoyé par lamia89 Voir le message
    ça ne marche toujours pas , j'ai toujours la même exception que ce soit avec ou sans instanciation de l'objet newsListe
    Normal vu que c'est newsService et non newsListequi n'est pas instancié.

  5. #5
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    Citation Envoyé par Mathieu.J Voir le message
    Normal vu que c'est newsService et non newsListequi n'est pas instancié.
    même si j'anstancie NewsService l'exception est levée , sachant que j'ai effectué un test sur la fonction findAll() en utilisant JUnit et la requête HQL est juste il me retourne tous les objets News.

  6. #6
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Es-tu certain que la stacktrace est identique après avoir instancié ton service ?
    Même type d'exception ne signifie pas même exception

  7. #7
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Sinon pour ta requête essaye :
    Code :
    return sessionFactory.getCurrentSession().createQuery("select OBJECT(news)  from  News news").list();

  8. #8
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    j'ai modifié la requête et voilà l'exception :
    Code :
    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
    com.sun.faces.lifecycle.LifecycleImpl phase
    ATTENTION: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@4ee1f1) threw exception
    javax.faces.FacesException: org.apache.jasper.JasperException: javax.faces.FacesException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:419)
    	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: org.apache.jasper.JasperException: javax.faces.FacesException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    	... 18 more
    Caused by: javax.faces.FacesException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:209)
    	at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
    	at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:454)
    	at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:635)
    	at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1033)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_p_005fdataTable_005f0(News_jsp.java:210)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_h_005fform_005f0(News_jsp.java:170)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_f_005fview_005f0(News_jsp.java:125)
    	at org.apache.jsp.Views.News_jsp._jspService(News_jsp.java:88)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    	... 28 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NewsBean': Invocation of init method failed; nested exception is java.lang.NullPointerException
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:147)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
    	at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:58)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
    	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    	at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:198)
    	... 39 more
    Caused by: java.lang.NullPointerException
    	at ma.it.service.NewsService.findAll(NewsService.java:26)
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
    	... 60 more
    10 mai 2012 11:57:02 org.apache.catalina.core.StandardWrapperValve invoke
    GRAVE: "Servlet.service()" pour la servlet Faces Servlet a généré une exception
    java.lang.NullPointerException
    	at ma.it.service.NewsService.findAll(NewsService.java:26)
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)
    	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:350)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
    	at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:43)
    	at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:58)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
    	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    	at org.apache.el.parser.AstValue.getValue(AstValue.java:112)
    	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    	at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
    	at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:198)
    	at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
    	at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:454)
    	at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:635)
    	at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1033)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_p_005fdataTable_005f0(News_jsp.java:210)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_h_005fform_005f0(News_jsp.java:170)
    	at org.apache.jsp.Views.News_jsp._jspx_meth_f_005fview_005f0(News_jsp.java:125)
    	at org.apache.jsp.Views.News_jsp._jspService(News_jsp.java:88)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    	at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    	at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    	at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Unknown Source)

  9. #9
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    vous pensez que cet exception peut être dû à une erreur de configuration de l'un des fichiers web.xml ou faces-config.xml ou applicationContext??!

  10. #10
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Il y a bien un changement d'exception.
    Code :
    1
    2
    3
     
    java.lang.NullPointerException
    	at ma.it.bean.NewsBean.init(NewsBean.java:25)
    Maintenant tu as
    Code :
    1
    2
    Caused by: java.lang.NullPointerException
    	at ma.it.service.NewsService.findAll(NewsService.java:26)
    Il nous faudrait le code de ton service.
    Mais à vu de nez, je pencherai pour sessionFactory qui serait NULL, ou sessionFactory.getCurrentSession() qui retourne NULL.

  11. #11
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    Re-bonjour ,

    voici le code de la classe NewsService :

    Code :
    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
    package ma.it.service;
     
    import java.util.List;
     
    import org.hibernate.SessionFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
     
    import ma.it.model.News;
     
    @Service("NewsService")
    @Transactional
    public class NewsService {
     
    	@Autowired
    	private SessionFactory sessionFactory;
     
    	@SuppressWarnings("unchecked")
    	public List<News> findAll()// throws Exception
    	{
    		return sessionFactory.getCurrentSession().createQuery("from  ma.it.model.News").list();
    	}
     
    	public News findById(Integer id)
    	{
    		return (News) sessionFactory.getCurrentSession().get(News.class,id);
    	}
     
    	public void save(News n)
    	{
    		sessionFactory.getCurrentSession().saveOrUpdate(n);
    	}
     
     
    }

  12. #12
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    avril 2004
    Messages
    1 181
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : avril 2004
    Messages : 1 181
    Points : 1 758
    Points
    1 758

    Par défaut

    Vérifie ces 2 points :
    Code :
    sessionFactory qui serait NULL, ou sessionFactory.getCurrentSession() qui retourne NULL.
    Et si c'est l'un des deux, tu dois avoir un problème de config Spring. Mais là j'y connais rien

  13. #13
    Membre Expert Avatar de fxrobin
    Homme Profil pro
    Formateur JAVA / XML
    Inscrit en
    novembre 2007
    Messages
    865
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Formateur JAVA / XML
    Secteur : Service public

    Informations forums :
    Inscription : novembre 2007
    Messages : 865
    Points : 1 318
    Points
    1 318

    Par défaut

    Cette injection

    Code :
    1
    2
    3
     
    @Autowired
    private SessionFactory sessionFactory;
    ne doit pas fonctionner.

    Montre ta classe "SessionFactory" et le fichier "applicationContext.xml" de Spring.

  14. #14
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    "applicationContext.xml" de Spring :

    Code :
    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
     
    <?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:aop="http://www.springframework.org/schema/aop"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
         <property name="driverClassName" value="org.gjt.mm.mysql.Driver" />
         <property name="url" value="jdbc:mysql://localhost/bdd_itrekrute" />
         <property name="username" value="root" />
         <property name="password" value="" />
    </bean>
    <bean id="SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
     <property name="dataSource" ref="dataSource" />
     <property name="annotatedClasses">
      <list>
         <value>ma.it.model.Abonnementclient</value>
         <value>ma.it.model.Abonnementprestataire</value>
         <value>ma.it.model.Abonnementrecruteur</value>
         <value>ma.it.model.Administrateur</value>
         <value>ma.it.model.Appeloffre</value>
         <value>ma.it.model.Candidat</value>
         <value>ma.it.model.Candidature</value>
         <value>ma.it.model.Categorieao</value>
         <value>ma.it.model.Client</value>
         <value>ma.it.model.Competence</value>
         <value>ma.it.model.Competencelinguistique</value>
         <value>ma.it.model.Compte</value>
         <value>ma.it.model.Cv</value>
         <value>ma.it.model.Devis</value>
         <value>ma.it.model.Domainecompetence</value>
         <value>ma.it.model.Experience</value>
         <value>ma.it.model.Favorisao</value>
         <value>ma.it.model.Formation</value>
         <value>ma.it.model.Langue</value>
         <value>ma.it.model.Lettremotivation</value>
         <value>ma.it.model.Loisir</value>
         <value>ma.it.model.Moderateur</value>
         <value>ma.it.model.News</value>
         <value>ma.it.model.Offreemploi</value>
         <value>ma.it.model.Offrefavoris</value>
         <value>ma.it.model.Pays</value>
         <value>ma.it.model.Prestataire</value>
         <value>ma.it.model.Recruteur</value>
         <value>ma.it.model.Secteur</value>
         <value>ma.it.model.Souscategorie</value>
         <value>ma.it.model.Typeabonnclt</value>
         <value>ma.it.model.Typeabonnpresta</value>
         <value>ma.it.model.Typeabonnrecrut</value>
         <value>ma.it.model.Typecontrat</value>
         <value>ma.it.model.Ville</value>
         <value>ma.it.model.Ville</value>
      </list>
     </property>
     <property name="hibernateProperties">
     <props>
     <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
     </props>
     </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="SessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" />
    <context:annotation-config/>
    <context:component-scan base-package="ma.it"></context:component-scan>
     
    <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
        <property name="scopes">
            <map>
                <entry key="session">
                    <bean class="org.springframework.web.context.request.SessionScope"/>
                </entry>
            </map>
        </property>
    </bean>
     
    </beans>

  15. #15
    Membre Expert Avatar de fxrobin
    Homme Profil pro
    Formateur JAVA / XML
    Inscrit en
    novembre 2007
    Messages
    865
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Formateur JAVA / XML
    Secteur : Service public

    Informations forums :
    Inscription : novembre 2007
    Messages : 865
    Points : 1 318
    Points
    1 318

    Par défaut

    je pense, mais je ne suis pas sûr, que c'est parce que l'id de ton bean est "SessionFactory" (majuscule) alors que ce devrait être "sessionFactory" (minuscule) pour que l'@Autowired fonctionne, mais je ne suis pas totalement certain.

    attention toutefois si tu changes l'id, tu as des ref="SessionFactory" dans ton fichier de config qu'il faudra aussi changer.

  16. #16
    Invité régulier
    Profil pro
    Étudiant
    Inscrit en
    septembre 2007
    Messages
    42
    Détails du profil
    Informations personnelles :
    Âge : 25
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : septembre 2007
    Messages : 42
    Points : 5
    Points
    5

    Par défaut

    j'ai toujour le même problème , même si j'ai effectué les modifications que vous avez mentionné

  17. #17
    Membre à l'essai
    Inscrit en
    février 2009
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : février 2009
    Messages : 65
    Points : 22
    Points
    22

    Par défaut bug sur "java.lang.NullPointerException"

    Bonjour à tous,
    je travaille sur un projet JEE, et j'ai ce genre d'erreur lors du lancement de navigateur mais je ne vois pas là où j'ai declaré une variable à null. java.lang.NullPointerException:
    beans.BeanEvent.doGetAllRessources(BeanEvent.java:135)
    beans.BeanEvent.<init>(BeanEvent.java:96)

    Voici ma controillerBean:
    Code :
    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
     
    public class BeanEvent {
    private RessourceVo ressourceConnected;
    private List<BeanColorRessource> listColorsRessources = new ArrayList<BeanColorRessource>();
    private List<BeanColorRessource> listColorsRessourcesTmp = new ArrayList<BeanColorRessource>();
     
    public BeanEvent() {
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("update");
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("gate");
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("inscriptionNotif");
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("period");
            doGetAllRessources();
     
        }
     
    private void doGetAllRessources() {
            BusinessDelegateRessource bdRessource = new BusinessDelegateRessource();
            try {
                this.ressourceConnected = bdRessource.getRessourceByLogin((String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("login"));
            } catch (Exception e) {
                e.printStackTrace();
                HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
                try {
                    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("event");
                    response.sendRedirect("accessdenied.jspx");
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            BeanColorRessource beanColorRessource = new BeanColorRessource();
            listColorsRessources.clear();
            this.listColorsRessources = beanColorRessource.doGetColorsRessourcesVisibleByIdRessourceMaster(
                    this.ressourceConnected.getIdRessource()); 
            //Prenait un int en dur ('1')
            listColorsRessourcesTmp.clear();
            listColorsRessourcesTmp.addAll(listColorsRessources);
            BeanRessourceType beanRessourceType = new BeanRessourceType();
            this.listRessourceTypes = beanRessourceType.doGetAllTypeRessources();
     
            BusinessDelegateParametre delegateParametre = new BusinessDelegateParametre();
            String selectOnLoad = delegateParametre.getParametreByName("SelectOnLoad").getValue();
     
            int i = 0;
            for (int max = this.listColorsRessources.size(); i < max; i++) {
     
                if (selectOnLoad.equals("1")) {
     
                    // Sélectionne la ressource connectée
                    BeanColorRessource colorRessource = new BeanColorRessource();
                    colorRessource = (BeanColorRessource) this.listColorsRessources.get(i);
                    if (colorRessource.getRessourceSlave().getIdRessource() == ressourceConnected.getIdRessource()) {
                        colorRessource.setSelected(true);
                        rowSelectionListener(null);
                    }
     
                } else if (selectOnLoad.equals("2")) {
     
                    // Sélectionne toutes les ressources
                    BeanColorRessource colorRessource = new BeanColorRessource();
                    colorRessource = (BeanColorRessource) this.listColorsRessources.get(i);
                    colorRessource.setSelected(true);
                    rowSelectionListener(null);
     
                }
     
            }
     
        }
    }
    Voici ma jspx:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <ice:panelGrid columns="1" cellpadding="4" cellspacing="4" width="200px">
        <div class="bloc-inscription">
            <ice:dataTable var="res" value="#{event.listColorsRessources}" binding="#{event.dataTable}" rows="30" width="100%" scrollable="true">
             <ice:column>
                  <h:graphicImage styleClass="resource-icon" url="imgs/icons/#{res.ressourceSlave.icon}16.png"></h:graphicImage>
                  <ice:rowSelector multiple="true" value="#{res.selected}" selectionListener="#{event.rowSelectionListener}" />
                   <ice:outputText value="#{res.ressourceSlave.nameRessource}" />
                    <div class="resource-color" style="background-color:#{res.color.colorName};">  
                    </div>  
            </ice:column>
          </ice:dataTable>
        </div>
    </ice:panelGrid>
    Merci pour votre aide.

Liens sociaux

Règles de messages

  • Vous ne pouvez pas créer de nouvelles discussions
  • Vous ne pouvez pas envoyer des réponses
  • Vous ne pouvez pas envoyer des pièces jointes
  • Vous ne pouvez pas modifier vos messages
  •