Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] NullPointerException with eclipselink-orm.xml

Hi Laird,

Read only should be an attribute and not an element, that is:

  <mapped-superclass class="com.foobar.identity.jpa.AbstractClassifier" read-_only_="true"/>

Curious if that fixes the NPE?

Cheers,
Guy


On 16/03/2011 7:38 PM, Laird Nelson wrote:
I have JPA-compliant entities (i.e. no provider-specific annotations or library dependencies).

I am (still, fruitlessly) trying to implement the common use case of retrieving U. S. states as read-only, heavily cached, etc.

After bumbling through the voluminous documentation, I happened across the eclipselink.read-only query hint, the @ReadOnly annotation, and the <read-only> element.  These look more promising than the other three or four alternatives I've mentioned on this list previously (and I'm still not sure which is the "proper" way to indicate that my 50 states are to be cached once and then never retrieved again from the database).

It just so happens that all my entities that are to be treated in this fashion inherit from a common mapped superclass (which I've named AbstractClassifier).  So I thought hey, I'll just use the eclipse-orm.xml to "decorate" my existing JPA entities with this additional <read-only>true</read-only> element.

So I put my eclipselink-orm.xml file next to my persistence.xml file, and next to my orm.xml file in the META-INF directory of my persistence unit.

It looked like this:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd" version="2.1">
  <mapped-superclass class="com.foobar.identity.jpa.AbstractClassifier">
    <read-only>true</read-only>
  </mapped-superclass>
</entity-mappings>

EclipseLink (as shipped with Glassfish 3.1) had this to say about it:

Exception Description: Predeployment of PersistenceUnit [LEAD] failed.
Internal Exception: java.lang.NullPointerException
Local Exception Stack:
Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [LEAD] failed.
Internal Exception: java.lang.NullPointerException
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1127)
    at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:187)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:205)
    [etc.]
Caused by: java.lang.NullPointerException
    at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.getProject(MetadataDescriptor.java:1076)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.<init>(ClassAccessor.java:225)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.<init>(MappedSuperclassAccessor.java:204)
    at org.eclipse.persistence.internal.jpa.metadata.ORMetadata.reloadMappedSuperclass(ORMetadata.java:550)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addPotentialMappedSuperclass(ClassAccessor.java:498)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.discoverMappedSuperclassesAndInheritanceParents(EntityAccessor.java:258)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(EntityAccessor.java:497)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage1(MetadataProject.java:1504)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:484)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:454)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1081)
    ... 36 more

I take it that doesn't work?

I will now attempt the query hint.

Any concrete real-world examples of how to cache a set of entities from the database would be most appreciated.

Best,
Laird
_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top