-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Validator problem with embedded, embedded object
PostPosted: Mon Feb 12, 2007 11:40 am 
Newbie

Joined: Wed Feb 07, 2007 1:10 pm
Posts: 7
Location: Kent, UK
Hi,

I have the following code, when I uncomment the @Valid annotation in OrderLine.java I get a NullPointerException on deploying the application. Without the annotation, it deploys correctly and works, but obviously without any validation. The problem appears to be caused by having nested @Embeddable objects!

I am using JBoss 4.0.5.GA which I installed using the ejb3 profile of jems-installer-1.2.0.GA.jar.

I have then replaced the bundled hibernate 3.2.0.GA jar files

jboss-4.0.5.GA\server\default\lib\hibernate3.jar
jboss-4.0.5.GA\server\default\lib\hibernate-annotations.jar
jboss-4.0.5.GA\server\default\lib\hibernate-entitymanager.jar

with the latest versions downloaded from http://www.hibernate.org/6.html

Hibernate 3.2.2.GA
Hibernate Annotation 3.2.1.GA
Hibernate Entity Manager 3.2.1.GA

OrderLine.java
Code:
@Entity
@Table(name="INORDER")
public class OrderLine implements Serializable {

    ...

    private Order order;

    ...
   
//    @Valid
    @Embedded
    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }
}


Order.java
Code:
@Embeddable
public class Order implements Serializable {

    ...

    private Address address;

    ...

    @Valid
    @Embedded
    @AttributeOverrides({
        @AttributeOverride(name="addressLine1", column=@Column(name="ADDRESS_LINE_1")),
        @AttributeOverride(name="addressLine2", column=@Column(name="ADDRESS_LINE_2")),
        @AttributeOverride(name="addressLine3", column=@Column(name="ADDRESS_LINE_3")),
        @AttributeOverride(name="town", column=@Column(name="TOWN")),
        @AttributeOverride(name="county", column=@Column(name="COUNTY")),
        @AttributeOverride(name="postcode", column=@Column(name="POSTCODE")),
        @AttributeOverride(name="country", column=@Column(name="COUNTRY"))
    })
    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }
}


Address.java
Code:
@Embeddable
public class Address implements Serializable {

    private String addressLine1;
   
    private String addressLine2;
   
    private String addressLine3;
   
    private String town;
   
    private String county;
   
    private String postcode;
   
    private String country;

    @NotNull
    public String getAddressLine1() {
        return addressLine1;
    }

    public void setAddressLine1(String addressLine1) {
        this.addressLine1 = addressLine1;
    }

    public String getAddressLine2() {
        return addressLine2;
    }

    public void setAddressLine2(String addressLine2) {
        this.addressLine2 = addressLine2;
    }

    public String getAddressLine3() {
        return addressLine3;
    }

    public void setAddressLine3(String addressLine3) {
        this.addressLine3 = addressLine3;
    }

    @NotNull
    public String getTown() {
        return town;
    }

    public void setTown(String town) {
        this.town = town;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    @NotNull
    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    @NotNull
    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }
}


Stack Trace
Code:
java.lang.NullPointerException
   at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:142)
   at org.hibernate.validator.ClassValidator.createChildValidator(ClassValidator.java:252)
   at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:216)
   at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:149)
   at org.hibernate.validator.ClassValidator.createChildValidator(ClassValidator.java:252)
   at org.hibernate.validator.ClassValidator.initValidator(ClassValidator.java:216)
   at org.hibernate.validator.ClassValidator.<init>(ClassValidator.java:134)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:318)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
   at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
   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:585)
   at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:102)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
   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:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:417)
   at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
   at $Proxy355.start(Unknown Source)
   at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:96)
   at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:467)
   at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:317)
   at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
   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:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:417)
   at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
   at $Proxy28.start(Unknown Source)
   at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:449)
   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:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
   at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
   at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
   at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
   at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
   at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
   at $Proxy29.start(Unknown Source)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
   at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
   at $Proxy8.deploy(Unknown Source)
   at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
   at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 12:21 pm 
Newbie

Joined: Wed Feb 07, 2007 1:10 pm
Posts: 7
Location: Kent, UK
Doh, there already a JIRA entry for it!

http://opensource.atlassian.com/project ... se/ANN-511

Any idea when the next version of Hibernate Annotations will be released?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As usual, not firm delay but I hope soonish.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 6:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Here is the revision number if you can't wait
http://fisheye.jboss.org/changelog/Hibernate/?cs=11054

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.