Partage
  • Partager sur Facebook
  • Partager sur Twitter

openJPA persistence.xml

openJPA persistence.xml

    25 janvier 2015 à 21:58:36

    Bonsoir,

    me voilà bien embêté, j'ai créer un projet maven simple. Je l'ai configuré de sorte à utiliser openJPA.

    J'ai créé une classe Account, une dao AccountDAO et un main de test afin de voir si la persitance s'effectuait correctement...

    package com.openjpa.test;
    
    import com.openjpa.dao.AccountDao;
    
    import com.openjpa.entities.Account;
    
    public class AccountTest {
    	
    	public static void main(String[] args) {
    		
    		//-----------------
    		// Please remove account before launching test
    		//-----------------
    		
    		System.out.println("0001 accountTest INFO [main] AccountTest - test beginig ...");
    		
    		//-----------------
    		// Creation of new account
    		//-----------------
    		
    		System.out.println("0001 accountTest INFO [main] AccountDAO - creating a new Account");
    		
    		Account accountOne 		= new Account("Vincent");
    		
    		Account accountTwo 		= new Account("Olivier");
    		
    		Account accountThree 	        = new Account("Philipe");
    		
    		//-----------------
    		// Persisting of new account
    		//-----------------
    		
    		System.out.println("0002 accountTest INFO [main] AccountTest - creating a new AccountDao");
    		
    		AccountDao accountDao = new AccountDao();
    		
    		System.out.println("0003 accountTest INFO [main] AccountTest - Persisting entity account");
    		
    		accountDao.createNewAccount(accountOne);
    		
    		accountDao.createNewAccount(accountTwo);
    		
    		accountDao.createNewAccount(accountThree);
    		
    		
    		
    	}
    		
    }
    


    Tout cela marche correctement alors j'ai converti mon projet maven simple en "web dynamic project" comme on dit.

    J'ai implémenté une servlet et essayé de nouveau des opérations de persistance... et ça ne marche pas...

    package com.openjpa.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    
    import javax.servlet.http.HttpServlet;
    
    import javax.servlet.http.HttpServletRequest;
    
    import javax.servlet.http.HttpServletResponse;
    
    import com.openjpa.dao.AccountDao;
    
    import com.openjpa.entities.Account;
    
    public class AccountServlet extends HttpServlet {
    	
    	private static final long serialVersionUID = 1L;
    	
    	public void doGet( HttpServletRequest request, HttpServletResponse response ) 
    			
    			throws ServletException, IOException {
    		
    		Account account = new Account("Jean");
    		
    		AccountDao accountDao = new AccountDao();
    		
    		accountDao.createNewAccount(account);	
    		
    	}
    	
    }

    Le main de test s'effectue toujours correctement mais les mêmes opérations de persistence ne fonctionnent pas dans la servlet...

    J'ai l'erreur suivante :

    2015-01-25T17:20:42.886+0100|Avertissement: StandardWrapperValve[addAccount]: Servlet.service() for servlet addAccount threw exception
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named account

    Si quelqu'un a une idée...

    Merci d'avance...

    • Partager sur Facebook
    • Partager sur Twitter

    openJPA persistence.xml

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown