Tuesday, August 14, 2018

Oracle DB Invalid Objects

Some usefuls commands to troubleshoot:

select count(*) from USER_OBJECTS where OBJECT_TYPE = 'TABLE';
select count(*) from user_objects where object_type='TYPE';
select count(*) from user_tables;

select * from USER_OBJECTS where STATUS = 'INVALID';



exec dbms_utility.compile_schema( 'MYUSER' );

alter package MYPACKAGE COMPILE;

alter package MYPACKAGE COMPILE BODY;

show errors;

select * from user_errors ;





References:

https://oracle-base.com/articles/misc/recompiling-invalid-schema-objects

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:637156098168



Thursday, August 2, 2018

CDI and WELD suck

A @Stateless bean could not be injected because not found by WELD

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type PersistenceService with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private com.pippo.pluto.paperino.rest.MafaldaController.persistenceService
  at com.pippo.pluto.paperino.rest.MafaldaController.persistenceService(MafaldaController.java:0)

 at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:362)
 at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
 at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:137)
 at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:158)
 at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:501)
 at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:61)
 at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:59)
 at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
 at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
 at org.jboss.threads.JBossThread.run(JBossThread.java:320)

https://docs.jboss.org/author/display/WFLY10/CDI+Reference

Even if the bean is a session bean, the archive (.jar) is not an “explicit bean archives (basically any archive containing the beans.xml file)“ because it doesn’t contain a beans.xml file (only the war file has a beans.xml file).

Since CDI 1.1 an archive can be implicit : “An implicit bean archive is any archive that contains one or more classes annotated with a bean defining annotation (scope annotation) or one or more session beans.”. Implicit archives don’t need a beans.xml.

But by default “implicit” is disabled! To enable it, you can either do the jboss-all.xml trick or do the “subsystem=weld:write-attribute(name=require-bean-descriptor,value=true)” trick. See again https://docs.jboss.org/author/display/WFLY10/CDI+Reference for more details. Or, you can simply add a beans.xml to the JAR.


If all this sounds to you like complete chaos and needless complication, it’s because it is!


Sunday, July 22, 2018

Spring Boot Security 5 and Oauth2




https://github.com/jgrandja/springone2017-demo


Ultimate guide and examples:

https://docs.spring.io/spring-security/site/docs/5.1.0.M1/reference/htmlsingle/

https://github.com/spring-projects/spring-security/blob/5.1.0.M1/samples/boot/oauth2login/README.adoc



Here a very rich presentation on Oauth2:

https://ordina-jworks.github.io/microservices/2017/09/26/Secure-your-architecture-part1.html

https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2


Spring boot Oauth2 https://spring.io/guides/tutorials/spring-boot-oauth2/



A simple application: https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_simple
Code is here https://github.com/spring-guides/tut-spring-boot-oauth2.git or also https://github.com/vernetto/springboottests/tree/master/ui

Here the OAuth2 specs https://tools.ietf.org/html/rfc6749#section-4

Nice simplified and compact presentation https://aaronparecki.com/oauth-2-simplified/


Baeldung example for Oauth2 here https://github.com/eugenp/tutorials/tree/master/spring-5 with explanation here http://www.baeldung.com/spring-security-5-oauth2-login