[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] NullPointer trying JPA2 (MetamodelImpl.java:370)
|
Diego,
1) Looks like your manually generated "Status_.java" canonical class
may be missing an import reference to "Status_.java" - this would cause
generation of the javaType for the "status" OneToOne to fail - however
the NPE needs to be fixed and replaced with a warning that the canonical
model is incomplete.
Try generating your "_" classes with the command in 2) below, or use
the dynamic non-canonical ones created in memory during deployment.
For...
public static volatile SingularAttribute<Usuario, Status> status;
Add just after your package declaration...
import your.package.Status;
As a result of this, the javaType of "Status" is not set on the
"status" SingularAttribute.
The fix will be to reference your other Status class.
However, the NPE in this case needs to be addressed by keeping
the superType as null == root level object
I have raised bug #297928 to fix this in 2.0.1
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297928
// Assign all superType fields on all IdentifiableTypes (only
after all managedType objects have been created)
for(ManagedTypeImpl<?> potentialIdentifiableType :
managedTypes.values()) {
Class aClass = potentialIdentifiableType.getJavaType();
/**
* The superclass for top-level types is Object - however we
set [null] as the supertype for root types.
* 1) We are constrained by the fact that the spec requires
that a superType be an IdentifiableType.
* Since [Object] is not an Entity or MappedSuperclass -
it fails this criteria - as it would be a BasicType
* because it has no @Entity or @MappedSuperclass
annotation.<p>
* 2) Another object space reasoning issue behind this is to
separate the Java and Metamodel object spaces.
* In Java all types inherit from Object, however in the JPA
Metamodel all types DO NOT inherit from a common type.
* Therefore in the metamodel top-level root types have a
superType of null.
* See design issue discussion:
*
http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_42:_20090709:_IdentifiableType.supertype_-_what_do_top-level_types_set_it_to
*/
370--> Class superclass = aClass.getSuperclass();
2) You can generate the "_" canonical metamodel classes using the
following line, eclipse integration is in progress.
http://wiki.eclipse.org/UserGuide/JPA/Using_the_Canonical_Model_Generator_%28ELUG%29
Here is an example generation of "_" java files without
corresponding compiled class files (-proc:only) - placed at the cmd root
Depending on your IDE, you will be able to automatically generate
these as long as the services file is in your classpath.
javac -processor
org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
-proc:only -classpath
lib/eclipselink.jar;lib/javax.persistence_2.0_preview.jar;punit
src/org/eclipse/persistence/testing/models/jpa/metamodel/*.java
thank you
/michael
Diego Coronel wrote:
Hi,
Im trying JPA2 using glassfish V3 final, Weld, and im getting this error:
Caused by: java.lang.NullPointerException
at
org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.initialize(MetamodelImpl.java:370)
at
org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:101)
at
org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.<init>(MetamodelImpl.java:120)
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.getMetamodel(EntityManagerSetupImpl.java:1939)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:472)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getCriteriaBuilder(EntityManagerFactoryImpl.java:456)
at
com.sun.enterprise.container.common.impl.EntityManagerFactoryWrapper.getCriteriaBuilder(EntityManagerFactoryWrapper.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
at
javax.persistence.EntityManagerFactory_$$_javassist_32.getCriteriaBuilder(EntityManagerFactory_$$_javassist_32.java)
at
com.fpf.model.security.dao.UsuarioDAO.getUsuario(UsuarioDAO.java:28)
at
com.fpf.web.security.login.Authenticator.isLogged(Authenticator.java:48)
at
com.fpf.web.security.login.Authenticator.authenticate(Authenticator.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
at
com.fpf.web.security.login.Authenticator_$$_javassist_31.authenticate(Authenticator_$$_javassist_31.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at
com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at
org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
at
org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:72)
at
com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
I have created by myself the entity and the metaModel
@StaticMetamodel( Usuario.class )
public abstract class Usuario_ {
public static volatile SingularAttribute<Usuario, Integer> id;
public static volatile SingularAttribute<Usuario, String> nome;
public static volatile SingularAttribute<Usuario, String> password;
public static volatile SingularAttribute<Usuario, String> login;
public static volatile SingularAttribute<Usuario, Status> status;
}
but its not working, so, what could be wrong ?? is there any docs for
configure eclipse to auto generate these metamodels ?? ty
sry about english.