rota90 | Bonjour,
je suis entrain de développer un web service qui fait appel à une fonction. Cette fonction traite des exceptions.
Le web service fonctionne très bien sans exception mais dés que je l'ajoute, une erreur à l'excution du projet s'affiche :
"Le contexte [/CMS_GRM] n'a pas encore été démarré a été rencontrée
D:\NetBeansProjects\CMS_GRM\nbproject\build-impl.xml:1055: The module has not been deployed.
See the server log for details."
voilà mon web service : Code :
- package WebService;
- import CMS.CMS_CardStatusException;
- import CMS.CMS_Exception;
- import javax.jws.WebService;
- import javax.jws.WebMethod;
- import javax.jws.WebParam;
- import javax.jws.WebResult;
- /**
- *
- * @author User
- */
- @WebService(targetNamespace = "http://WebService/" )
- public class NEC_WS {
- /**
- * Web service operation
- */
- @WebMethod(operationName = "ChangeCardStatus" )
- public int changeCardStatus(@WebParam(name = "ApplicationId" ) int applicationId, @WebParam(name = "CardNumber" ) String cardNumber, @WebParam(name = "CardStatusId" ) int cardStatusId) throws CMS_Exception, CMS_CardStatusException {
- CMS.Controller c = new CMS.Controller();
- int res = c.ChangeCardStatus(cardNumber, applicationId, cardStatusId);
- return res;
- }
|
la fonction "ChangeCardStatus"
Code :
- public int ChangeCardStatus(String CardNumber, int ApplicationId, int cardStatusId) throws CMS_Exception, CMS_CardStatusException {
- int result = 0;
- int res = 0;
- configFileURL = HibernateUtil.class.getResource("/hibernate.cfg.xml" );
- Configuration config2 = (new Configuration()).configure(configFileURL);
- factory2 = config2.
- addAnnotatedClass(GRM.ApplicationCardStatuses.class).
- addAnnotatedClass(GRM.CardStatus.class).buildSessionFactory();
- Session session2 = factory2.openSession();
- Transaction tx2 = null;
- try {
- tx2 = session2.beginTransaction();
- GRM.CardStatus cardState = new GRM.CardStatus();
- GRM.CardStatus newCardState = new GRM.CardStatus(cardStatusId);
- Query query1 = session2.createQuery("From GRM.ApplicationCardStatuses st where st.applicationId= ?" );
- query1.setParameter(0, ApplicationId);
- if (query1.list().isEmpty() == true) {
- throw new CMS_Exception("ApplicationId does not exist in the DataBase!" );
- } else {
- List<GRM.ApplicationCardStatuses> cartesGRM = query1.list();
- for (GRM.ApplicationCardStatuses carteGRM : cartesGRM) {
- cardState = carteGRM.getCardStatus();
- int PreviousStatusId = cardState.getCardStatusId();
- res = CardStatusCompatibility(cardStatusId, PreviousStatusId);
- if (res != 0) {
- throw new CMS_CardStatusException(cardStatusId, PreviousStatusId, res);
- } else {
- carteGRM.setStatusDate(new Date());
- carteGRM.setCardStatus(newCardState);
- }
- }
- tx2.commit();
- result = 0;
- }
- } catch (HibernateException e) {
- if (tx2 != null) {
- tx2.rollback();
- }
- e.printStackTrace();
- result = 1;
- } catch (CMS_Exception ex) {
- System.out.println("Exception generated : " + ex.getMessage());
- result = 1;
- } catch (CMS_CardStatusException e) {
- e.printStackTrace();
- result = 1;
- } finally {
- session2.close();
- }
- return result;
- }
|
et la classe CMS_Exception
Code :
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package CMS;
- import javax.xml.ws.WebFault;
- /**
- *
- * @author aghazouani
- */
- @WebFault(name="WebServiceCMS_Exception",
- targetNamespace="http://WebService/" )
- public class CMS_Exception extends Exception {
- private CMS_Exception faultInfo;
- public CMS_Exception (){
- // System.out.print("ApplicationId does not exist in the DataBase!" );
- }
- public CMS_Exception( String msg) {
- super(msg);
- }
- public CMS_Exception getFaultInfo() {
- return faultInfo;
- }
- }
|
j'ai bien cherché ailleurs mais j'ai pas trouvé de solutions. Merci de m'aider |