8 Replies Latest reply on Dec 18, 2013 5:37 PM by jmanko

    Error with Quickstart picketlink-authorization-idm-jpa

    jmanko

      Error occurred during deployment: Exception while preparing the app : Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException

      Exception Description: Predeployment of PersistenceUnit [picketlink-default] failed.

      Internal Exception: Exception [EclipseLink-7212] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException

      Exception Description: The attribute [expiryDate] from the entity class [class org.picketlink.idm.jpa.model.sample.simple.AbstractCredentialTypeEntity] does not specify a temporal type. A temporal type must be specified for persistent fields or properties of type java.util.Date and java.util.Calendar.. Please see server.log for more details.

        • 1. Re: Error with Quickstart picketlink-authorization-idm-jpa
          jmanko

          So, I guess PicketLink (default entity implementation) doesn't work with EclipseLink, and thus Glassfish.  Any plans on fixing this?

           

          https://github.com/picketlink/picketlink/tree/master/modules/idm/simple-schema/src/main/java/org/picketlink/idm/jpa/model/sample/simple

           

          @MappedSuperclass

          public abstract class AbstractCredentialTypeEntity implements Serializable {

           

              @EffectiveDate

              @Temporal(TemporalType.DATE)

              private Date effectiveDate;

           

              @ExpiryDate

              @Temporal(TemporalType.DATE)

              privateDateexpiryDate;


           

           

           

          @IdentityManaged (IdentityType.class)

          @Entity

          @Inheritance(strategy = InheritanceType.JOINED)

          public class IdentityTypeEntity extends AttributedTypeEntity {

           

              @AttributeValue

              @Temporal(TemporalType.DATE)

              private Date createdDate;

           

              @AttributeValue

              @Temporal(TemporalType.DATE)

              private Date expirationDate;

          • 2. Re: Error with Quickstart picketlink-authorization-idm-jpa
            shane.bryzak

            I've added the @Temporal annotation to these fields now.  Thanks for letting us know!

             

             

            [PLINK-302] Annotate date fields in the simple schema with @Temporal - JBoss Issue Tracker

            • 3. Re: Error with Quickstart picketlink-authorization-idm-jpa
              antohax

              Thanks for this. I fixed this previously in my project with orm.xml like this:

              <entity class="AbstractCredentialTypeEntity" metadata-complete="false">

                <table name="idm_abstract_credential_type_entity"/>

                <attributes >

                     <basic name="expiryDate">

                     <temporal>TIMESTAMP</temporal>

                     </basic>

                     <basic name="effectiveDate">

                     <temporal>TIMESTAMP</temporal>

                     </basic>

                </attributes>

                </entity>


              But I have another error with picketlink + eclipselink. I found out that it is a mistake eclipselink.

              Sall come from afar.

              A little example with two classes:

               

              @Entity

              public class Entity implements Serializable {

                @Id

                 @GeneratedValue

                private String id;

              //getters and setters

              }

               

              @javax.persistence.Entity

              public class Identity implements Serializable {

                @Id

                @GeneratedValue

                private String id;

                @ManyToOne

                @JoinColumn(name = "OWNER_ID", referencedColumnName = "ID")

                private Entity owner;

              //getters and setters

              }

               

              Test database on mysql:

              CREATE TABLE `entity` (

                `ID` varchar(255) NOT NULL,

                PRIMARY KEY (`ID`)

              ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

               

              INSERT INTO `entity` VALUES ('aaa');

              INSERT INTO `entity` VALUES ('bbb');

              INSERT INTO `entity` VALUES ('ccc');

              INSERT INTO `entity` VALUES ('ddd');

               

              DROP TABLE IF EXISTS `identity`;

              CREATE TABLE `identity` (

                `ID` varchar(255) NOT NULL,

                `OWNER_ID` varchar(255) NOT NULL,

                PRIMARY KEY (`ID`)

              ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

               

              INSERT INTO `identity` VALUES ('1', 'aaa');

              INSERT INTO `identity` VALUES ('2', 'yyy');

              INSERT INTO `identity` VALUES ('3', 'zzz');

              INSERT INTO `identity` VALUES ('4', 'ccc');

              INSERT INTO `identity` VALUES ('5', 'xxx');

              I tested in war application in glassfish 4:

              1) JPQL this query is working as excected:

              Query query = em.createQuery("select r from Entity r where r in (select e.owner from Identity e)");

              System.out.println(query.getResultList());//Two records

               

              2) Criteria api query is not working:

              CriteriaBuilder cb = em.getCriteriaBuilder();

              CriteriaQuery<?> cq = cb.createQuery(Entity.class);

              Root from = cq.from(Entity.class);

              Subquery<?> subquery = cq.subquery(Identity.class);

              Root subRoot = subquery.from(Identity.class);

              subquery.select(subRoot.get("owner"));

              cq.select(from);

              cq.where(cb.in(from).value(subquery));

              System.out.println(em.createQuery(cq).getResultList());//Exception

               

              Exception [EclipseLink-6048] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.QueryException

              Exception Description: Illegal use of getField() [entity.ID] in expression.

              Query: ReadAllQuery(referenceClass=Entity )

               

              But if I change requests as follows, it will work perfectly:

              1) JPQL this query is working as excected:

              Query query = em.createQuery("select r from Entity r where r.id in (select e.owner.id from Identity e)");

              System.out.println(query.getResultList());//Two records

               

              2) Criteria api query is not working:

              CriteriaBuilder cb = em.getCriteriaBuilder();

              CriteriaQuery<?> cq = cb.createQuery(Entity.class);

              Root from = cq.from(Entity.class);

              Subquery<?> subquery = cq.subquery(Identity.class);

              Root subRoot = subquery.from(Identity.class);

              subquery.select(subRoot.get("owner").get("id"));

              cq.select(from);

              cq.where(cb.in(from.get("id")).value(subquery));

              System.out.println(em.createQuery(cq).getResultList()); //Two records

               

              I will write about this error in  eclipselink community  , but it can take a very long time. 

              We return to the picketlink.  

              I have the same error in Criteria API in the next call:

              BasicModel.hasRole(relationshipManager, identity.getAccount(), role);

              Could you close the error something like this (compare entity ID in 'IN clause' and not entirely entity) in JPAIdentityStore:

              https://github.com/picketlink/picketlink/blob/master/modules/idm/impl/src/main/java/org/picketlink/idm/jpa/internal/JPAIdentityStore.java

               

              Subquery<?> subquery = cq.subquery(relationshipMemberMapper.getEntityType());

                Root fromRelationshipIdentityType = subquery.from(relationshipMemberMapper.getEntityType());

                subquery.select(fromRelationshipIdentityType.get(relationshipProperty.getName()).get("id"));//Id-field name taken from the meta-description of course

               

                Property<String> descriptorProperty = relationshipMemberMapper.getProperty(RelationshipDescriptor

                .class).getValue();

               

                Predicate conjunction = cb.conjunction();

               

                conjunction.getExpressions().add(

                cb.equal(fromRelationshipIdentityType.get(descriptorProperty.getName()),

                identityTypeParameter.getName()));

               

                Property<Object> identityProperty = relationshipMemberMapper.getProperty(RelationshipMember.class).getValue();

               

                if (identityProperty.getJavaClass().equals(String.class)) {

                conjunction.getExpressions().add(fromRelationshipIdentityType.get(identityProperty.getName()).in(identityTypeIdentifiers));

                } else {

                Join join = fromRelationshipIdentityType.join(identityProperty.getName());

                EntityMapper identityTypeMapper = getMapperForEntity(identityProperty.getJavaClass());

                Property identifierProperty = identityTypeMapper.getProperty(Identifier.class).getValue();

               

                conjunction.getExpressions().add(join.get(identifierProperty.getName()).in(identityTypeIdentifiers));

                }

               

                subquery.where(conjunction);

               

                predicates.add(cb.in(from.get("id")).value(subquery));

              • 4. Re: Error with Quickstart picketlink-authorization-idm-jpa
                pcraveiro

                Hi,

                 

                   I've made some changes to the JPA store to get EclipseLink fully supported. Our test suite is now configured to run all IDM tests using EclipseLink as well Hibernate.

                 

                   Wondering if you can try out a SNAPSHOT version to see if you can get your app working.

                 

                Regards.

                • 5. Re: Error with Quickstart picketlink-authorization-idm-jpa
                  jmanko

                  I'll play with it next week.  Thanks.

                  • 6. Re: Error with Quickstart picketlink-authorization-idm-jpa
                    pcraveiro

                    You can try 2.5.3.Beta1, instead of SNAPSHOT.

                    • 7. Re: Error with Quickstart picketlink-authorization-idm-jpa
                      jmanko

                      Pedro,I just got back on this.  Sorry for the delay.  So, I just deployed an EAR project to glassfish.  Although no errors occurred, I received a few warnings in the log (see below).  Additionally, PicketLink Reference Documentation does not indicate that "static" is required on the @Produce property.  I should note that I have to add the code in section "8.1.2. Configuring an EntityManager" before the tables were generated.  I've always thought that tables were generated upon deployment, but I could be wrong.

                       

                      I should also note that a Sequence table was generated.  This is usually a result of an ID primary key being annotated as @GeneratedValue(strategy = GenerationType.SEQUENCE).  I've never liked that, and prefer @GeneratedValue(strategy = GenerationType.IDENTITY) (ie, auto increment of the ID column).  Is there any way to change that?

                       

                      WARNING:   AS-CDI-005

                      WARNING:   AS-CDI-005

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type S from public void org.picketlink.idm.credential.handler.PasswordCredentialHandler.setup(S) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.spi.CredentialStore<?> from public void org.picketlink.idm.credential.handler.TOTPCredentialHandler.setup(org.picketlink.idm.spi.CredentialStore<?>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.spi.CredentialStore<?> from public void org.picketlink.idm.credential.handler.AbstractCredentialHandler.setup(S) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.model.Attribute<? extends java.io.Serializable> from public void org.picketlink.idm.model.AbstractAttributedType.setAttribute(org.picketlink.idm.model.Attribute<? extends java.io.Serializable>) is not resolvable to a concrete type.

                      WARNING:   The following warnings have been detected: WARNING: Parameter 1 of type org.picketlink.idm.spi.CredentialStore<?> from public void org.picketlink.idm.credential.handler.AbstractCredentialHandler.setup(S) is not resolvable to a concrete type.

                      • 8. Re: Error with Quickstart picketlink-authorization-idm-jpa
                        jmanko

                        Wow, I have to thank you guys for putting the bug in my head on the GenerationType issue.  I just learned that EclipseLink does make use of orm.xml if one exists, which will allow me to override the GenerationType with one I want (since AUTO is the default, which is the case for these entities).  Awesome.