I am actually working on a Jsf project with spring Ioc and primefaces. when i run my project i obtain this error and i couldn't really find out why. this is the error:
Caused by: java.lang.NullPointerException
at com.grh.bean.TypePrimeManager.init(TypePrimeManager.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
... 63 more
mai 20, 2015 1:22:34 AM org.apache.catalina.core.StandardWrapperValve invoke
Grave: "Servlet.service()" pour la servlet Faces Servlet a généré une exception
java.lang.IllegalStateException: CDATA tags may not nest
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:681)
at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:179)
at javax.faces.context.PartialResponseWriter.startError(PartialResponseWriter.java:341)
at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:174)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:202)
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:126)
at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
this is my managed bean:
package com.grh.bean;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.grh.model.Input;
import com.grh.model.TypPrime;
import com.grh.service.TypeprimeServ;
@Component
@ManagedBean
@Scope("session")
public class TypePrimeManager{
@Autowired
private TypeprimeServ TPS;
private List<TypPrime> tprimes =new ArrayList<TypPrime>();
private TypPrime selectedtype=new TypPrime();
private TypPrime Pr=new TypPrime();
private TypPrime P=new TypPrime();
private List<Input> inputs;
private boolean a=false;
private TypPrime MTypepPrime= new TypPrime();
private List<TypPrime> listTypajouter;
private List<TypPrime> listexistantajout;
private int nbrechampafficher;
private int nbchamps;
private String nb=null;
private TypPrime typSup =new TypPrime();
private List<TypPrime> listTypePrime;
private int n;
private String[] TypeEntr;
@PostConstruct
public void init(){
listTypePrime.clear();
listTypePrime = TPS.TousTypePrime();
}
public int getN() {
return n;
}
public void setN(int n) {
this.n = n;
}
public void setInputs(List<Input> inputs) {
this.inputs = inputs;
}
public List<TypPrime> getListTypePrime() {
return listTypePrime;
}
public void setListTypePrime(List<TypPrime> listTypePrime) {
this.listTypePrime = listTypePrime;
}
public String getNb() {
return nb;
}
public void setNb(String nb) {
this.nb = nb;
}
public TypPrime getSelectedtype() {
return selectedtype;
}
public void setSelectedtype(TypPrime selectedtype) {
this.selectedtype = selectedtype;
}
public int getNbchamps() {
return nbchamps;
}
public void setNbchamps(int nbchamps) {
this.nbchamps = nbchamps;
}
public int getNbrechampafficher() {
return nbrechampafficher;
}
public void setNbrechampafficher(int nbrechampafficher) {
this.nbrechampafficher = nbrechampafficher;
}
public TypPrime getMTypepPrime() {
return MTypepPrime;
}
public void setMTypepPrime(TypPrime mTypepPrime) {
MTypepPrime = mTypepPrime;
}
public String remplirList(){
listTypePrime.addAll(TPS.TousTypePrime());
return "";
}
public TypPrime getTypSup() {
return typSup;
}
public void setTypSup(TypPrime typSup) {
this.typSup = typSup;
}
public TypPrime getPr() {
return Pr;
}
public void setPr(TypPrime pr) {
Pr = pr;
}
public List<TypPrime> getTprimes() {
return tprimes;
}
public void setTprimes(List<TypPrime> tprimes) {
this.tprimes = tprimes;
}
public TypPrime getP() {
return P;
}
public void setP(TypPrime p) {
P = p;
}
public TypeprimeServ getTPS() {
return TPS;
}
public void setTPS(TypeprimeServ tPS) {
TPS = tPS;
}
public List<TypPrime> gettprimes() {
return tprimes;
}
public void settprimes(List<TypPrime> Tprimes) {
tprimes = Tprimes;
}
public boolean isA() {
return a;
}
public void setA(boolean a) {
this.a = a;
}
public String[] getTypeEntr() {
return TypeEntr;
}
public void setTypeEntr(String[] typeEntr) {
TypeEntr = typeEntr;
}
public void traitementAjout(){
}
public List<TypPrime> getListTypajouter() {
return listTypajouter;
}
public void setListTypajouter(List<TypPrime> listTypajouter) {
this.listTypajouter = listTypajouter;
}
public List<TypPrime> getListexistantajout() {
return listexistantajout;
}
public void setListexistantajout(List<TypPrime> listexistantajout) {
this.listexistantajout = listexistantajout;
}
public void traitmenetModifer(){
}
public void traitementSupprimer(){
try{
TPS.supprimerTypeprime(typSup);
FacesContext co = FacesContext.getCurrentInstance();
co.addMessage(null, new FacesMessage("type de prime bien supprimé"));
init();
selectedtype=null;
}catch(Exception e){
FacesContext co = FacesContext.getCurrentInstance();
co.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Type de prime non supprimé car déjà utilisé", null));
remplirList();
RequestContext.getCurrentInstance().update("carsTable");
}
}
public void champs(){
setTypeEntr(new String[n]);
RequestContext context = RequestContext.getCurrentInstance();
context.execute("PF('ajoutertypeprime').show()");
}
public void add() {
Input input = new Input();
input.setLabel("Input " + (inputs.size() + 1));
inputs.add(input);
}
public List<Input> getInputs() {
return inputs;
}
public void supPrimeType(){
typSup=selectedtype;
RequestContext context = RequestContext.getCurrentInstance();
context.execute("PF('dialogSupprimer').show()");
selectedtype=null;
}
}
and this my application context:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:p="http://ift.tt/1jdM0fE"
xmlns:tx="http://ift.tt/OGfeU2"
xmlns:context="http://ift.tt/GArMu7"
xmlns:jdbc="http://ift.tt/18IIlo0"
xsi:schemaLocation="http://ift.tt/18IIlo0 http://ift.tt/1qD8Elx
http://ift.tt/GArMu6 http://ift.tt/1cMYE2s
http://ift.tt/OGfeU2 http://ift.tt/18tm2Tg
http://ift.tt/GArMu7 http://ift.tt/1dfrlFf">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/grh"></property>
<!-- property name="url" value="jdbc:mysql://192.168.1.3/grh"></property-->
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource" /></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.grh.model.Typecredit</value>
<value>com.grh.model.GroupetravailEmploye</value>
<value>com.grh.model.Mission</value>
<value>com.grh.model.Organisme</value>
<value>com.grh.model.Poste</value>
<value>com.grh.model.Etablissement</value>
<value>com.grh.model.TypPrime</value>
<value>com.grh.model.Ville</value>
<value>com.grh.model.Credit</value>
<value>com.grh.model.Configuration</value>
<value>com.grh.model.ExceptionDisponibilite</value>
<value>com.grh.model.Echelon</value>
<value>com.grh.model.TypeSanction</value>
<value>com.grh.model.PosteEmploye</value>
<value>com.grh.model.Contrat</value>
<value>com.grh.model.Grade</value>
<value>com.grh.model.FormationEmploye</value>
<value>com.grh.model.HeureExceptionnelle</value>
<value>com.grh.model.Groupetravail</value>
<value>com.grh.model.Administration</value>
<value>com.grh.model.Prime</value>
<value>com.grh.model.Conjoint</value>
<value>com.grh.model.MissionEmploye</value>
<value>com.grh.model.TypPrimeEchelon</value>
<value>com.grh.model.Diplome</value>
<value>com.grh.model.GradeEmploye</value>
<value>com.grh.model.Sanction</value>
<value>com.grh.model.Document</value>
<value>com.grh.model.Echelle</value>
<value>com.grh.model.EmployeHeureExceptionnelle</value>
<value>com.grh.model.Typeconge</value>
<value>com.grh.model.TypeRetraite</value>
<value>com.grh.model.ConjointEmploye</value>
<value>com.grh.model.Typecontrat</value>
<value>com.grh.model.Formation</value>
<value>com.grh.model.DiplomePoste</value>
<value>com.grh.model.Droit</value>
<value>com.grh.model.Conge</value>
<value>com.grh.model.PrimeEmploye</value>
<value>com.grh.model.Employe</value>
<value>com.grh.model.Enfant</value>
<value>com.grh.model.DiplomePersonnelle</value>
<value>com.grh.model.Typerecrutement</value>
<value>com.grh.model.Pays</value>
<value>com.grh.model.Retraite</value>
<value>com.grh.model.TypeCreditEtablissement</value>
<value>com.grh.model.DiplomeEtablissement</value>
<value>com.grh.model.OrganismeEtablissement</value>
<value>com.grh.model.TypcongeEtablissement</value>
<value>com.grh.model.TypContratEtablissement</value>
<value>com.grh.model.TypRecrutementEtablissement</value>
<value>com.grh.model.TypSanctionEtablissement</value>
<value>com.grh.model.TypretraiteEtabl</value></list>
</property></bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config/>
<context:component-scan base-package="com.grh"/>
</beans>
I realy appreciate any Help.
Aucun commentaire:
Enregistrer un commentaire