[keycloak-user] Photoz Authz example DB issue

Ilya Korol llivezking at gmail.com
Mon Apr 10 22:23:11 EDT 2017


Oh, i wrongly put it. I failed to build or test keycloak itself, not the 
example (I'm talking about guide at github/keycloak/keycloak/README.md). 
So, i downloaded standalone keycloak distribution (2.5.5) and 
appropriate archive with examples, and after deploy i got mentioned NPE 
errors (that refers to DB issues).


P.S. I've just run:

     mvn clean

     mvn install

And tests failed somewhere at BaseTestSuite, so then i run following 
command to create log file for posting it in JIRA:

     mvn clean

     mvn install | tee mvn_install.log.txt

And all builds and tests passes!!!111 WTF?. Then i successfully run

     mvn install -Pdistribution

Then i wanted to run created distribution. README.md says that i should run

     tar xfz 
distribution/appliance-dist/target/keycloak-appliance-dist-all-<VERSION>.tar.gz
     cd keycloak-appliance-dist-all-<VERSION>/keycloak
     bin/standalone.sh

but i didn't find any anything like 'appliance-dist'. Then i found 
distribution/demo-dist directory and run distribution in 
keycloak-demo-3.0.1.Final-SNAPSHOT.tar.gz. I successfully deployed 
/examples/authz/photoz from this archive to keycloak and everything is 
working right now! Cool.


P.P.S I also faced mini issue with rule policy from this example:

After importing Authorization settings to photoz-restful-api client i 
went to authorization->policies->only owner policy. This policy based on 
org.keycloak:photoz-authz-policy:${project.version} maven artifact with 
Drools rules. But resolving of this artifact were failing until i 
manually specify 3.0.1.Final-SNAPSHOT version (i also checked Server 
Info entry in server-info Keycloak page: it is 3.0.1.Final-SNAPSHOT, so 
is it a bug?).


Anyway thanks for help!


On 10.04.2017 22:27, Pedro Igor Silva wrote:
> Hi Ilya, it should work right OOTB. Can you please fill a JIRA with 
> more information about the issues you are facing ?
>
> If you are building from upstream/master it should work fine. Also, 
> this quickstart is mainly targeted for Wildfly/EAP.
>
> Regards.
> Pedro Igor
>
> On Mon, Apr 10, 2017 at 4:05 AM, Ilya Korol <llivezking at gmail.com 
> <mailto:llivezking at gmail.com>> wrote:
>
>     Hi, i'm trying to realize how does authz work in keycloak, therefore i
>     tried to run keycloak/examples/authz/photoz project. I failed to
>     run it
>     from git sources (i'm even failed to build or test it!), so i
>     downloaded
>     examples.zip from keycloak.org <http://keycloak.org>. I
>     successfully built and deployed jars
>     to keycloak instance, but when i go to specified in README.md urls
>     (http://localhost:8080/photoz-html5-client/#/album/create
>     <http://localhost:8080/photoz-html5-client/#/album/create> ...) i see
>     NPEs in keycloak logs. This errors refers to any code like:
>
>     this.entityManager.createQuery("from Album where name = :name and
>     userId
>     = :userId");
>
>     I checked persistence.xml:
>
>          <persistence-unit name="primary"
>     transaction-type="RESOURCE_LOCAL">
>     <provider>org.hibernate.ejb.HibernatePersistence</provider>
>
>     <class>org.keycloak.example.photoz.entity.Album</class>
>     <class>org.keycloak.example.photoz.entity.Photo</class>
>
>              <properties>
>                  <property name="hibernate.dialect"
>     value="org.hibernate.dialect.H2Dialect" />
>                  <property name="hibernate.connection.driver_class"
>     value="org.h2.Driver" />
>                  <property name="hibernate.connection.url"
>     value="jdbc:h2:~/keycloak-photoz-example" />
>                  <property name="hibernate.connection.user" value="sa" />
>                  <property name="hibernate.flushMode"
>     value="FLUSH_AUTO" />
>                  <property name="hibernate.hbm2ddl.auto" value="update" />
>                  <property name="hibernate.show_sql" value="false" />
>              </properties>
>          </persistence-unit>
>
>
>     Do i have to make any DB bootstrapping actions or this project should
>     work right out of the box?
>
>     _______________________________________________
>     keycloak-user mailing list
>     keycloak-user at lists.jboss.org <mailto:keycloak-user at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/keycloak-user
>     <https://lists.jboss.org/mailman/listinfo/keycloak-user>
>
>



More information about the keycloak-user mailing list