Wednesday, June 19, 2024

Stock Market Data - Using Python to retrieve data from Yfinance library

 Hi, my friends. It's been a long time since I posted here. I am now coding with Python and retrieving data from the Yahoo Finance library for my analysis and studies.



At the command line, you should see these:



Then as your dataset result, you should see finally these:


Clicking in DataFrame:




I hope this helps you to start coding an retrieving datasets from the stock market for your analysis.


Kindly,

Thiago Leoncio.

Sunday, August 11, 2019

Eclipse common error

Hello everyone, today I am going to share one common error I got in Eclipse, and how I was able to fix it:

===================
ECLIPSE ERROR #1:--
===================

/Users/tleoncio/Thiago/code/.metadata/.log.


!SESSION 2019-08-10 14:42:38.841 -----------------------------------------------
eclipse.buildId=4.7.3.M20180330-0640
java.version=14.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product -keyring /Users/tleoncio/.eclipse_keyring
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.java.product -keyring /Users/tleoncio/.eclipse_keyring

!ENTRY org.eclipse.osgi 4 0 2019-08-10 14:42:43.915
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
        at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:410)
        at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
        at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:491)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:505)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:204)
        at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:614)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
        at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:124)
        at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:399)
        ... 22 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.100.v20170421-1418
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:433)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 24 more
and
!ENTRY org.eclipse.e4.ui.workbench 4 0 2019-08-10 14:42:43.919
!MESSAGE FrameworkEvent ERROR
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
        at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:450)
        at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:156)
        at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
        at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
        at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
        at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:178)
        at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:99)
        at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:141)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)
        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)
        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168)
        at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
        at org.eclipse.osgi.container.Module.doStop(Module.java:634)
        at org.eclipse.osgi.container.Module.stop(Module.java:498)
        at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:202)
        at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)
        at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.100.v20170421-1418
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:433)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 21 more




=========================
FIX FOR THIS ERROR: #1:--
=========================

1-GO TO YOUR ECLIPSE PATH: /Users/tleoncio/Thiago/eclipse/oxigen/Eclipse.app/Contents/Eclipse

and change the java version of your eclipse.ini.

-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20191219-1356.jar
--launcher.library
/Users/tleoncio/.p2/pool/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.551.v20171108-1834
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/


2- in my case it is: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home


I am sharing this because it helped me a lot, I hope it helps you,
Thiago Leoncio.

Monday, February 11, 2019

Java.lang.IllegalStateException: Workspace already contains a project with name

Hello all,

Sometimes when you try to import your project to eclipse from another copy of the project you have done before, you can get this type of error:

Java.lang.IllegalStateException: Workspace already contains a project with name ThiagoLeoncioService.
at com.google.common.base.Preconditions.checkState(Preconditions.java:150)
at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.includeProject(DefaultWorkspaceOperations.java:138)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addExistingEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:279)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:268)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:179)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:99)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:134)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:131)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:115)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:85)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:73)
at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62)
at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)



Solution:

1- Go to your project root folder
2-Check your build.gradle file and see if the baseName attribute is correct.
3- Check it there is a file like .project
4-Change this file for you new project name:
Eg:.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>ThiagoLeoncioService</name>
        <comment>Project reprocessing created by Buildship.</comment>
        <projects>
        </projects>
        <buildSpec>
                <buildCommand>
                        <name>org.eclipse.jdt.core.javabuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
                <buildCommand>
                        <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
                        <arguments>
                        </arguments>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>org.eclipse.jdt.core.javanature</nature>
                <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
        </natures>
</projectDescription>

2- Check if there is any remaining git repo information from the old project. Sometimes you can
copy a project rename all your classes, but it still in sync with git repo. To check that you can run
a basic git command : 'git branch' and see if it shows old branches there.

3-To remove those git references, execute the following command:
rm -rf .git

4-Check if there is any remaining info:
 find . | grep "\.git/" | xargs rm -rf

5- Now git branch should become master again.
execute command: git branch

You should be able to import your java project to eclipse now.


Have fun and happy coding.
Thiago

Saturday, January 5, 2019

ADF error: Failed to replicate non-serializable object. java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: Failed to load class

Hello everyone,


I've had an issue during my coding in ADF and I would like to share what I did to fix this issue here.

####<Jan 5, 2019 9:27:44 PM CST> <Error> <Cluster> <thiagoleoncio.oim.com> <oim_serverLeoncio> <[ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <afbe5002577ceeea:8f87540d2fab3:-8000-0000000000004037> <1549423664159> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.lang.ClassNotFoundException: Failed to load class thiagoleoncioBean
        at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
        at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
        at weblogic.cluster.replication.ReplicationManager_1036_WLStub.create(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor1495.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at weblogic.cluster.replication.SecureReplicationInvocationHandler$ReplicationServicesInvocationAction.run(SecureReplicationInvocationHandler.java:224)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.cluster.replication.SecureReplicationInvocationHandler.invoke(SecureReplicationInvocationHandler.java:194)
        at com.sun.proxy.$Proxy556.create(Unknown Source)
        at weblogic.cluster.replication.ReplicationManager.trySecondary(ReplicationManager.java:937)
        at weblogic.cluster.replication.ReplicationManager.createSecondary(ReplicationManager.java:890)
        at weblogic.cluster.replication.ReplicationManager.getPrimary(ReplicationManager.java:866)
        at weblogic.cluster.replication.ReplicationManager.lookup(ReplicationManager.java:428)
        at weblogic.servlet.internal.session.ReplicatedSessionContext.lookupSession(ReplicatedSessionContext.java:395)
        at weblogic.servlet.internal.ServletRequestImpl.getSession(ServletRequestImpl.java:1339)
        at weblogic.servlet.internal.session.ReplicatedSessionContext.lookupAppVersionIdForSession(ReplicatedSessionContext.java:549)
        at weblogic.servlet.internal.ServletRequestImpl.findVersionedContext(ServletRequestImpl.java:1705)
        at weblogic.servlet.internal.ServletRequestImpl.dispatchVersion(ServletRequestImpl.java:1658)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1478)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: java.lang.ClassNotFoundException: Failed to load class thiagoleoncioBean
        at weblogic.rmi.utils.WLRMIClassLoaderDelegate.loadClass(WLRMIClassLoaderDelegate.java:208)
        at weblogic.rmi.utils.WLRMIClassLoaderDelegate.loadClass(WLRMIClassLoaderDelegate.java:135)
        at weblogic.rmi.utils.Utilities.loadClass(Utilities.java:305)
        at weblogic.rjvm.MsgAbbrevInputStream.resolveClass(MsgAbbrevInputStream.java:452)
        at weblogic.utils.io.ChunkedObjectInputStream$NestedObjectInputStream.resolveClass(ChunkedObjectInputStream.java:274)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1864)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1750)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2036)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.HashMap.readObject(HashMap.java:1186)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at oracle.adfinternal.controller.state.SessionBasedScopeMap.readScopeMap(SessionBasedScopeMap.java:153)
        at oracle.adfinternal.controller.state.PageFlowScope.readObject(PageFlowScope.java:165)
        at sun.reflect.GeneratedMethodAccessor4034.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.concurrent.ConcurrentHashMap.readObject(ConcurrentHashMap.java:1574)
        at sun.reflect.GeneratedMethodAccessor4028.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2281)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2205)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2281)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2205)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.Hashtable.readObject(Hashtable.java:1015)
        at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at weblogic.servlet.internal.session.ReplicatedSessionData.readExternal(ReplicatedSessionData.java:145)
        at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2112)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2061)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:214)
        at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:618)
        at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:210)
        at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
        at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
>
####<Jan 5, 2019 9:27:44 PM CST> <Error> <Cluster> <thiagoleoncio.oim.com> <oim_serverLeoncio> <[ACTIVE] ExecuteThread: '10' for queue: 'weblogic.kernel.Default (self-tuning)'> <xelsysadm> <> <afbe5002577ceeea:8ffed7:168c0d2fab3:-8000-0000000000004037> <1549423664372> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
        java.lang.ClassNotFoundException: Failed to load class thiagoleoncioBean
        at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
        at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
        at weblogic.cluster.replication.ReplicationManager_1036_WLStub.create(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor1495.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at weblogic.cluster.replication.SecureReplicationInvocationHandler$ReplicationServicesInvocationAction.run(SecureReplicationInvocationHandler.java:224)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.cluster.replication.SecureReplicationInvocationHandler.invoke(SecureReplicationInvocationHandler.java:194)
        at com.sun.proxy.$Proxy556.create(Unknown Source)
        at weblogic.cluster.replication.ReplicationManager.trySecondary(ReplicationManager.java:937)
        at weblogic.cluster.replication.ReplicationManager.createSecondary(ReplicationManager.java:890)
    weblogic.servlet.internal.ServletRequestImpl$SessionHelper.syncSession(ServletRequestImpl.java:2963)
        at weblogic.servlet.internal.ServletResponseImpl$1.run(ServletResponseImpl.java:1520)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:1514)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1507)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused By: java.lang.ClassNotFoundException: Failed to load class thiagoleoncioBean
        at weblogic.rmi.utils.WLRMIClassLoaderDelegate.loadClass(WLRMIClassLoaderDelegate.java:208)
        at weblogic.rmi.utils.WLRMIClassLoaderDelegate.loadClass(WLRMIClassLoaderDelegate.java:135)
        at weblogic.rmi.utils.Utilities.loadClass(Utilities.java:305)
        at weblogic.rjvm.MsgAbbrevInputStream.resolveClass(MsgAbbrevInputStream.java:452)
        at weblogic.utils.io.ChunkedObjectInputStream$NestedObjectInputStream.resolveClass(ChunkedObjectInputStream.java:274)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1864)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1750)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2036)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.HashMap.readObject(HashMap.java:1186)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at oracle.adfinternal.controller.state.SessionBasedScopeMap.readScopeMap(SessionBasedScopeMap.java:153)
        at oracle.adfinternal.controller.state.PageFlowScope.readObject(PageFlowScope.java:165)
        at sun.reflect.GeneratedMethodAccessor4034.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.concurrent.ConcurrentHashMap.readObject(ConcurrentHashMap.java:1574)
        at sun.reflect.GeneratedMethodAccessor4028.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2281)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2205)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2281)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2205)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at java.util.Hashtable.readObject(Hashtable.java:1015)
        at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1171)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2172)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2063)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at weblogic.servlet.internal.session.ReplicatedSessionData.readExternal(ReplicatedSessionData.java:145)
        at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2112)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2061)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1572)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:430)
        at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:214)
        at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:618)
        at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:210)
        at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(Unknown Source)
        at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
        at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
        at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
>

To fix this issue in your ADF application:


  • First Step: in weblogic.xml change this:


  1. Session descriptor change: Memory option here means - single-server, non-replicated

     <session-descriptor>
    <persistent-store-type>memory</persistent-store-type>
    </session-descriptor>

  • Second Step: Serialization issue during the deployment sometimes is just a matter or testing in one single Managed Server. So, having said that. You need to change the 'architecture problem you are facing during the deployment'.
  1.           You need to stop the other managed servers during the deployment.
  2.           Then this error will not occur, as there will only be one version of the application when restarting after deployment of the new version.


I hope it helps you. Leave a comment if so!

Happy coding,
Thiago Leoncio.

Saturday, December 15, 2018

Azure AD authentication methods to be used

Hello everyone,

Microsoft Azure AD and on-premise provide a solution to create a common user identity for authentication and authorization to all resources, regardless of location. We call this hybrid identity.

To achieve a hybrid identity, one of three authentication methods can be used, depending on your scenarios. The three methods are:


Password hash synchronization (PHS)

Password hash synchronization is one of the sign-in techniques used to accomplish a hybrid identity.
 Azure AD Connect synchronizes a hash, of the hash, of a user's password from an on-premises Active Directory instance to a cloud-based Azure AD instance.



Password hash synchronization is an extension to the directory synchronization feature implemented by Azure AD Connect sync. You can use this feature to sign in to Azure AD services like Office 365.
 You sign in to the service by using the same password you use to sign in to your on-premises Active Directory instance.

What is Azure AD Connect

Password hash synchronization helps by reducing the number of passwords; your users need to maintain to just one. Password hash synchronization can:

Improve the productivity of your users.
Reduce your helpdesk costs.
Optionally, you can set up password hash synchronization as a backup if you decide to use Federation with Active Directory Federation Services (AD FS) as your sign-in method.

To use password hash synchronization in your environment, you need to:

Install Azure AD Connect.
Configure directory synchronization between your on-premises Active Directory instance and your Azure Active Directory instance.
Enable password hash synchronization.

Pass-through authentication (PTA)

What is Azure Active Directory Pass-through Authentication?
Azure Active Directory (Azure AD) Pass-through Authentication allows your users to sign in to both on-premises and cloud-based applications using the same passwords.
This feature provides your users with a better experience - one less password to remember and reduces IT helpdesk costs because your users are less likely to forget how to sign in.
 When users sign in using Azure AD, this feature validates users' passwords directly against your on-premises Active Directory.

This feature is an alternative to Azure AD Password Hash Synchronization, which provides the same benefit of cloud authentication to organizations. However, specific organizations wanting to enforce their on-premises Active Directory security and password policies can choose to use Pass-through Authentication instead.
Review this guide for a comparison of the various Azure AD sign-in methods and how to choose the right sign-in method for your organization.



Federation

Federation is a collection of domains that have established trust. The level of trust may vary, but typically includes authentication and almost always includes authorization. A typical federation might consist of some organizations that have established the trust for shared access to a set of resources.

You can federate your on-premises environment with Azure AD and use this federation for authentication and authorization.
This sign-in method ensures that all user authentication occurs on-premises. This method allows administrators to implement more rigorous levels of access control.
 Federation with AD FS and PingFederate is available.



Happy coding,
Thiago Leoncio.

Friday, September 28, 2018

nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.thiagoleoncio.thiagoG.entity.ProcessedRepository.findByACCOUNT_NUMBER(java.lang.String)! No property aCCOUNT found for type Processed!

Have gotten this error today:

SDSX-108-L:recordreprocessing tguimaraes$ ./gradlew bootRun

> Task :bootRun
2018-09-28 15:14:40.511  INFO 8214 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6c80d78a: startup date [Fri Sep 28 15:14:40 EDT 2018]; root of context hierarchy
2018-09-28 15:14:40.988  INFO 8214 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1a26ce66] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.1.RELEASE)

2018-09-28 15:14:41.208  INFO 8214 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://docker-dev-01.mic.thiagoleoncio.com:8888/
2018-09-28 15:14:41.486  INFO 8214 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=claim-reprocess-service,file-fetcher-library, profiles=[default], label=null, version=edfb09bdf68547e4fd217c32fe831d3372158a19, state=null
2018-09-28 15:14:41.486  INFO 8214 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://bitbucket.thiagoleoncio.com/scm/thiagoG/servicesconfiguration.git/thiagoG/file-fetcher-library.properties'}]}
2018-09-28 15:14:41.508  INFO 8214 --- [           main] c.s.d.ClaimReprocessServiceApplication   : No active profile set, falling back to default profiles: default
2018-09-28 15:14:41.524  INFO 8214 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6e15fe2: startup date [Fri Sep 28 15:14:41 EDT 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6c80d78a
2018-09-28 15:14:42.508  INFO 8214 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=refresh; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=false; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] with [Root bean: class [org.springframework.aop.scope.ScopedProxyFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
2018-09-28 15:14:42.685  INFO 8214 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=4d3c6ad7-210c-3d69-b466-1beae216a57e
2018-09-28 15:14:42.845  INFO 8214 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$fe0ccb69] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-28 15:14:42.902  INFO 8214 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$1a26ce66] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-28 15:14:43.330  INFO 8214 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-09-28 15:14:43.365  INFO 8214 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-09-28 15:14:43.365  INFO 8214 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-09-28 15:14:43.377  INFO 8214 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/tguimaraes/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-09-28 15:14:43.537  INFO 8214 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-09-28 15:14:43.537  INFO 8214 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2013 ms
2018-09-28 15:14:43.711  INFO 8214 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-28 15:14:43.712  INFO 8214 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-28 15:14:43.712  INFO 8214 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-28 15:14:43.712  INFO 8214 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-28 15:14:43.713  INFO 8214 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-09-28 15:14:43.714  INFO 8214 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-09-28 15:14:43.956  INFO 8214 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-09-28 15:14:44.148  INFO 8214 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-09-28 15:14:44.228  INFO 8214 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-09-28 15:14:44.262  INFO 8214 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
2018-09-28 15:14:44.387  INFO 8214 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.16.Final}
2018-09-28 15:14:44.389  INFO 8214 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-09-28 15:14:44.430  INFO 8214 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-09-28 15:14:44.564  INFO 8214 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-09-28 15:14:45.093  INFO 8214 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@19fbc594'
2018-09-28 15:14:45.096  INFO 8214 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-09-28 15:14:45.608  WARN 8214 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-09-28 15:14:45.948  WARN 8214 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/Users/tguimaraes/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/2.9.2/ed2ed714a6cba8804d00f80f0534901e4c7a3211/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/Users/tguimaraes/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/2.9.2/ed2ed714a6cba8804d00f80f0534901e4c7a3211/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processedRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.thiagoleoncio.thiagoG.entity.ProcessedRepository.findByACCOUNT_NUMBER(java.lang.String)! No property aCCOUNT found for type Processed!
2018-09-28 15:14:45.949  INFO 8214 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2018-09-28 15:14:45.949  INFO 8214 --- [           main] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed drop of schema as part of SessionFactory shut-down'
2018-09-28 15:14:45.955  INFO 8214 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2018-09-28 15:14:45.959  INFO 8214 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2018-09-28 15:14:45.960  INFO 8214 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-09-28 15:14:45.974  INFO 8214 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-09-28 15:14:45.987 ERROR 8214 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:/Users/tguimaraes/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/2.9.2/ed2ed714a6cba8804d00f80f0534901e4c7a3211/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/Users/tguimaraes/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/2.9.2/ed2ed714a6cba8804d00f80f0534901e4c7a3211/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processedRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.thiagoleoncio.thiagoG.entity.ProcessedRepository.findByACCOUNT_NUMBER(java.lang.String)! No property aCCOUNT found for type Processed!
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:729) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1270) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
        at com.thiagoleoncio.thiagoG.ClaimReprocessServiceApplication.main(ClaimReprocessServiceApplication.java:25) [main/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcRequestHandlerProvider' defined in URL [jar:file:/Users/tguimaraes/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/2.9.2/ed2ed714a6cba8804d00f80f0534901e4c7a3211/springfox-spring-web-2.9.2.jar!/springfox/documentation/spring/web/plugins/WebMvcRequestHandlerProvider.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processedRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.thiagoleoncio.thiagoG.entity.ProcessedRepository.findByACCOUNT_NUMBER(java.lang.String)! No property aCCOUNT found for type Processed!
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:729) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1270) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1325) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1291) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1193) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:815) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:721) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
        ... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processedRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.thiagoleoncio.thiagoG.entity.ProcessedRepository.findByACCOUNT_NUMBER(java.lang.String)! No property aCCOUNT found for type Processed!
   
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 8s
3 actionable tasks: 1 executed, 2 up-to-date




To FIX THIS ISSUE:

To quote the article on DZone:

"When Spring Data creates a new Repository implementation, it analyzes all the methods defined by the interfaces and tries
to automatically generate queries from the method name. While this has limitations, it is a very powerful and elegant way of defining new
custom access methods with very little effort. For example, if the managed entity has a name field (and the Java Bean standard getter and
setter for that field), defining the findByName method in the DAO interface will automatically generate the correct query:"

So, they way I fixed the issue was doing this on the entity class:

@Column(name = "ACCOUNT_NUMBER", nullable = true, updatable = false)
private String accountNumber;

Sunday, May 20, 2018

Collaborative Defense in Depth



Hurry up; collaboration is losing in Security.

Cybercriminals are sharing zero-day vulnerabilities and credentials, selling corporate infrastructure details, renting out botnets for attacks, and creating easy-to-use, complex, automated tools and armaments — all of which are getting sold on Dark Web. So, how can IT organizations defend against these threats? One possibility is to improve collaboration among good professionals, both within and across organizations.

How?

Dynamic security analytics with AI that combines orchestration beyond the diversity of threats (as well as characters and processes) can help set the foundation for a robust security maneuvering. Collude is the glue that integrates disparate point products in a manner that extends their security capabilities beyond what each technology could afford on its own. Going deeply on each of them helps to control and integrate many different products as well as collect, prevent, and detect the threat.


Here it's the traditional defense in depth framework we have:

Fig1: Traditional Defense in Depth framework

Traditional security practices are unsustainable because there are too many nonintegrated tools for understaffed IT security departments to manage. One primary example of this is the integration that lacks on enabling collaborative defense at the Endpoint level. Today we have many different companies to provide many different solutions(e.g., EndPoint control), Solutions Architects tend to select multiple vendors to provide their solution and implement the workflow.


The uncomfortable situation that organizations face today regarding the collaborative defense is outside of them. For many reasons, they lack trust with other companies.

  • Corporate policies that forbid the communication of threat intelligence outside the company;
  • Lack of resources to define processes or operationalize IT sharing back into the community; and
  • Lacking trust in relationships.
  • Lack of processes to anonymize and share threat intelligence back into the community;
  • Fear of obligation from threat intelligence sharing;


Empowering Collaborative Defense at the Endpoint

Cybercriminals are well organized to devastated companies. Security architects struggle with the speed of changes we are facing today. To make it work, we need to create an ecosystem that enables, collaboration using Defense-in-Depth over multiple vendor integrations that satisfies traditional security practices. 

Saturday, April 28, 2018

Auth0 - SPA - Single Page application - part 2

Hello all,


As part 2 of Auth0 development, I would like to show today what you need to work on your NodeJS code to make your single page application protected and use the best features of Auth0.


1. Remeber that for single page application we use a grant flow that we call Implicit Grant. In my case, I am using reponse_type=id_token token.
Fig1: Implicit flow using id_token token


2. For SPA, we have 3 basic ways to store our token:
2.1- Using Local Storages
2.2- Using Cookies
2.3-Using Session Storages

Fig2: 3 basic options to store tokens using SPA.


2.4- The fourth option provides more protection - In-memory.


Fig3: In-memory to store a token

3. Another good recommendation is clean up as much as possible using the onbeforeunload trigger.

Fig4: onbeforeunload window script for cleaning.

4. Working with SPA, you basically have only one HTML page that uses all 'div' and 'id' created from your NODEJS code. So, having said that:

Fig5: HTML piece that loads the profileview from app.js code


5. app.js function that calls an API(/userInfo) with access_token to collect a json information about user.
Fig6: app.js function calling API(/userInfo) 



Summary:

A single-page application (SPA) is a web application or website that interacts with the user by dynamically reworking the current page rather than loading entire new pages from a server.  We avoid interruption of the user experience between progressive pages, making the application act more like a desktop application.


Advantages

1. Best responsiveness – Server-side rendering is hard to implement for all the intermediate states – small view states do not map well to URLs. Single page apps are characterized by their ability to redraw any part of the UI without requiring a server roundtrip to retrieve HTML. 

2. Easy to deploy – A single page application is super-simple to deploy if compared to more traditional server-side rendered applications: it’s just one index.htmlfile, with a CSS bundle and a Javascript bundle. 

3. versioning and rollback – Another advantage of deploying our frontend as a single page application is a versioning and rollback. All we have to do is to version our build output (that produces the CSS and JS bundles highlighted in yellow above). 

4. Faster to load – If you have ever used a web application that is regularly reloading everything from the server on almost every user interaction, you will know that that type of application gives a poor user experience due to: the constant full page reloads; also due to the network back and forth trips to the server to fetch all that HTML. 

Disadvantages

Memory leaks – Pages are “long-lived” boosting the risk of memory leak issues. This can deteriorate UX and because of battery drain on mobile devices.


Thank you and happy coding,
Thiago Leoncio.



Sunday, April 22, 2018

Auth0 - how to integrate your application with this smart solution - Part 1

Hello everybody,


I would like to show today more about this great identity solution that I've been working on these days.

Auth0 widget gives you a fully customizable, enterprise-ready login/registration box with just a few lines of JavaScript, Java, Swift, or many other languages. The idea behind Auth0 identity as a service solution is to remove from your developers and time wasted with concerns about the authentication and authorization process. That alleviates and help the engineering team to focus on what is more important to the business.

Auth0 has many options for authentication, but by default, it uses OpenID connect to generate what we call IDToken and then, for authorization it uses OAuth protocol that generates and exchanges the AccessToken.

As I presented in my previous article here it's how OAuth flow works:


Here we have the most common grants and flows base on the application need:


What are the different type of apps:

1-Mobile/Native App

 - GRANT: Authorization Code using PKCE - Proof Key for Code Exchange.
 - Flow:
 1.1- Native APP(client) call /authorize endpoint
 1.2-Auth0 redirects with authorization_code in the querystring.
 1.3- Native app sends the authorization_code,code_verifier, redirect_Uri,and clientIDto Auth0.
 Using the /oauth/token endpoint
 1.4-Auth0 validates this information and returns access_token(opt: refresh_token)
 1.5-The native app can use the access_token to call the API on behalf of the user.


2-Single Page App
- GRANT: Implicit
- Flow:
1- The app initiates the flow and redirects the browser to Auth0(using /authorize endpoint),
so the user can authenticate.
2-Auth0 authenticates the user. The first time the user goes through this flow a consent page
will be shown where the permissions, that will be given to the application, are listed. For example:
post_messages, list contacts, and others.

3-Auth0 redirects the user to the app with an access_token(and optionally and id_token) in the hash
fragment of the URI. The app can extract the tokens from the hash fragment.
NOTE: In Single PAge application(SPA) this would be done using javascript and in a mobile application
this is typically handled by interacting with a Web View.

4- The app can use the access_token to call API on behalf of the user.



3-Web App

- GRANT: Authorization Code
- Flow:
1- The Web app initiates the flow and redirects the browser to Auth0(specifically to the /authorize endpoint).
So the user can be authenticated.

2- Auth0 authenticates the user, via the browser. The first time the user goes through this flow a consent the page will be shown where the permissions are listed that will be given to the application.
For example post messages, list contacts and so forth.

3-Auth0 redirects the user to the web app(specifically to redirect_uri, as specified in the
/authorize request) with an authorization code in the query string(code).

4-The web app sends the authorization code to Auth0 and asks to exchange it with an access_token
(and optionally an id_token and a refresh_token). This is done using the Cliend id and Client secret.

5- Auth0 authenticates the web app, validates the authorization code and responds back with the token.

6- The web app can use the access_token to call API on behalf of the user.

Benefits:


  • Almost any web app you use is going to perform authentication. This is table stakes, and there are a lot of cookie-cutter solutions for various frameworks but can be hard to get it right and secure. One less thing to maintain and worry about when you are building your product. Their starter free plan is sufficient for most startups' needs.
  • Auth0 has got SDKs in various languages and a ton of documentation. It's easy to integrate it with your demand.
  • It provides compliance with various standards(Ex: HIPAA) if that's a key requirement for your outcome.

Summary:

     Learn that you are offloading your whole user data to a 3rd party app in exchange for extensibility. They do offer a way to migrate this data back to your app in case you need it, thus avoiding any vendor lock-in. In my next article, I am going provide code examples that I did integrate this excellent identity solution with my IOS, Java and NodeJS apps. Stay tuned.



Happy coding,
Thiago Leoncio.