Hi Sebastin,

Thanks for sending me over your code. I took at a look at it and here is
what I found.

First off, there was a problem with the documentation, it was out of date.
Apologies I should have seen that right away. The createSupportedFormats()
method should return a list, rather than a map. I have updated the
documentation here:

http://docs.geoserver.org/1.7.x/developer/programming-guide/rest-services/implementing.html

There were also a few other issues with teh code:

* The sources and test files are not in the proper location with regard to
packaging. You need to move src/main/java/HelloResource.java to
src/main/java/org/geoserver/hellorest/HelloResource.java. And similarly for
the the HelloResourceTest.java file.

* A few imports were missing from HelloResource:

import org.geoserver.rest.format.StringFormat;
import org.restlet.data.MediaType;

You also now will need:

import java.util.ArrayList;
import java.util.List;

Let me know if that works. After making those changes I was able to
successfully run HelloResourceTest.

-Justin

On Wed, 24 Jun 2009 11:43:05 -0400, Sebastin Kolman <[email protected]>
wrote:
> Thanks Justin. Did you mean just the hello_rest module? I have attached
it
> with this mail.
> 
> I am also just learning Java so yeah I could be doing a simple thing
really
> wrong.
> 
> On Tue, Jun 23, 2009 at 9:51 PM, Justin Deoliveira
> <[email protected]>wrote:
> 
>> Hmmm... can you zip up your project and send it to me in a private
email?
>> It looks like the classpath is somehow off, and it would be nice to look
>> at
>> the eclipse .classpath file, along with the sources.
>>
>> -Justin
>>
>>
>> sabman wrote:
>>
>>> Thanks Justin.
>>>
>>> Here is what I was doing wrong. I created the folders src/main/java and
>>> src/test/java under rest/hello_rest. When I created the class files,
>>> eclipse
>>> was creating the files under the rest/src/java folder instead of
>>> rest/hello_rest/src/java.
>>>
>>> So now I made sure that the HelloResource.java file is located under
the
>>> correct folder and there were no errors. (But I could see that the
>>> StringFormat and MediaType objects were not being recognized
correctly.)
>>> Also I moved the applicationContext.xml file from the resources
>>> folder(as
>>> mentioned in the tutorial) to the src/main/java folder (as you
>>> mentioned.).
>>> Also made sure the HelloResourceTest.java file is under the correct
>>> folder.
>>> Now when I run mvn install under the root module I get the following
>>> compilation error:
>>>
>>> [INFO] Compiling 1 source file to
>>>
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/target/classes
>>> [INFO]
>>>
------------------------------------------------------------------------
>>> [ERROR] BUILD FAILURE [INFO]
>>>
------------------------------------------------------------------------
>>> [INFO] Compilation failure
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[9,7]
>>> org.geoserver.hellorest.HelloResource is not abstract and does not
>>> override
>>> abstract method
>>>
createSupportedFormats(org.restlet.data.Request,org.restlet.data.Response)
>>> in org.geoserver.rest.AbstractResource
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[12,38]
>>>
createSupportedFormats(org.restlet.data.Request,org.restlet.data.Response)
>>> in org.geoserver.hellorest.HelloResource cannot override
>>>
createSupportedFormats(org.restlet.data.Request,org.restlet.data.Response)
>>> in org.geoserver.rest.AbstractResource; attempting to use incompatible
>>> return type found   :
>>> java.util.Map<java.lang.String,org.geoserver.rest.format.DataFormat>
>>> required: java.util.List<org.geoserver.rest.format.DataFormat>
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[14,7]
>>> cannot find symbol symbol  : class HashMap location: class
>>> org.geoserver.hellorest.HelloResource
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[14,29]
>>> cannot find symbol symbol  : class HashMap location: class
>>> org.geoserver.hellorest.HelloResource
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[15,31]
>>> cannot find symbol symbol  : class StringFormat location: class
>>> org.geoserver.hellorest.HelloResource
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[15,45]
>>> cannot find symbol symbol  : variable MediaType location: class
>>> org.geoserver.hellorest.HelloResource
>>>
/home/sabman/Documents/Projects/geoserver/src/rest/hello_rest/src/main/java/HelloResource.java:[11,4]
>>> method does not override or implement a method from a supertype
>>>
>>>
>>>
>>>
>>>
>>>
>>> Justin Deoliveira wrote:
>>>
>>>> sabman wrote:
>>>>
>>>>> I did not copy the jar file in the WEB-INF/lib folder. I did that now
>>>>> but
>>>>> its
>>>>> still the same.
>>>>>
>>>> Did you restart geoserver after you did?
>>>>
>>>>> There is no information related to the exception in the log file. 
>>>>> There
>>>>> are
>>>>> some errors messages in eclipse which I am listing below:
>>>>>
>>>> Yeah, there probably won't be an exception, just nothing in the log
>>>> file.
>>>> It could also be that your applicationContext.xml file is in the wrong
>>>> place. Is it under src/main/java in the root of your plugin source?
>>>>
>>>> Can you do a "jar tvf hello_rest.jar" to give us a listing of the
>>>> files.
>>>> Thanks.
>>>>
>>>>> 1) In the HelloResource.java file,  For this piece of code:
>>>>>  protected Map<String, DataFormat> createSupportedFormats(Request
>>>>> request,
>>>>> Response response) {
>>>>>
>>>>>           HashMap formats = new HashMap();
>>>>>           formats.put( "txt", new StringFormat( MediaType.TEXT_PLAIN
>>>>>           ));
>>>>>
>>>>>           return formats;
>>>>>        }
>>>>>
>>>>> These are the errors:
>>>>> @ Map<String, DataFormat> Multiple markers at this line
>>>>>        - The return type is incompatible with
>>>>> AbstractResource.createSupportedFormats(Request,         Response)
>>>>>        - implements
>>>>> org.geoserver.rest.AbstractResource.createSupportedFormats
>>>>> @HashMap Multiple markers at this line
>>>>>        - HashMap cannot be resolved         to a type
>>>>>        - HashMap cannot be resolved         to a type
>>>>>
>>>>> @StringFormat and @MediaType Multiple markers at this line
>>>>>        - StringFormat cannot be resolved         to a type
>>>>>        - MediaType cannot be resolved
>>>>>
>>>> These are because the rest module is not on the classpath of your
>>>> module.
>>>> Can you run a mvn eclipse:eclipse in the root of your module and  then
>>>> refresh the project in eclipse. I think the tutorial is lackign that
>>>> step.
>>>>
>>>>> 2)  When i start geoserver from eclipse by running the Start.java
file
>>>>> I
>>>>> see
>>>>> the following warning messages in the console:
>>>>>
>>>>> Jun 22, 2009 11:14:11 AM
>>>>> it.geosolutions.imageio.gdalframework.GDALUtilities
>>>>> loadGDAL
>>>>> WARNING: Native library load failed.java.lang.UnsatisfiedLinkError:
no
>>>>> gdaljni in java.library.path
>>>>> ..
>>>>> ..
>>>>> log4j:WARN File option not set for appender [geoserverlogfile].
>>>>> log4j:WARN Are you using FileAppender instead of ConsoleAppender?
>>>>>
>>>> That is normal, you can ignore that.
>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> aaime wrote:
>>>>>
>>>>>> sabman ha scritto:
>>>>>>  > I followed the instructions for the REST services available
>>>>>>
>>>>>>>
>>>>>>>
http://docs.geoserver.org/1.7.x/developer/programming-guide/rest-services/implementing.html
>>>>>>> here . The only changes I had to make was in the pom.xml file where
>>>>>>> i
>>>>>>> changed the org.geoserver versions to "1.7.5-SNAPSHOT" from
>>>>>>> "1.7.3-SNAPSHOT"
>>>>>>> (i compared it with the other pom.xml files). The hello_rest module
>>>>>>> compiled
>>>>>>> successfully. I then tried testing the rest service by going to the
>>>>>>> URL:
>>>>>>>
>>>>>>> http://localhost:8080/geoserver/rest/hello.txt
>>>>>>> http://localhost:8080/geoserver/rest/hello_rest/hello.txt
>>>>>>> http://localhost:8080/geoserver/rest/hello_rest
>>>>>>>
>>>>>>> I was not sure which one is correct so I tried all in the browser.
>>>>>>> And
>>>>>>> all I
>>>>>>> see is this:
>>>>>>>
>>>>>>> Geoserver Configuration API
>>>>>>>
>>>>>>>    * exception
>>>>>>>
>>>>>>> What am I doing wrong here?
>>>>>>>
>>>>>> Did you actually include your jar/project in the GeoServer
>>>>>> application
>>>>>> classpath? E.g, took the hello_rest jar and drop it into
>>>>>> geoserver/WEB-INF/lib?
>>>>>>
>>>>>> Can you look in $GEOSERVER_DATA_DIR/logs/geoserver.log and see what
>>>>>> exception (with full strack trace) is thrown when you try to access
>>>>>> those
>>>>>> URL's?
>>>>>>
>>>>>> Cheers
>>>>>> Andrea
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
------------------------------------------------------------------------------
>>>>>> Are you an open source citizen? Join us for the Open Source Bridge
>>>>>> conference!
>>>>>> Portland, OR, June 17-19. Two days of sessions, one day of
>>>>>> unconference:
>>>>>> $250.
>>>>>> Need another reason to go? 24-hour hacker lounge. Register today!
>>>>>>
>>>>>>
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
>>>>>> _______________________________________________
>>>>>> Geoserver-devel mailing list
>>>>>> [email protected]
>>>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>>>>>>
>>>>>>
>>>>>>
>>>> --
>>>> Justin Deoliveira
>>>> OpenGeo - http://opengeo.org
>>>> Enterprise support for open source geospatial.
>>>>
>>>>
>>>>
------------------------------------------------------------------------------
>>>> Are you an open source citizen? Join us for the Open Source Bridge
>>>> conference!
>>>> Portland, OR, June 17-19. Two days of sessions, one day of
>>>> unconference:
>>>> $250.
>>>> Need another reason to go? 24-hour hacker lounge. Register today!
>>>>
>>>>
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
>>>> _______________________________________________
>>>> Geoserver-devel mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>>>>
>>>>
>>>>
>>>
>>
>> --
>> Justin Deoliveira
>> OpenGeo - http://opengeo.org
>> Enterprise support for open source geospatial.
>>

-- 
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to