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

Format d'échange (XML, JSON...) Java Discussion :

Socket Exception en parsant un flux XHTML


Sujet :

Format d'échange (XML, JSON...) Java

  1. #1
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut Socket Exception en parsant un flux XHTML
    Bonjour,

    J'ai réalisé une appli en PHP. Je voudrais la tester via java. Dans mon appli java, je dois donc parser les flux (forcément HTML) envoyé par le PHP. Il se trouve que je parse un flux (XHTML) sur mon localhost. Mais voila j'ai une URL exception. voici la trace de l'exception
    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
    Exception in thread "main" java.net.SocketException: Permission denied: connect
    	at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
    	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    	at java.net.PlainSocketImpl.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at sun.net.NetworkClient.doConnect(Unknown Source)
    	at sun.net.www.http.HttpClient.openServer(Unknown Source)
    	at sun.net.www.http.HttpClient.openServer(Unknown Source)
    	at sun.net.www.http.HttpClient.<init>(Unknown Source)
    	at sun.net.www.http.HttpClient.New(Unknown Source)
    	at sun.net.www.http.HttpClient.New(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    	at java.net.URL.openStream(Unknown Source)
    	at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:807)
    	at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:767)
    	at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:275)
    	at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:841)
    	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
    	at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
    	at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    	at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1114)
    	at org.skyrecon.skyline.parsers.XHTMLParser.<init>(XHTMLParser.java:16)
    	at org.skyrecon.skyline.emulation.main.VirtualUser.connect(VirtualUser.java:75)
    	at org.skyrecon.skyline.emulation.main.Main.main(Main.java:13)
    voici comment j'appelle mon handler (plus bas)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    XMLReader saxReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    		saxReader.setContentHandler(new SkyHandler());
            saxReader.parse(uri);
            System.out.println("trying to parse "+uri);
    et voici mon handler
    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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.LocatorImpl;
     
    public class SkyHandler implements ContentHandler 
    {
        private Locator locator = null;
        public SkyHandler()
    	{
    		super();
    		this.locator = new LocatorImpl();
    	}
    	public void setDocumentLocator(Locator value) 
    	{
    	     this.locator =  value;
    	}
    	public void startDocument() throws SAXException 
    	{
    		System.out.println("Debut de l'analyse du document");
    	}
    	public void endDocument() throws SAXException 
    	{
    		System.out.println("Fin de l'analyse du document" );
    	}
    	public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributs) throws SAXException 
    	{
    		System.out.println("Ouverture de la balise : " + localName);
    	    if ( ! "".equals(nameSpaceURI))
    	    {
    	    	System.out.println("  appartenant a l'espace de nom : "  + nameSpaceURI);
    	    }
    	    System.out.println("  Attributs de la balise : ");
    	    for (int index = 0; index < attributs.getLength(); index++) 
    	    { 
    	    	System.out.println("     - " +  attributs.getLocalName(index) + " = " + attributs.getValue(index));
    	    }
    	}
    	public void endElement(String nameSpaceURI, String localName, String rawName) throws SAXException 
    	{
    		System.out.print("Fermeture de la balise : " + localName);
    		if ( ! "".equals(nameSpaceURI)) 
    		{ 
    			System.out.print("appartenant a l'espace de nommage : " + localName);
    	    }
    		System.out.println();
    	}
    	@Override
    	public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void endPrefixMapping(String arg0) throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
    			throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void processingInstruction(String arg0, String arg1)
    			throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void skippedEntity(String arg0) throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    	@Override
    	public void startPrefixMapping(String arg0, String arg1)
    			throws SAXException {
    		// TODO Auto-generated method stub
     
    	}
    }

  2. #2
    Membre chevronné
    Profil pro
    Développeur Java
    Inscrit en
    Novembre 2007
    Messages
    301
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Novembre 2007
    Messages : 301
    Par défaut
    La connexion a été refusé. Ton uri doit être incorrect. Vérifie le port, etc...

  3. #3
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    Citation Envoyé par darkxan Voir le message
    La connexion a été refusé. Ton uri doit être incorrect. Vérifie le port, etc...
    Tu avais raison, c'était un logiciel de sécu qui bloquaity javaw => donc forcément

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

Discussions similaires

  1. [Socket Exception] Broken Pipe
    Par GyZmoO dans le forum Entrée/Sortie
    Réponses: 1
    Dernier message: 21/01/2010, 10h50
  2. Sockets : exceptions levées par Begin* et End*
    Par icareo dans le forum Général Dotnet
    Réponses: 2
    Dernier message: 16/08/2009, 17h33
  3. [JDOM] Parsage de flux XHTML
    Par sliderman dans le forum Format d'échange (XML, JSON...)
    Réponses: 5
    Dernier message: 05/09/2008, 22h37
  4. Problème Socket Exception
    Par Royd938 dans le forum Langage
    Réponses: 6
    Dernier message: 28/11/2006, 11h18
  5. [Java][Socket] Pas de lecture de flux
    Par mavina dans le forum Entrée/Sortie
    Réponses: 7
    Dernier message: 20/10/2006, 19h02

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