Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/Box: Pending Java Exception detected: Could not create entity object #1021

Closed
JitenderSharmaMaxSold opened this issue Nov 11, 2021 · 4 comments
Labels
bug Something isn't working more info required Further information is requested

Comments

@JitenderSharmaMaxSold
Copy link

Describe the bug
When put call is called it give error in log as:
I/Box: Pending Java Exception detected: Could not create entity object

  • ObjectBox version: 3.0.1
  • Reproducibility: always
  • Device: Samsung Galaxy M21
  • OS: Android 11

To Reproduce
Steps to reproduce the behavior:

  1. Create the entity class
  2. Call removeAll and put calls in runInTx
  3. See error

Expected behavior
It should enter the entities

Code
Entity Class

@Entity
data class RepositoryEntity(
    @Id(assignable = true) var id: Long = 0,
    @SerializedName("name") val name: String = "",
    @SerializedName("html_url") val repoUrl: String = "",
    @SerializedName("language") val language: String = "",
    @SerializedName("stargazers_count") val starCount: Int = 0,
    @SerializedName("forks_count") val forksCount: Int = 0,
    @SerializedName("avatar_url") val avatarUrl: String = ""
)

Method to remove all and put all entities, where the error occurs at put method:

fun saveData(data: List<RepositoryEntity>) {
        CoroutineScope(Dispatchers.IO).launch {
            boxStore.runInTx {
                boxStore.boxFor<RepositoryEntity>()
                    .removeAll()  // deleting and inserting data to avoid sync issues
                boxStore.boxFor<RepositoryEntity>().put(data)
            }
        }
    }

Logs, stack traces
Relevant logs, or a stack trace.
I/Box: Pending Java Exception detected: Could not create entity object

@JitenderSharmaMaxSold JitenderSharmaMaxSold added the bug Something isn't working label Nov 11, 2021
@greenrobot-team
Copy link
Member

Thanks for reporting. This exception ("Could not create entity object") is thrown if an entity class cannot be created due to a missing no-args (or alternatively all properties) constructor.

However, the RepositoryEntity class you supplied does have a valid no-arg constructor. Also this exception is only thrown when reading entities, e.g. with get or a query. It is likely that this code and entity is not the cause.

So can you provide a full stack trace to see where this issue actually originates?

@greenrobot-team greenrobot-team added the more info required Further information is requested label Nov 15, 2021
@greenrobot
Copy link
Member

@greenrobot-team Just a side note... Because of "Pending Java Exception detected": can we repro this in our Java tests? Might help us internally to better pin this down in the future.

@greenrobot-team
Copy link
Member

@greenrobot Not so far. The odd thing is that the annotation processor should already error since 3.0.0 if no required constructor exists. And when circumventing that, the exception message from the core APIs is actually something like:

io.objectbox.exception.DbSchemaException: Entity is expected to have this constructor: TestEntity(JZBSIJFDLjava/lang/String;[B[Ljava/lang/String;Ljava/util/List;SIJ)V
	at io.objectbox.Cursor.nativeGetEntity(Native Method)
	at io.objectbox.Cursor.get(Cursor.java:196)
	at io.objectbox.Box.get(Box.java:210)

So need more context to reproduce this.

@no-response
Copy link

no-response bot commented Dec 6, 2021

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

@no-response no-response bot closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more info required Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants