Mantis - Resin
Viewing Issue Advanced Details
3071 major always 11-13-08 12:10 12-15-08 09:22
dicr  
ferg  
normal  
closed 3.2.1  
fixed  
none    
none 4.0.0  
0003071: EJB 3.0 may not have public constructor
[22:06:22.246] {http--8443-9} Caused by: com.caucho.config.ConfigException: 'org.dicr.isp.ejb.PaymentDO' needs a public or protected no-arg constructor. Entity beans must have a public or protected no-arg constructor.
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.AbstractConfigIntrospector.validateConstructor(AbstractConfigIntrospector.java:187)
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.AbstractConfigIntrospector.validateType(AbstractConfigIntrospector.java:160)
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.EntityIntrospector.introspectEntityType(EntityIntrospector.java:254)
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.EntityIntrospector.introspect(EntityIntrospector.java:105)
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.AmberConfigManager.introspect(AmberConfigManager.java:85)
[22:06:22.246] {http--8443-9} at com.caucho.amber.manager.AmberPersistenceUnit.addEntityClass(AmberPersistenceUnit.java:510)
[22:06:22.246] {http--8443-9} at com.caucho.amber.cfg.PersistenceUnitConfig.init(PersistenceUnitConfig.java:343)
@Entity
public class PaymentDO implements Serializable {
    protected PaymentDO() {
        super();
    }
}

There will no error, if I will change constructor to 'public'.
But error says 'public or protected no-arg constructor'.

Notes
(0003550)
dicr   
11-17-08 19:41   
ejb-3_0-fr-spec-persistence.pdf
2.1 Requirements on the Entity Class

"The entity class must have a no-arg constructor. The entity class may have other constructors as well. The no-arg constructor must be public or protected."

But Resin accept only public constructor. In my application public constructor is not acceptable, because I want to force use of my beans by user with right constructor with arguments. For example, I need to allow user to use:

@Entity
public class LoginDO {
    @Basic private String _name;

    protected LoginDO() {
        super();
    }

    public LoginDO(String name) {
        this.setName(name);
    }

    public void setName(String name) {
        if (name == null || name.length() < 1) throw new IllegalArgumentException("incorrect name");
        this._name = name;
}

I need to hide non-arg constructpr from user with 'protected' access.
But resin force me to make non-arg constructor public :(
(0003637)
ferg   
12-15-08 09:22   
jpa/0g0r