Your error (stack trace) is a strong indication that geoserver is not  
running at localhost port 8080. Please check this.

On a linux box type

netstat -na | grep 8080 | grep LISTEN

You should get an output, otherwise geoserver is not running.

On Windows, I cant give you a hint because I never worked on MS platforms.




Quoting Jakub Rojek <[email protected]>:

>
>
>>
>> Hi,
>>
>> I have followed you advices trying to write Java   
>> GeoServerRestClint, but i did not succeed to connect to GeoServer   
>> (but my code works with www.yahoo.com). The  other problem is how   
>> to embed the following(just red part of the curl command ):
>>
>> curl -u admin:geoserver -XPOST -H 'Content-type: text/xml' \
>>   -d '<featureType><name>buildings</name></featureType>' \
>>     
>> http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes
>>  the code, which I have written is beneath. The code suppose to do   
>> the same as following curl command:
>> curl -XGET   
>> http://localhost:8080/geoserver/rest/workspaces/acme/datastores/nyc/featuretypes/buildings.xml
>>  The received errors are beneath the code:
>>
>>
>> Thank in advance for your help.
>>
>>
>>
>> /*
>>  * To change this template, choose Tools | Templates
>>  * and open the template in the editor.
>>  */
>> package jdbcsandbox;
>>
>> /**
>>  *
>>  * @author kuba
>>  */
>> import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory.Default;
>> import java.net.*;
>> import java.io.*;
>>
>> public class GeoServerRESTClient {
>>
>>     public static String user = "admin";
>>     public static String password = "geoserver";
>>
>>     public static void main(String[] args) throws Exception {
>>         //
>>
>>         Authenticator.setDefault(new Authenticator() {
>>
>>             @Override
>>             protected PasswordAuthentication getPasswordAuthentication() {
>>                 return new PasswordAuthentication(user,   
>> password.toCharArray());
>>             }
>>         });
>>
>>      //  URL url = new URL("http://www.yahoo.com/";);
>>       URL url = new URL("http://localhost:8080/geoserver/rest/";);
>>
>>
>>         HttpURLConnection connection = null;
>>         try {
>>             //create connection
>>             connection = (HttpURLConnection) url.openConnection();
>>             connection.setRequestMethod("GET");
>>             connection.setRequestProperty("Content-type", "text/xml");
>>             connection.setRequestProperty("Accept", "text/xml");
>>             connection.setUseCaches(false);
>>             connection.setDoInput(true);
>>             connection.setDoOutput(true);
>>             //Get Response
>>             InputStream is = connection.getInputStream();
>>             BufferedReader rd = new BufferedReader(new   
>> InputStreamReader(is));
>>             String line;
>>             StringBuffer response = new StringBuffer();
>>             while ((line = rd.readLine()) != null) {
>>                 response.append(line);
>>                 response.append('\r');
>>             }
>>             rd.close();
>>             System.out.println("" + response.toString());
>>
>>         } catch (Exception e) {
>>
>>
>>             e.printStackTrace();
>>
>>         } finally {
>>
>>             if (connection != null) {
>>                 connection.disconnect();
>>             }
>>         }
>>
>>     }
>> }
>>
>>
>> Errors:
>>
>>
>> java.net.ConnectException: Connection refused
>>         at java.net.PlainSocketImpl.socketConnect(Native Method)
>>         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
>>         at   
>> java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
>>         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
>>         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
>>         at java.net.Socket.connect(Socket.java:529)
>>         at java.net.Socket.connect(Socket.java:478)
>>         at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
>>         at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
>>         at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
>>         at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
>>         at sun.net.www.http.HttpClient.New(HttpClient.java:306)
>>         at sun.net.www.http.HttpClient.New(HttpClient.java:323)
>>         at   
>> sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)
>>         at   
>> sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)
>>         at   
>> sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)
>>         at   
>> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
>>         at jdbcsandbox.GeoServerRESTClient.main(GeoServerRESTClient.java:61)
>>
>>
>>
>>
>>
>>
>> On Aug 18, 2010, at 2:15 PM, [email protected] wrote:
>>
>>> First, please stay on the mailing list, otherwise we would miss   
>>> some hints from others.
>>>
>>> Same situation for me, I have about 900 layers/style sheets which   
>>> I have to configure.
>>>
>>> Google "java url tutorial", I found
>>> http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html
>>> as an example
>>>
>>> Some Hints
>>> 1)
>>> My java scripts has a "removeWorkspace" method which removes a   
>>> workspace. You have to remove all configuration objects bottom up,  
>>>  there is no cascading delete.
>>> 2)
>>> The script starts, removes the whole workspaces(s) and recreates   
>>> the whole configuration. I would not try to support delta   
>>> manipulations.
>>> 3)
>>> For REST calls, you must log in as admin. You can use the   
>>> following code  in your startup sequence.
>>>
>>>             Authenticator.setDefault(new Authenticator() {
>>>                 protected PasswordAuthentication 
>>> getPasswordAuthentication() {
>>>                     return new PasswordAuthentication (user, 
>>> password.toCharArray());
>>>                 }
>>>             });
>>> 4)
>>> Setting the correct connection properties
>>>
>>>     void setConnectionProperties(HttpURLConnection connection) {
>>>             connection.setRequestProperty("Content-type", "text/xml");
>>>             connection.setRequestProperty("Accept", "text/xml");
>>>     }
>>>
>>>
>>> so far, so good
>>> Christian
>>>
>>>
>>>
>>> Quoting Jakub Rojek <[email protected]>:
>>>
>>>> Hi,
>>>>
>>>>
>>>> because I have  huge database and thousands of tables in it.I do   
>>>> not  want to publish each of the layer per hand,  because i am   
>>>> lazy. My  average data set have over 200 tables and I have quite   
>>>> few of such a  sets.
>>>>
>>>>
>>>> Grüß
>>>>
>>>>
>>>> Kuba
>>>>
>>>>
>>>>
>>>> On Aug 18, 2010, at 12:28 PM, [email protected] wrote:
>>>>
>>>>> If you need a GUI, why do you not use the Geoserver Admin GUI ?
>>>>>
>>>>> REST configuration is useful in scripts and for batch    
>>>>> configurations (that is what I do using Java).
>>>>> Why do you want to create an additional GUI for admin actions ?.
>>>>>
>>>>> Quoting Jakub Rojek <[email protected]>:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am using REST Configuration Plugin and curl software.  It   
>>>>>> works   pretty smooth. The thing is that i would like to write   
>>>>>> java  program  that would do the same as curl, but would have   
>>>>>> gui for  the people  that do not really like to write scripts   
>>>>>> in Shell. Do  you know how I  can do it?
>>>>>>
>>>>>> Thanks in advance
>>>>>>
>>>>>>
>>>>>> Kuba
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> This SF.net email is sponsored by
>>>>>>
>>>>>> Make an app they can't live without
>>>>>> Enter the BlackBerry Developer Challenge
>>>>>> http://p.sf.net/sfu/RIM-dev2dev
>>>>>> _______________________________________________
>>>>>> Geoserver-users mailing list
>>>>>> [email protected]
>>>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ----------------------------------------------------------------
>>>>> This message was sent using IMP, the Internet Messaging Program.
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> ----------------------------------------------------------------
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>>
>>
>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to