begin process at 2010 03 19 23:20:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

JAVA / J2EE / J2ME

 > 

Divers

 > 

Débutant(e)

 > 

java.nullPointerException


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

java.nullPointerException

lundi 31 mars 2008 à 17:44:10 | java.nullPointerException

luffyst

salut tout le monde,
ça fé pas mal de jours que je me prend la tete sur une erreur qui doit etre assez facile à résoudre.
Toutefois je suis débutant en java.

Je suis dans le cas d'un développement d'une appli web

je pense avoir repérer l'erreur mais je ne suis pas sur donc j'ai besoin de vous!!!
je vous met le code dela factory que j'implémente:
 en vert foncé c 'est l'erreur (j'ai tout essayé d tests de if,...)
Je vous remercie d'avance si vous arrivez à m'aiguiller.

package

com.st.mcc.wam.service;

import

java.util.List;

import

javax.persistence.EntityManager;

import

javax.persistence.EntityManagerFactory;

import

org.apache.commons.logging.Log;

import

org.apache.commons.logging.LogFactory;

import

org.springframework.orm.jpa.JpaTemplate;

import

org.springframework.transaction.annotation.Transactional;

import

com.st.mcc.wam.bean.Lot;

/* create a class LotFactoryImpl to implement interface LotFactory */

public

class LotFactoryImpl implements LotFactory

{

/**Logger.*/

privatestaticfinal Log LOG = LogFactory.getLog(LotFactoryImpl.class);

private JpaTemplate jpaTemplate; /* object JpaTemplate(type) jpaTemplate(attribute) */

private EntityManager entityManager;

//private EntityManagerImpl = null;

public LotFactoryImpl()

{

// default constructor

}

/*public RuntimeException ()

{

}*/

/* (non-Javadoc)

* @see com.st.mcc.wam.service.CRUDLotfactory#createLot(com.st.mcc.wam.bean.Lot)

*/

@Transactional/* an annotation */

public Lot createLot(Lot lot) /*Create a Lot */

{

LOG.debug("create of lot (begin)");

LOG.debug("id = " + lot.getLotId());

LOG.debug("lattice code = " + lot.getLattice_code());

LOG.debug("quantity = "+ lot.getQuantity());

/* try a LOG with jpaTemplate */

try {

jpaTemplate.persist(lot);/*.persist(lot)= persistence Object(Lot) */

jpaTemplate.flush(); /* .flush = empty a memory or up to date of memory */

LOG.debug("create of lot (end)");

return lot;

}

/* Failure so catch an exception to runtime */

catch (RuntimeException e)

{

//throw new RuntimeException("n'existe pas")

LOG.error("problem !");

returnnull;

}

}

/* (non-Javadoc)

* @see com.st.mcc.wam.service.CRUDLotFactory#deleteLot(com.st.mcc.wam.bean.Lot)

*/

@Transactional

publicvoid deleteLot(Lot lot) {

// TODO Auto-generated method stub

}

/* (non-Javadoc)

* @see com.st.mcc.wam.service.CRUDLotFactory#readLot(com.st.mcc.wam.bean.Lot)

*/

@Transactional

public Lot getLot(String lotId)

{

LOG.debug("search of lot (begin)");

LOG.debug("id = " + lotId);

try

{

Lot lot =

jpaTemplate.find(Lot.class, lotId);/* .find serve to find a lot */

LOG.debug("search of lot (end)");

return lot; /*find a lot so return a lot*/

}

catch (RuntimeException e)

{

System.

err.println(e);

LOG.error("problem !");

returnnull; /* not find a lot so return null and to start again a search */

}

}

/* (non-Javadoc)

* @see com.st.mcc.wam.service.CRUDLotFactory#updateLot(com.st.mcc.wam.bean.Lot)

*/

@Transactional

publicvoid updateLot(Lot lot)

{

// TODO Auto-generated method stub

}

/*the connection at BDD = EntityManagerFactory */

publicvoid setEntityManagerFactory(EntityManagerFactory emf)

{

this.jpaTemplate = new JpaTemplate(emf);

this.entityManager = emf.createEntityManager();

}

 

@Transactional

public List<Lot> getLots()

{

//if (l!=0) throw new RuntimeException("");

for(int i=0; i<2; i++)

{

Lot l =

new Lot();

l.setLotId(

"G_"+ i);

l.setLattice_code(

"");

l.setQuantity(3);

l.setJalon(

"");

l.setTechnology(

"");

l.setPriority(

"");

l.setStatus_lot(

"");

l.setHold(

"");

l.setOverride(

"");

int date_begin = 06/02/2008;

l.setDate_debut(date_begin);

l.setDate_debut(06/02/2008);

int date_end = 17/04/2008;

l.setDate_fin(date_end);

this.createLot(l);

LOG.debug("Lot = " + l.getLotId() );

}

System.

out.println(" hello!"); //il m'affiche bien ceci sur la console d'éclipse

entityManager.createNamedQuery("getAllLots");/*ERROR HERE*/

List<Lot> lotList=

jpaTemplate.find("SELECT * FROM LOT");

jpaTemplate.findByNamedQuery("getAllLots",lotList);

/**Thisisthelistofobject**/

return (List<Lot>)lotList;

}

/**************Properties************************/

/**

*@returnthejpaTemplate

*/

public JpaTemplate getJpaTemplate() {

returnjpaTemplate;

}

/**

*@paramjpaTemplatethejpaTemplatetoset

*/

publicvoid setJpaTemplate(JpaTemplate jpaTemplate) {

this.jpaTemplate = jpaTemplate;

}

/**

*@returntheentityManager

*/

public EntityManager getEntityManager() {

returnentityManager;

}

/**************************************************/

/**

*@paramentityManagertheentityManagertoset

*/

publicvoid setEntityManager(EntityManager entityManager) {

this.entityManager = entityManager;

}

/**

*@returnthelOG

*/

publicstatic Log getLOG() {

returnLOG;

}

/*****************************************************/

}



voici l'erreur ke me donne internet qu'en j'exécute ma requete.

exception

javax.servlet.ServletException 	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) 	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) 	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:697) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 

root cause

java.lang.NullPointerException 	com.st.mcc.wam.service.LotFactoryImpl.getLots(LotFactoryImpl.java:175) 	com.st.mcc.wam.action.LotInfoAction.getLotInfo(LotInfoAction.java:34) 	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 	java.lang.reflect.Method.invoke(Method.java:585) 	org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269) 	org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) 	org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) 	org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) 	org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) 	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) 	org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) 	org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) 	org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) 	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) 	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:697) 	javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96

 voila
lundi 31 mars 2008 à 19:25:41 | Re : java.nullPointerException

Twinuts

Membre Club Administrateur CodeS-SourceS
Salut,

elle est où la ligne 175 ? dsl mais j'ai la flème de compter....



------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
mardi 1 avril 2008 à 08:40:54 | Re : java.nullPointerException

luffyst


voici le bout de code ou il y a la ligne 175:


System.

out.println(" hello!"); //il m'affiche bien ceci sur la console d'éclipse

entityManager.createNamedQuery("getAllLots");/*ERROR HERE*/

List<Lot> lotList=

jpaTemplate.find("SELECT * FROM LOT"); // line175

jpaTemplate.findByNamedQuery("getAllLots",lotList);

/**Thisisthelistofobject**/

return (List<Lot>)lotList;



 voila


Cette discussion est classée dans : java, apache, log, lot, jpatemplate


Répondre à ce message

Sujets en rapport avec ce message

Redemarrer serveur Apache via JAVA [ par pipo ] Bonjour, je cherche a redemarrer mon serveur apache "WIN32" (pas une machine internet, machine en reseau localhost) via une applet ou autre.le but est Socket.. [ par bouboulleblanc ] Salut.Je voudrais utiliser un applet java avec une base de donnée sql se trouvant sur un serveur apache.j'utilise ceci :Class.forName("com.mysql.jdbc. probleme apache+tomcat+java sous win 2000 [ par blutch12 ] Salut,Nous avons un serveur NT 4.0 avec apache 2.0.45, tomcat 4.1, java 1.4.0_03 et ie 6.0 sp1 et une application web qui utilise les jsp. Cela foncti Servlet(serveur TOMCAT) et serveur RMI [ par Matteo05 ] Voila mon pbCoté Client, j'ai un site fait en servelt (serveur web Tomcat). A partir de ce client, j'accède à une base de donnée via un serveur RMI.J' Java tel mobile ? -> Quel log ? [ par guizmo123 ] Salut tout le monde !Voilà j'ai un problème, je sais qu'on peut créer des logiciels en java pour téléphone mobiles tels que Nokia ou encore Sageme myx help jsp [ par farotide ] je suis sur le developpement d'une identification avec login et mdp.ceux ci sont recuperez dans un fichier.pour cela j'utilise une page jsp, deux clas Connexion JDBC à une base ACCESS [ par peeterm ] Bonjour je n'arrive pas à me connecter à une base access avec le Driver sun.jdbc.odbc.JdbcOdbcDriverj'ai cré ma source odbc sous windows qui s'appelle jdbc mysql erreur de connection [ par tic42 ] Bonjour voila j'ai un programme qui se connecte à une base de donnée qui fonctionne mais maintenant je l'ai transformé pour en faire un servlet et j'o Prb avec TOMCAT [ par ghrissi31 ] bonjour tt le monde,j'utilise un serveur d'application JOnas associé avec TomCat. le serveur d'objet marche trés bien (EJB) mais lorsque j'essaye de m Affichage feuille Excel [ par javaSudSudOuest ] Bonjour,J'essaie désesperement d'afficher le contenu d'un fichier excel au travers d'une appli JAVA.Je pensais donc utiliser SWING. C'est d'ailleurs c


Nos sponsors


Sondage...

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,546 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales