Can't find a solution?
Post questions to the Ebean forum at: Ebean google group
java.lang.IllegalStateException: Bean class _ is not enhanced?
Actions
1. Check that the IDE enhancement plugin for IDEA or Eclipse is installed
2. Check that the enhancement plugin for maven or gradle is being used
See docs / getting started for more details on enhancement.
NullPointerException using Query beans
Example
new QCustomer
.name.istartsWith("rob") // <-- Getting NPE here
.findList()
Diagnosis
For Java: The query beans or the code using the query beans is not being enhanced.
For Kotlin: The query beans are not being enhanced.
Actions
1. Check the querybean-packages
entry in ebean.mf
For Java:
We need to enhance both the code that is using the query beans and the query beans themselves.
The packages specified by querybean-packages
needs to include the code that is using
the query beans.
For Kotlin: For Kotlin we only need to enhance the query beans themselves (and not the calling code).
For Kotlin the querybean-packages
just needs to include the query beans.
Note that since 12.1.8 we no longer need ebean.mf to support query bean enhancement.
NullPointerException in EntityBeanIntercept
Example
Caused by: java.lang.NullPointerException: null at io.ebean.bean.EntityBeanIntercept.isLoadedProperty(EntityBeanIntercept.java:509) at io.ebean.bean.EntityBeanIntercept.preGetter(EntityBeanIntercept.java:914) at models.Security._ebean_get_status(Security.java:6)
Diagnosis
For Java:There is probably a @OnetoMany
or a @ManyToOne
mapping that is faulty.
For Kotlin:There is probably a @OnetoMany
or a @ManyToOne
mapping that is faulty.
Actions
1. Check the mappings in the model class that is throwing the exception.
In our example above, it is themodels.Security
class. Comment out each mapping until the exception goes away, then you have identified the problem.
RuntimeException: Is class org.example.domain.Foo registered?
Diagnosis
Ebean does not think the bean in question is an entity bean, or we are explicitly registering entity beans (via ServerConfig.addClass()) and have not added the entity bean to that.
Actions
1. Check that the bean has @Entity
annotation
2. Register the entity bean if necessary
If the entity beans are being explicit registered via serverConfig.addClass()
then it could
be that this entity bean class needs to also be included.
Typically stacktrace
Caused by: java.lang.RuntimeException: Error with association to [class org.example.domain.Contact]
from [org.example.domain.Customer.contacts]. Is class org.example.domain.Contact registered?
at io.ebeaninternal.server.deploy.parse.AnnotationAssocManys.readToOne(AnnotationAssocManys.java:476)
at io.ebeaninternal.server.deploy.parse.AnnotationAssocManys.read(AnnotationAssocManys.java:73)
at io.ebeaninternal.server.deploy.parse.AnnotationAssocManys.parse(AnnotationAssocManys.java:64)
at io.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:50)
... 37 more
DataSource user is null?
Actions
1. Check that there is a application-test.yml (or equivalent) to specify the datasource
2. Check that io.ebean : ebean-test
is a test dependency
See docs / testing for setting up ebean-test
Typically stacktrace
ERROR io.ebean.Ebean - Error trying to create the default EbeanServer
java.lang.RuntimeException: DataSource user is null?
at org.avaje.datasource.pool.ConnectionPool.<init>(ConnectionPool.java:207)
at org.avaje.datasource.core.Factory.createPool(Factory.java:15)
at io.ebeaninternal.server.core.DefaultContainer.getDataSourceFromConfig(DefaultContainer.java:273)
at io.ebeaninternal.server.core.DefaultContainer.setDataSource(DefaultContainer.java:217)
...