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

Services Web Java Discussion :

Axis et MySQL


Sujet :

Services Web Java

  1. #1
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut Axis : java.net.ConnectException: Connection refused: connect
    Bonjour à tous,

    j'essaie de faire fonctionner un Web Service où il y a une connection en base.

    J'ai importé le driver JDBC dans WEB_INF/lib de axis et dans la librairie dans mon projet Eclipse : mysql-connector-java-3.1.12.jar

    Je lance le serveur MySQL à la main (mysqld --console) d'un coté, et je vérifie avec la vue quantumDB sous Eclipse que j'ai bien accès à cette base.

    Cependant lorsque je lance le WS (avec un fichier .bat qui fait toutes les opérations qui vont bien) j'obtiens l'erreur suivante :

    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
     
    Exception in thread "main" AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode:
     faultString: java.net.ConnectException: Connection refused: connect
     faultActor:
     faultNode:
     faultDetail:
            {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(Unknown Source)
            at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
            at java.net.PlainSocketImpl.connect(Unknown Source)
            at java.net.SocksSocketImpl.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
            at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
            at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
            at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
            at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
     
            at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
            at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
            at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
            at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
            at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
            at org.apache.axis.client.Call.invoke(Call.java:2767)
            at org.apache.axis.client.Call.invoke(Call.java:1792)
            at org.ploteus.client.PLOTEUSQueryServiceClient.main(PLOTEUSQueryService
     
    ...
     
    Client.java:99)
    donc je pense que j'ai mal paramétré quelque chose ou sauté une étape.

    Si vous pouviez m'aider, ça serait sympa

    merci ! ciao

  2. #2
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Voici peut être le morceau de code en cause dans la classe :

    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
     
    try {
    			Class.forName("com.mysql.jdbc.Driver");
    		}
    		catch (ClassNotFoundException e) {
    			// The following line allows to return an error code and an error description to the parent class (org.ploteus.QueryService),
    			// which is in charge to build the corresponding XML reply header and return it as response to the web service client.
    			// As the error is proper to the local system, the error code must have the following format "DATASOURCE-XXX".
    			throw new PLOTEUSException("UTDANNINGHE-001","Driver class not found");
    		}
     
    		// Obtain the environment naming context and retrieve MySQL database host name
    		String host_name = null;
    		try {
    			Context initCtx = new InitialContext();
    			Context envCtx = (Context) initCtx.lookup("java:comp/env");
    			host_name = (String)envCtx.lookup("/MySQL_host_name");
    		}
    		catch (NamingException e) {
    			host_name = "localhost:3306";
    		}
     
    		// Get connection to the utdanning database
    		Connection con = null;
    		String url = "jdbc:mysql://"+host_name+"/utdanning";
    		try {
    		    	// Connect with user test
    			con = DriverManager.getConnection(url, "root", "admin");
    		}
    		catch (SQLException e) {
    			e.printStackTrace();		                       	
    			throw new PLOTEUSException("UTDANNINGHE-002","Impossible to connect to the database");
    		}
    si ça peut aider...

  3. #3
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Autre précision :

    le service est accessible via http://localhost:8080/...

    la base MySQL est accessible via jdbc:mysql://localhost:3306/...

    je sais pas si ça à un rapport mais bon, comme je suis un peu perdu, je vous donne le maximum d'éléments !

    je continue à investiguer...

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    36
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Juillet 2007
    Messages : 36
    Par défaut
    A priori ton client n'arrive pas a accéder à ton web service, tu es bien sur que celui ci tourne ?

  5. #5
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    oui, quand je fais http://localhost:8080/nomProjet/services/nomService

    j'ai bien "Hi there, this is an AXIS service!"

  6. #6
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    N'aurais-je pas un problème de driver ou de conf entre axis et mysql ?

    J'ai pourtant ajouter le mysql-connector-java-3.0.17-ga-bin.jar dans le WEB-INF de axis.

    En tout cas j'ai bien vérifié le classpath etc, le service est bien déployé etc

    J'ai aussi ajouté :

    <env-entry>
    <env-entry-name>localhost</env-entry-name>
    <env-entry-value>localhost:3306</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

    dans le web.xml du WEB-INF de axis (et celui du projet à tout hasard...)

    mais toujours la même erreur.

  7. #7
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Petite réflexion de ma part :

    en fait la portion de code qui réalise la connection à la base est contenue dans la classe compilée au départ pour le déploiement du service.

    Donc si cette connection n'est pas bonne dès le début, c'est un peu normal que j'obtienne tout le temps la même erreur non ?

    voici le code en question, en revanche, je ne sais pas trop comment le remplir)

    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
     
     
    try {
    			Class.forName("com.mysql.jdbc.Driver");
    		}
    		catch (ClassNotFoundException e) {
     
    			throw new PLOTEUSException("UTDANNINGHE-001","Driver class not found");
    		}
     
    		// Obtain the environment naming context and retrieve MySQL database host name
    		String host_name = null;
    		try {
    			Context initCtx = new InitialContext();
    			Context envCtx = (Context) initCtx.lookup("java:comp/env");
    			host_name = (String)envCtx.lookup("/MySQL_host_name");
    		}
    		catch (NamingException e) {
    			host_name = "localhost:3306";
    		}
     
    		// Get connection to the utdanning database
    		Connection con = null;
    		String url = "jdbc:mysql://"+host_name+"/utdanning";
     
    		try {
     
    			// Connect with user test
    			con = DriverManager.getConnection(url, "root", "");
    		}
    		catch (SQLException e) {
    			e.printStackTrace();		                       	
    			throw new PLOTEUSException("UTDANNINGHE-002","Impossible to connect to the database");
    		}

  8. #8
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Je continue à investiguer sur mon propre topic, j'ai corrigé d'autres problèmes mais en tout cas ce n'est clairement pas un problème d'accès à la base de données (j'aurais des erreurs JDBC..).

    Quand on regarde la trace

    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
     
    Exception in thread "main" AxisFault
     faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
     faultSubcode:
     faultString: java.net.ConnectException: Connection refused: connect
     faultActor:
     faultNode:
     faultDetail:
            {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
    ction refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(Unknown Source)
            at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
            at java.net.PlainSocketImpl.connect(Unknown Source)
            at java.net.SocksSocketImpl.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:153)
            at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
    ketFactory.java:120)
            at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
    91)
            at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
    va:404)
            at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
     
            at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
            at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
            at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
            at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
            at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
            at org.apache.axis.client.Call.invoke(Call.java:2767)
            at org.apache.axis.client.Call.invoke(Call.java:1792)
            at org.ploteus.client.PLOTEUSQueryServiceClient.main(PLOTEUSQueryService
    Client.java:106)
     
    ...
    On voit qu'il y a un problème d'accès à http://xml.apache.org/axis/.

    Donc je penche maintenant sur un autre problème, la configuration d'un proxy ?

    Quelqu'un a-t-il des élements sur le sujet ?

    Et la ligne qui pose problème est celle-ci : Vector elements = (Vector) call.invoke(input);

    Donc c'est clairement l'invocation du Web Service qui est en cause, mais j'avoue que mes compétences s'arrêtent ici (pour le moment)

    des pistes ?

    merci

  9. #9
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Je suis en train de bidouiller pour configurer un proxy (je ne sais pas si je suis sur la bonne piste mais bon...)


    Si je mets :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Properties props= new Properties(System.getProperties());
    props.put("http.proxySet", "true");
    props.put("http.proxyHost", "127.0.0.1");
    props.put("http.proxyPort", "8080");
    Properties newprops = new Properties(props);
    System.setProperties(newprops);
    j'ai l'erreur suivante (différente de celle que j'ai depuis le début) :

    Exception in thread "main" AxisFault
    faultCode: {http://xml.apache.org/axis/}HTTP
    faultSubcode:
    faultString: (400)Invalid URI
    faultActor:
    faultNode:
    faultDetail:
    {}:return code: 400

    {http://xml.apache.org/axis/}HttpErrorCode:400

    (400)Invalid URI
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.j
    ava:744)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)

    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
    y.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:1792)
    at org.ploteus.client.PLOTEUSQueryServiceClient.main(PLOTEUSQueryService
    Client.java:120)



    voilà donc ce serait vraiment cool si quelqu'un arrivait à me sortir de cette impasse

  10. #10
    Membre confirmé
    Inscrit en
    Juillet 2006
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juillet 2006
    Messages : 143
    Par défaut
    Citation Envoyé par Aphrael Voir le message
    A priori ton client n'arrive pas a accéder à ton web service, tu es bien sur que celui ci tourne ?
    En effet, je me suis aperçu qu'il y avait un problème de slashes (anti slashes au lieu de slashes) dans l'url d'appel du web service...et d'autres soucis de classpath etc...

    Donc problème résolu !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Aide de connexion à MySQL avec Axis
    Par guandalope dans le forum Services Web
    Réponses: 5
    Dernier message: 29/05/2012, 14h13
  2. Axis et MySQL sur Eclipse
    Par guandalope dans le forum Services Web
    Réponses: 0
    Dernier message: 17/08/2009, 14h45
  3. Probleme C++Builder et Mysql
    Par noname dans le forum C++Builder
    Réponses: 3
    Dernier message: 20/06/2002, 13h40
  4. connection a une BDD MySql
    Par delire8 dans le forum MFC
    Réponses: 7
    Dernier message: 19/06/2002, 18h18
  5. [Kylix] Pb connection à Mysql
    Par Anonymous dans le forum EDI
    Réponses: 3
    Dernier message: 25/04/2002, 15h26

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