Issue Details (XML | Word | Printable)

Key: NUCREST-5
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Joscha Feth
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus API REST

Querying all objects of a class returns 404

Created: 08/Aug/11 01:24 AM   Updated: 30/Apr/12 12:02 PM   Resolved: 30/Apr/12 10:37 AM
Component/s: None
Affects Version/s: 3.0.0.release
Fix Version/s: None

File Attachments: 1. Zip Archive datanucleus-rest-example.zip (7 kB)
2. Text File server.log (56 kB)
3. Text File testcase (client).log (38 kB)

Environment: OSX Lion, HBase 0.90.2

Forum Thread URL: http://www.datanucleus.org/servlet/forum/printthread_thread,6759
Datastore: HBase
Severity: Production


 Description  « Hide
When using datanucleus-3.0.0-release REST, fetching all objects of a class (first one here http://www.datanucleus.org/products/accessplatform/rest/httpmethods.html) returns a 404 Not Found:

-- 8< --
curl -v http://localhost:8080/dn/com.MyClass
* About to connect() to localhost port 8080 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
> GET /dn/com.MyClass HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Length: 0
< Server: Jetty(7.4.5.v20110725)
<
* Connection #0 to host localhost left intact
* Closing connection #0
-- 8< --

whereas a query for a single object completes successfully.
After debugging into it, I got the feeling it has something to do with the primary key not getting correctly calculated.

My setup is as follows:

POM:
---------
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-rest</artifactId>
<version>3.0.0-release</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-json</artifactId>
<version>3.0.0-release</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-json</artifactId>
<version>3.0.0-release</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-hbase</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>3.0.0-release</version>
</dependency>

<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>3.0.0-release</version>
<type>jar</type>
<scope>compile</scope>
</dependency>


web.xml:
---------
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">

<servlet>
<servlet-name>DataNucleus</servlet-name>
<servlet-class>org.datanucleus.api.rest.RestServlet</servlet-class>
<init-param>
<param-name>persistence-context</param-name>
<param-value>transactions-optional</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>DataNucleus</servlet-name>
<url-pattern>/dn/*</url-pattern>
</servlet-mapping>
</web-app>



persistence.xml:
----------
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">

<persistence-unit name="transactions-optional"
transaction-type="RESOURCE_LOCAL">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>com.MyClass</class>
<exclude-unlisted-classes />
<properties>
<property name="datanucleus.ConnectionURL" value="hbase" />
<property name="datanucleus.ConnectionUserName" value="" />
<property name="datanucleus.ConnectionPassword" value="" />
<property name="datanucleus.autoCreateTables" value="true" />
<property name="datanucleus.autoCreateColumns" value="true" />
<property name="datanucleus.Multithreaded" value="true" />
</properties>
</persistence-unit>
</persistence>


hbase-site.xml:
-----------
<configuration>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>localhost</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.master</name>
        <value>localhost:60000</value>
    </property>
</configuration>


Queried Class:
------------
@PersistenceCapable(table = "bla")
public class MyClass extends Model {

/**
*
*/
private static final long serialVersionUID = 1L;

@Persistent(primaryKey = "true", columns = { @Column(name = "id", allowsNull = "false") }, name = "id", valueStrategy = IdGeneratorStrategy.NATIVE, cacheable = "true")
protected String id;

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 08/Aug/11 09:27 AM
Not reproduceable. You have to demonstrate with a testcase.
The current tests at
http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/test/accessplatform/trunk/test.rest/
all work, when run against HSQLDB, or against HBase. When providing a test, provide it as a patch to the above so then if there is a problem the test becomes part of the test suite

Joscha Feth added a comment - 08/Aug/11 01:31 PM
Attached an example including a testcase.
When building the maven project, please make sure you skip the tests, because they fail before the included jetty has been started.

Do this:

mvn -DskipTests=true clean install
(other cmd) mvn jetty:run
mvn test

Andy Jefferson added a comment - 08/Aug/11 03:10 PM
Thx but this is not fitting in with our test suite hence no time to look at it. Our test suite starts up Jetty internally (which you can see in BasicTest). Consequently it is more portable and simpler to add tests.

Secondly you likely have an error in the log implying something along the lines of value generation hasn't been performed; this is because the person who wrote the REST plugin only implemented basic persistence

Joscha Feth added a comment - 08/Aug/11 03:21 PM
I apologize my test project does not fit in your test suite, but would you please be so kind and have a look at it nevertheless?
The problem is a critical one - it's not like there is some arbitrary almost-never-used functionality is not working and the forum thread (which is not by me) suggests others are also seeing this problem with 3.0.0-release.
You asked me to transform my error report into a test case, which I did, so it would be nice if you could spend the five minutes to run the (also integrated Jetty plus tests) with the three (!) lines of code I provided in my earlier comment.

Andy Jefferson added a comment - 08/Aug/11 04:06 PM
I already said, look in your log, and also said that the author of that plugin didnt allow for value strategies. Consequently it should be obvious what to do :-
1. either remove the value strategy from your code and re-run it
2. or contribute the code to api.rest/api.json plugins to generate values for any fields that need them generating, by inspecting the metadata to find any fields affected, and using the StoreManager to generate the value.

If you have a "critical" problem then the onus is on you, not me. DataNucleus provides the source code, and provides adequate mechanisms (contributions, donations, commercial support, etc) for users to push issues forward.

Joscha Feth added a comment - 10/Aug/11 04:54 AM
I removed "valueStrategy = IdGeneratorStrategy.NATIVE" from "MyClass" and added a setter for the ID instead. Does not seem to change anything. Still a 404 for the GET for all objects.

I will attach the logs (for the run with the value strategy) - I ran it with DEBUG but can not find any hints that anything went wrong.

With critical I did not mean especially for me, but in general the problem - not being able to query all persisted objects of a table seems to be ...unfortunate.

Joscha Feth added a comment - 10/Aug/11 04:54 AM
Log files

Joscha Feth added a comment - 26/Aug/11 05:40 AM
adding "identityType = IdentityType.APPLICATION" explicitly also does not seem to do the trick.

Andy Jefferson added a comment - 30/Apr/12 10:37 AM
Suggest you try SVN trunk since your test isn't matching our format, and SVN trunk has had significant changes