Announcement Announcement Module
Collapse
No announcement yet.
spring-data-neo4j REST timeout Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-data-neo4j REST timeout

    Hi All,
    In my project,I use spring-data-neo4j to connect the neo4j server.
    but when i use the java api method "template.getGraphDatabaseService().getAllNodes()" .

    I see error message like this:
    Code:
    Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out
    	at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131)
    	at com.sun.jersey.api.client.Client.handle(Client.java:616)
    	at com.sun.jersey.api.client.WebResource.handle(WebResource.java:559)
    	at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:72)
    	at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:494)
    	at org.neo4j.rest.graphdb.ExecutingRestRequest.post(ExecutingRestRequest.java:134)
    	at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:404)
    	at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:425)
    	at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:230)
    	at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50)
    	at org.neo4j.rest.graphdb.RestGraphDatabase.getAllNodes(RestGraphDatabase.java:74)
    	at com.neo4j.util.DownloadData.downloadData(DownloadData.java:33)
    	at com.neo4j.main.MainTest.main(MainTest.java:16)
    Caused by: java.net.SocketTimeoutException: Read timed out
    	at java.net.SocketInputStream.socketRead0(Native Method)
    	at java.net.SocketInputStream.read(SocketInputStream.java:129)
    	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    	at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    	at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
    	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
    	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
    	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
    	at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:218)
    	at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129)
    	... 12 more
    this is my applicationContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="
           	http://www.springframework.org/schema/beans 
           	http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context 
    		http://www.springframework.org/schema/context/spring-context.xsd
    		http://www.springframework.org/schema/data/neo4j
    		http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd
    		http://www.springframework.org/schema/tx
    		http://www.springframework.org/schema/tx/spring-tx.xsd">
    
    	<context:spring-configured />
    	<context:annotation-config />
    	<context:component-scan
    		base-package="org.springframework.data.neo4j.examples.hellograph" />
    
    	<neo4j:config graphDatabaseService="graphDatabaseService" />
    	<bean id="graphDatabaseService"
    		class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
    		<constructor-arg index="0" value="http://localhost:7474/db/data" />
    	</bean>
    
    	<neo4j:repositories base-package="org.springframework.data.neo4j.examples.hellograph" />
    
    	<bean id="neo4jTemplate" class="org.springframework.data.neo4j.support.Neo4jTemplate">
    		<constructor-arg ref="graphDatabaseService" />
    	</bean>
    
    	<bean id="transactionManager"
    		class="org.springframework.transaction.jta.JtaTransactionManager">
    		<property name="transactionManager">
    			<bean class="org.neo4j.kernel.impl.transaction.SpringTransactionManager">
    				<constructor-arg ref="graphDatabaseService" />
    			</bean>
    		</property>
    		<property name="userTransaction">
    			<bean class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
    				<constructor-arg ref="graphDatabaseService" />
    			</bean>
    		</property>
    	</bean>
    
    	<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />
    </beans>
    this is my java:
    Code:
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.Iterator;
    
    import org.neo4j.graphdb.Node;
    import org.springframework.data.neo4j.support.Neo4jTemplate;
    
    import com.neo4j.main.ContextUtil;
    
    public class DownloadData {
        public static BufferedReader bufread;
        private static String path = "D:/data.txt";
        private static File filename = new File(path);
        private static FileWriter fileWriter;
        private static BufferedWriter bw;
    
        
        private static Neo4jTemplate template = (Neo4jTemplate) ContextUtil.getContext().getBean("neo4jTemplate");
    
        @SuppressWarnings("deprecation")
        public static void downloadData() {
            System.out.println("test");
            try {
                creatTxtFile();
                fileWriter = new FileWriter(path);
                bw = new BufferedWriter(fileWriter);
                for (Node n : template.getGraphDatabaseService().getAllNodes()) {
                    // Node n = db.getNodeById(2);
                    System.out.println("Got node " + n);
                    Iterator<String> it = n.getPropertyKeys().iterator();
                    String str = "";
                    while (it.hasNext()) {
                        String key = it.next();
                        str = str + " " + key + ":" + n.getProperty(key);
                    }
                    writeTxtFile(n.getId() + str);
                }
                fileWriter.flush();
                bw.close();
                fileWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                template.getGraphDatabaseService().shutdown();
            }
        }
    
        public static void creatTxtFile() throws IOException {
            if (!filename.exists()) {
                filename.createNewFile();
                System.err.println(filename + "is greated!");
            }
        }
    
        /**
         * write file.
         * 
         */
        public static void writeTxtFile(String newStr) throws IOException {
            bw.newLine();
            bw.write(newStr);
        }
    }
    please help me. Thanks.

  • #2
    For completeness, the same question is here: https://groups.google.com/forum/#!to...4j/ohRK5EvEwOo

    Pamod, did Michael's advice help, or is this still a problem for you?

    Regards,

    Lasse

    Comment


    • #3
      Hi lasse
      yes. that is me.
      I found a nother way to realize my project.
      So I steer clear of the problem

      Comment

      Working...
      X