IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tomcat et TomEE Java Discussion :

configurer dbunit sans lancer tomcat


Sujet :

Tomcat et TomEE Java

  1. #1
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Points : 2
    Points
    2
    Par défaut configurer dbunit sans lancer tomcat
    Bonjour.
    j'essai de configurer dbunit sans lancer tomcat mais je ne sais pas trop comment faire.

    j'ai l'exception javax.naming.NoInitialContextException

    j'ai essayé de d'initialiser ceci :

    System.setProperty"java.naming.factory.initial", "org.apache.catalina.net.DefaultServerSocketFactory");
    System.setProperty("java.naming.factory.url.pkgs", "org.apache.naming");

    quelqun aurait-il une idée.
    Merci

  2. #2
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Points : 2
    Points
    2
    Par défaut
    pour infos

    j'essai de lancer une méthode d'un fichier Bo qui est extends de BoAncestorBean.

    voici ce qui me géne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    public static DataSource getDatasource(String aPoolName) throws TechniqueException
    	{
    		// Recuperation du datasource correspondant au pool
    		DataSource ds = (DataSource) fDataSourceManager.get(aPoolName);
    		if (ds == null)
    		{
    			// Recuperation du datasource
    			try
    			{
    				Context ctx = new InitialContext();
    				ctx = (Context) ctx.lookup("java:comp/env");
    				ds = (javax.sql.DataSource) ctx.lookup(aPoolName);
    			}
    			catch (NamingException e)
    			{
    				Logger log = Logger.getLogger(BoAncestorBean.class);
    				LoggerUtil.printStackTraceToLogger(log,e,Level.FATAL);
    				throw new TechniqueException(null,"Impossible de recuperer le pool " + aPoolName + " " + e);
    			}
     
    			// Si datasource existant
    			if (ds != null)
    				fDataSourceManager.put(aPoolName, ds);
    			else
    				throw new TechniqueException(null,"le pool " + aPoolName + " n'existe pas !");
    		}
     
    		return ds;
    	}
    quand il fait ctx = (Context) ctx.lookup("java:comp/env"); ca gére une exception.

    J'ai essayé plein de chose en vain.

    Si quelqun pouvait m'aider.

  3. #3
    Candidat au Club
    Inscrit en
    Avril 2009
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Avril 2009
    Messages : 6
    Points : 2
    Points
    2
    Par défaut Résolu
    voilo j'ai résolu mon problème donc je partage ma solution.
    dans la méthode setUp() j'ai ajouté :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     try {
    	            // Create initial context
    	            System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
    	                "org.apache.naming.java.javaURLContextFactory");
    	            System.setProperty(Context.URL_PKG_PREFIXES, 
    	                "org.apache.naming");            
     
    	            //initialise un nouveau context
     	            InitialContext ic = new InitialContext();
     
     	            try{
     	            	ic.destroySubcontext("java:");
     	            	ic.createSubcontext("java:");
     	            }catch(Exception e){
     	            	ic.createSubcontext("java:");
     	            }
     
     	            try{
     	            	ic.destroySubcontext("java:comp");
     	            	ic.createSubcontext("java:comp");
     	            }catch(Exception e){
     	            	ic.createSubcontext("java:comp");
     	            }
     
     	            try{
     	            	ic.destroySubcontext("java:comp/env");
     	            	ic.createSubcontext("java:comp/env");
     	            }catch(Exception e){
     	            	ic.createSubcontext("java:comp/env");
     	            }
     
     	            try{
     	            	ic.destroySubcontext("java:comp/env/jdbc");
     	            	ic.createSubcontext("java:comp/env/jdbc");
     	            }catch(Exception e){
     	            	ic.createSubcontext("java:comp/env/jdbc");
     	            }
     
    	            // Construct DataSource
    	            OracleConnectionPoolDataSource ds = new OracleConnectionPoolDataSource();
    	            ds.setDriverType(driver);
    	            ds.setURL(pool);
    	            ds.setUser(user);
    	            ds.setPassword(password);
     
    	            //on ajoute la ds au context
    	            ic.bind("java:comp/env/jdbc/cahier(cahier = le_nom_du_pool", ds);
     
    	        } catch (NamingException ex) {
    	            ex.printStackTrace();
    	        }

Discussions similaires

  1. [NetBeans] prb pour lancer tomcat sous netbeans 5
    Par bbazot dans le forum NetBeans
    Réponses: 7
    Dernier message: 06/03/2006, 16h56
  2. [LOG4J] configuration de log4j sous tomcat
    Par java_fun dans le forum Logging
    Réponses: 4
    Dernier message: 26/09/2005, 11h30
  3. [ Tomcat ]débuguer application Struts sans pluggin Tomcat
    Par laurent.c123 dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 12/07/2005, 14h32
  4. [Plugin Tomcat] Impossible de lancer TOMCAT
    Par Dahu dans le forum Eclipse Java
    Réponses: 7
    Dernier message: 03/03/2005, 10h40
  5. [TOMCAT] Comment lancer Tomcat sous linux
    Par mathieu dans le forum Tomcat et TomEE
    Réponses: 4
    Dernier message: 26/03/2004, 15h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo