You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Karel Minařík <ka...@gmail.com> on 2011/09/13 22:15:42 UTC

Cannot create table over REST

Hi,

when I try to create a table via the REST interface:

curl -v -X PUT \
  'http://localhost:8080/test/schema' \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"@name":"test","ColumnSchema":[{"@name":"data"}]}'

I get an exception:

Sep 13, 2011 10:11:47 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NullPointerException
	at org.apache.hadoop.hbase.util.Bytes.toBytes(Bytes.java:401)

What I'm doing wrong?

Thanks!,

Karel


Re: Cannot create table over REST

Posted by Andrew Purtell <ap...@apache.org>.
Hi Karel,

> The REST docs are not very clear then -- I've copied over the JSON from `GET /table/schema` example

Noted, thanks.


Please see https://issues.apache.org/jira/browse/HBASE-4399

 

Best regards,


       - Andy

Problems worthy of attack prove their worth by hitting back. - Piet Hein (via Tom White)


>________________________________
>From: Karel Minařík <ka...@gmail.com>
>To: user@hbase.apache.org
>Sent: Tuesday, September 13, 2011 9:33 PM
>Subject: Re: Cannot create table over REST
>
>Thanks, Andy! I see I've had one more `@` in the column "name" property? 
>
>The REST docs are not very clear then -- I've copied over the JSON from `GET /table/schema` example (which contains `@name`, not `name` in the column definition). I think adding examples for creating tables (and rows, for that matter), would be very handy.
>
>Karel
>
>On 14.Sep, 2011, at 1:11 , Andrew Purtell wrote:
>
>> Try
>> 
>> curl -v -X PUT \
>> 
>>  http://localhost:8080/test/schema \
>>   -H "Accept: application/json" \
>>   -H "Content-Type: application/json" \
>>   -d '{"name":"test","ColumnSchema":[{"name":"data"}]}'
>> 
>>  
>> You should see:
>> 
>>> PUT /test/schema HTTP/1.1
>>> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
>>> Host: localhost:8080
>>> Accept: application/json
>>> Content-Type: application/json
>>> Content-Length: 48
>>> 
>> < HTTP/1.1 201 Created
>> < Location: http://localhost:8085/test/schema
>> < Content-Length: 0
>> 
>> 
>> Best regards,
>> 
>> 
>> - Andy
>> 
>> 
>> Problems worthy of attack prove their worth by hitting back. - Piet Hein (via Tom White)
>> 
>> 
>> ----- Original Message -----
>>> From: Karel Minařík <ka...@gmail.com>
>>> To: user@hbase.apache.org
>>> Cc: 
>>> Sent: Tuesday, September 13, 2011 1:15 PM
>>> Subject: Cannot create table over REST
>>> 
>>> Hi,
>>> 
>>> when I try to create a table via the REST interface:
>>> 
>>> curl -v -X PUT \
>>>   'http://localhost:8080/test/schema' \
>>>   -H "Accept: application/json" \
>>>   -H "Content-Type: application/json" \
>>>   -d 
>>> '{"@name":"test","ColumnSchema":[{"@name":"data"}]}'
>>> 
>>> I get an exception:
>>> 
>>> Sep 13, 2011 10:11:47 PM com.sun.jersey.spi.container.ContainerResponse 
>>> mapMappableContainerException
>>> SEVERE: The RuntimeException could not be mapped to a response, re-throwing to 
>>> the HTTP container
>>> java.lang.NullPointerException
>>>     at org.apache.hadoop.hbase.util.Bytes.toBytes(Bytes.java:401)
>>> 
>>> What I'm doing wrong?
>>> 
>>> Thanks!,
>>> 
>>> Karel
>>> 
>
>
>
>

Re: Cannot create table over REST

Posted by Karel Minařík <ka...@gmail.com>.
@Andy: Great!

@Sonal: I've read it cover to cover -- unfortunately, the REST section does not give examples for _creating_ a table (schema), so I had to reverse-engineer the docs for _querying_ the table (schema). I've added a comment to the appropriate chapter [http://ofps.oreilly.com/titles/9781449396107/clients.html#comment_6143].

Best!,

Karel

On 14.Sep, 2011, at 6:52 , Sonal Goyal wrote:

> You can check HBase The Definitive Guide, it has a great chapter on the
> different clients including Rest.
> 
> http://ofps.oreilly.com/titles/9781449396107/clients.html

On 14.Sep, 2011, at 6:47 , Andrew Purtell wrote:

>> The REST docs are not very clear then -- I've copied over the JSON from `GET /table/schema` example
> 
> Noted, thanks.
> 
> Please see https://issues.apache.org/jira/browse/HBASE-4399

Re: Cannot create table over REST

Posted by Sonal Goyal <so...@gmail.com>.
Hi Karel,

You can check HBase The Definitive Guide, it has a great chapter on the
different clients including Rest.

http://ofps.oreilly.com/titles/9781449396107/clients.html

HTH

Best Regards,
Sonal
Crux: Reporting for HBase <https://github.com/sonalgoyal/crux>
Nube Technologies <http://www.nubetech.co>

<http://in.linkedin.com/in/sonalgoyal>





On Wed, Sep 14, 2011 at 10:03 AM, Karel Minařík <ka...@gmail.com>wrote:

> Thanks, Andy! I see I've had one more `@` in the column "name" property?
>
> The REST docs are not very clear then -- I've copied over the JSON from
> `GET /table/schema` example (which contains `@name`, not `name` in the
> column definition). I think adding examples for creating tables (and rows,
> for that matter), would be very handy.
>
> Karel
>
> On 14.Sep, 2011, at 1:11 , Andrew Purtell wrote:
>
> > Try
> >
> > curl -v -X PUT \
> >
> >   http://localhost:8080/test/schema \
> >   -H "Accept: application/json" \
> >   -H "Content-Type: application/json" \
> >   -d '{"name":"test","ColumnSchema":[{"name":"data"}]}'
> >
> >
> > You should see:
> >
> >> PUT /test/schema HTTP/1.1
> >> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3
> OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> >> Host: localhost:8080
> >> Accept: application/json
> >> Content-Type: application/json
> >> Content-Length: 48
> >>
> > < HTTP/1.1 201 Created
> > < Location: http://localhost:8085/test/schema
> > < Content-Length: 0
> >
> >
> > Best regards,
> >
> >
> > - Andy
> >
> >
> > Problems worthy of attack prove their worth by hitting back. - Piet Hein
> (via Tom White)
> >
> >
> > ----- Original Message -----
> >> From: Karel Minařík <ka...@gmail.com>
> >> To: user@hbase.apache.org
> >> Cc:
> >> Sent: Tuesday, September 13, 2011 1:15 PM
> >> Subject: Cannot create table over REST
> >>
> >> Hi,
> >>
> >> when I try to create a table via the REST interface:
> >>
> >> curl -v -X PUT \
> >>   'http://localhost:8080/test/schema' \
> >>   -H "Accept: application/json" \
> >>   -H "Content-Type: application/json" \
> >>   -d
> >> '{"@name":"test","ColumnSchema":[{"@name":"data"}]}'
> >>
> >> I get an exception:
> >>
> >> Sep 13, 2011 10:11:47 PM com.sun.jersey.spi.container.ContainerResponse
> >> mapMappableContainerException
> >> SEVERE: The RuntimeException could not be mapped to a response,
> re-throwing to
> >> the HTTP container
> >> java.lang.NullPointerException
> >>     at org.apache.hadoop.hbase.util.Bytes.toBytes(Bytes.java:401)
> >>
> >> What I'm doing wrong?
> >>
> >> Thanks!,
> >>
> >> Karel
> >>
>
>

Re: Cannot create table over REST

Posted by Karel Minařík <ka...@gmail.com>.
Thanks, Andy! I see I've had one more `@` in the column "name" property? 

The REST docs are not very clear then -- I've copied over the JSON from `GET /table/schema` example (which contains `@name`, not `name` in the column definition). I think adding examples for creating tables (and rows, for that matter), would be very handy.

Karel

On 14.Sep, 2011, at 1:11 , Andrew Purtell wrote:

> Try
> 
> curl -v -X PUT \
> 
>   http://localhost:8080/test/schema \
>   -H "Accept: application/json" \
>   -H "Content-Type: application/json" \
>   -d '{"name":"test","ColumnSchema":[{"name":"data"}]}'
> 
>  
> You should see:
> 
>> PUT /test/schema HTTP/1.1
>> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
>> Host: localhost:8080
>> Accept: application/json
>> Content-Type: application/json
>> Content-Length: 48
>> 
> < HTTP/1.1 201 Created
> < Location: http://localhost:8085/test/schema
> < Content-Length: 0
> 
> 
> Best regards,
> 
> 
> - Andy
> 
> 
> Problems worthy of attack prove their worth by hitting back. - Piet Hein (via Tom White)
> 
> 
> ----- Original Message -----
>> From: Karel Minařík <ka...@gmail.com>
>> To: user@hbase.apache.org
>> Cc: 
>> Sent: Tuesday, September 13, 2011 1:15 PM
>> Subject: Cannot create table over REST
>> 
>> Hi,
>> 
>> when I try to create a table via the REST interface:
>> 
>> curl -v -X PUT \
>>   'http://localhost:8080/test/schema' \
>>   -H "Accept: application/json" \
>>   -H "Content-Type: application/json" \
>>   -d 
>> '{"@name":"test","ColumnSchema":[{"@name":"data"}]}'
>> 
>> I get an exception:
>> 
>> Sep 13, 2011 10:11:47 PM com.sun.jersey.spi.container.ContainerResponse 
>> mapMappableContainerException
>> SEVERE: The RuntimeException could not be mapped to a response, re-throwing to 
>> the HTTP container
>> java.lang.NullPointerException
>>     at org.apache.hadoop.hbase.util.Bytes.toBytes(Bytes.java:401)
>> 
>> What I'm doing wrong?
>> 
>> Thanks!,
>> 
>> Karel
>> 


Re: Cannot create table over REST

Posted by Andrew Purtell <ap...@apache.org>.
Try

curl -v -X PUT \

  http://localhost:8080/test/schema \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name":"test","ColumnSchema":[{"name":"data"}]}'

 
You should see:

> PUT /test/schema HTTP/1.1
> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: localhost:8080
> Accept: application/json
> Content-Type: application/json
> Content-Length: 48
> 
< HTTP/1.1 201 Created
< Location: http://localhost:8085/test/schema
< Content-Length: 0


Best regards,


- Andy


Problems worthy of attack prove their worth by hitting back. - Piet Hein (via Tom White)


----- Original Message -----
> From: Karel Minařík <ka...@gmail.com>
> To: user@hbase.apache.org
> Cc: 
> Sent: Tuesday, September 13, 2011 1:15 PM
> Subject: Cannot create table over REST
> 
> Hi,
> 
> when I try to create a table via the REST interface:
> 
> curl -v -X PUT \
>   'http://localhost:8080/test/schema' \
>   -H "Accept: application/json" \
>   -H "Content-Type: application/json" \
>   -d 
> '{"@name":"test","ColumnSchema":[{"@name":"data"}]}'
> 
> I get an exception:
> 
> Sep 13, 2011 10:11:47 PM com.sun.jersey.spi.container.ContainerResponse 
> mapMappableContainerException
> SEVERE: The RuntimeException could not be mapped to a response, re-throwing to 
> the HTTP container
> java.lang.NullPointerException
>     at org.apache.hadoop.hbase.util.Bytes.toBytes(Bytes.java:401)
> 
> What I'm doing wrong?
> 
> Thanks!,
> 
> Karel
>