KeyCloak 2.3 getting NPE when exporting - java

My KeyCloak works with h2 db(default) and has some data in it
i want to export the data so i can migrate KeyCloak to mysql
KeyCloak i'm using is 2.3 version
I keep getting the NPE when trying to export the data.
Command that i'm using for exporting is:
sudo ./standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=/tmp/export.json
Stacktrace:
Caused by: java.lang.NullPointerException
at org.keycloak.exportimport.util.ExportUtils.exportRealm(ExportUtils.java:227)
at org.keycloak.exportimport.singlefile.SingleFileExportProvider$1.runExportImportTask(SingleFileExportProvider.java:65)
at org.keycloak.exportimport.util.ExportImportSessionTask.run(ExportImportSessionTask.java:35)
at org.keycloak.models.utils.KeycloakModelUtils.runJobInTransaction(KeycloakModelUtils.java:235)
at org.keycloak.exportimport.singlefile.SingleFileExportProvider.exportModel(SingleFileExportProvider.java:58)
at org.keycloak.exportimport.ExportImportManager.runExport(ExportImportManager.java:102)
at org.keycloak.services.resources.KeycloakApplication.<init>(KeycloakApplication.java:148)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
... 19 more

Solved this by reading H2 and creating sql script for generating tables + data

I'm not sure if this is the same issue but I was also getting a Null pointer error when trying to do a default export.
The issue for me was due to not setting the alias for an execution in the authentication flow.
https://issues.jboss.org/browse/KEYCLOAK-2494
Basically to maintain ordering of the exported Json files and keep them versionable keycloak is requiring an alias be set so that it can always do consistent sorting.
https://github.com/keycloak/keycloak/commit/c81d0c0898d7b44c0d053ce6666acdad4967bffc
The fix for me was to set an alias field in the config for the execution through the admin console, annoyingly if you've done any configuration before it won't let you update the alias. You'll have to just delete the execution in the admin console and recreate it.

Related

ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long on DriverManager.getConnection() [duplicate]

When connecting to MySQL, I get an error (see below).
Click here for code
I get this output:
run:
Now connecting to databse...
java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1062)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3556)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2513)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at dbms_basic.Dbms_Basic.main(Dbms_Basic.java:28)
Caused by: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1007)
... 15 more
BUILD SUCCESSFUL (total time: 0 seconds)
How can I solve this?
Your error clearly says casting is not possible, because a java.math.BigInteger class instance is not an instance of java.lang.Long class.
Now the question arises who is doing casting at what level, when we ask the JDBC driver to make a connection, it is doing lot of work behind the scene before it actually give us back the proper working object of connection.
The problem seems with your version of MySQL in combination with your version of mysql-connector.jar. Try a newer version of MySQL Connector/J (see https://dev.mysql.com/downloads/connector/j/ for the latest version), for example upgrade to 5.1.47 or 8.0.12 if you are using an older version.
This issue is not there with 5.1.45 as mentioned in the above comments. Available to download at,
https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.45/
Another way, because changing the version from mysql does not worked for me, for help another people:
Long.parseLong(String.valueOf(item[0]);
There is a miss-match between your MySQL version, which might be the latest 8.0.19, but the MySQL driver file is older version may be 5.1.23, which is generally available with the NetBeans IDE. To overcome this, download the mysql-connector-java-5.1.48.jar from this link in your PC download connector/j 5.1.48 zip file
(4.6MB)
Now right-click on project name in the netbeans IDE, go to services, in that choose 'Libraries', in it choose 'Add library', then don't opt for available libraries( the drop-down menu will list a JDBCDriver file which has 'mysql-connector-java-5.1.23.jar' file inside it, which is an older version, this is causing the miss-match). Therefore, instead click on 'Create Library', now give it any name of your choice, then click the create button, a browse window will pop-up, go to the directory where you have downloaded the 'mysql-connector-java-5.1.48.zip' folder, open it and select the java jar file 'mysql-connector-java-5.1.48.jar' and click 'ok'. The library folder of your project tree will now show 'JDBCDriver-mysql-connector-java-5.1.48.jar' added in the list of libraries(JDK and Tomcat) . Now try connecting to your database again by clicking on the 'run' button, go to the JSP link, and you see that this time you are connected.
For me updating the connector wasn't enough, I also had to complete my DriverManager.getConnection() url parameter with all the arguments, even if the error message was not mentionning this issue.
In my case this parameters were needed :
"jdbc:mysql://127.0.0.1:3306/database?zeroDateTimeBehavior=convertToNull&serverTimezone=UTC"
Connector : mysql-connector-java-8.0.17.jar
mysql version : 8.0.17
Using java on netbeans.
This is a common issue when you use outdated/unsupported mysql connector driver. If youre using x86 version of Netbeans, your driver will usually be found in the Program(x86) folder an not the Program folder. something like this "C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-java-8.0.23.jar"

Java weblogic error with Caused by: java.lang.IllegalArgumentException

We are facing below error when trying to push some of bulk-upload using sftp from Source server to destination servers.
Back-end of this application running on weblogic.
Caused by: java.lang.IllegalArgumentException: No Configuration was registered that can handle the configuration named com.sun.security.jgss.krb5.initiate
at com.bea.common.security.jdkutils.JAASConfiguration.getAppConfigurationEntry(JAASConfiguration.java:124)
at sun.security.jgss.LoginConfigImpl.getAppConfigurationEntry(LoginConfigImpl.java:139)
at javax.security.auth.login.LoginContext.init(LoginContext.java:243)
at javax.security.auth.login.LoginContext.<init>(LoginContext.java:499)
at sun.security.jgss.GSSUtil.login(GSSUtil.java:244)
at sun.security.jgss.krb5.Krb5Util.getTicket(Krb5Util.java:136)
at sun.security.jgss.krb5.Krb5InitCredential$1.run(Krb5InitCredential.java:328)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.jgss.krb5.Krb5InitCredential.getTgt(Krb5InitCredential.java:325)
at sun.security.jgss.krb5.Krb5InitCredential.getInstance(Krb5InitCredential.java:128)
at sun.security.jgss.krb5.Krb5MechFactory.getCredentialElement(Krb5MechFactory.java:106)
at sun.security.jgss.krb5.Krb5MechFactory.getMechanismContext(Krb5MechFactory.java:172)
at sun.security.jgss.GSSManagerImpl.getMechanismContext(GSSManagerImpl.java:209)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:195)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:162)
at com.jcraft.jsch.jgss.GSSContextKrb5.init(GSSContextKrb5.java:129)
at com.jcraft.jsch.UserAuthGSSAPIWithMIC.start(UserAuthGSSAPIWithMIC.java:135)
at com.jcraft.jsch.Session.connect(Session.java:419)
at com.jcraft.jsch.Session.connect(Session.java:150)
at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:210)
Do you have JAAS configuration file? If you do, then you probably have old format of "initiate" section - com.sun.security.jgss.initiate, note that it's missing ".krb5". It should be com.sun.security.jgss.krb5.initiate.
Or maybe the path to configuration file is incorrect in your server startup command line.

on ArtifactoryClient.create exception thrown for JFrogDev/artifactory-client-java

I am developing a Jenkins Plugin in Java, and I'm getting the following error when I try to instantiate the ArtifactoryClient class within JFrog's artifactory client java library.
I used the following code:
ArtifactoryClient artifactory = ArtifactoryClient.create(resolverServerUrl, resolverUsername, resolverPassword);
And I get the error stack trace below when it executes. I have done extensive research on this issue, and I have not found anyone with a similar error except for the ones referenced in this issue which I also opened:
https://github.com/JFrogDev/artifactory-client-java/issues/85
I found a similar stack overflow question, but their solution does not work for me and their stack trace is different, which means the error is different. (Upload to Artifactory using Java client)
I am wondering if anyone knows how to resolve this error and why it is happening?
groovy.lang.MissingMethodException: No signature of method:
com.fasterxml.jackson.databind.ObjectMapper.addMixIn() is applicable for argument types: (java.lang.Class, java.lang.Class) values: [interface
org.jfrog.artifactory.client.model.Repository, ...] at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55) at
org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46) at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at org.jfrog.artifactory.client.impl.ArtifactoryImpl.<init>(ArtifactoryImpl.groovy:46) at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at
java.lang.reflect.Constructor.newInstance(Constructor.java:423) at
org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCllSite.java:194) at
org.jfrog.artifactory.client.ArtifactoryClient.create(ArtifactoryClient.groovy:
7) at
org.jfrog.artifactory.client.ArtifactoryClient.create(ArtifactoryClient.groovy)
at com.jenkins.plugins.servicenow.artifactory.ArtifactoryService.<init
(ArtifactoryService.java:36) at
com.ge.integration.jenkins.notification.Phase.initialize(Phase.java:152) at
com.ge.integration.jenkins.notification.Phase.perform(Phase.java:210) at
com.ge.integration.jenkins.notification.Phase.handle(Phase.java:114) at
com.ge.integration.jenkins.notification.JobListener.onFinalized(JobListener.jav
:52) at hudson.model.listeners.RunListener.fireFinalized(RunListener.java:230)
at hudson.model.Run.onEndBuilding(Run.java:1890) at
hudson.model.Run.execute(Run.java:1809) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:98) at
hudson.model.Executor.run(Executor.java:381)
I am using the following versions:
I'm using the latest version of artifactory-client-java.
Jenkins 1.621
Artifactory 2.3.0
The environment I am using this for requires these versions.
The Java Versions I have tried this plugin on are Java 1.8.02 and Java 1.7.79
As #drob said in the comments above, I was using the wrong version of the Jackson Library. JFrog's client library imports and requires Jackson 2.4.6; however, I had imported Jackson 2.1.1 in a dependency that I imported before hand.
My build tool (Maven) read it as a conflict and used 2.1.1 omitting 2.4.6, causing the error described above.

HBase crashes after few seconds

I have been following the HBase installation instructions as given on this page:
https://hbase.apache.org/book.html#quickstart
I am using HBase version 1.1.3 (stable release) and have configured in standalone mode. I have installed OpenJDK 7
When I try to start hbase it crashes after few seconds and I get the following error:
2016-01-29 17:37:04,136 ERROR [main] master.HMasterCommandLine: Master exiting
java.lang.RuntimeException: Failed construction of Master: class org.apache.hadoop.hbase.master.HMasterCommandLine$LocalHMaster
at org.apache.hadoop.hbase.util.JVMClusterUtil.createMasterThread(JVMClusterUtil.java:143)
at org.apache.hadoop.hbase.LocalHBaseCluster.addMaster(LocalHBaseCluster.java:219)
at org.apache.hadoop.hbase.LocalHBaseCluster.<init>(LocalHBaseCluster.java:155)
at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:224)
at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:139)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:126)
at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:2355)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.hbase.util.Bytes$LexicographicalComparerHolder$UnsafeComparer
at org.apache.hadoop.hbase.util.Bytes.putInt(Bytes.java:899)
at org.apache.hadoop.hbase.KeyValue.createByteArray(KeyValue.java:1082)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:652)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:580)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:483)
at org.apache.hadoop.hbase.KeyValue.<init>(KeyValue.java:370)
at org.apache.hadoop.hbase.KeyValue.<clinit>(KeyValue.java:267)
at org.apache.hadoop.hbase.HConstants.<clinit>(HConstants.java:978)
at org.apache.hadoop.hbase.HTableDescriptor.<clinit>(HTableDescriptor.java:1488)
at org.apache.hadoop.hbase.util.FSTableDescriptors.<init>(FSTableDescriptors.java:124)
at org.apache.hadoop.hbase.regionserver.HRegionServer.<init>(HRegionServer.java:570)
at org.apache.hadoop.hbase.master.HMaster.<init>(HMaster.java:365)
at org.apache.hadoop.hbase.master.HMasterCommandLine$LocalHMaster.<init>(HMasterCommandLine.java:307)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.hadoop.hbase.util.JVMClusterUtil.createMasterThread(JVMClusterUtil.java:139)
... 7 more
Can anyone tell me the reason for this error ?
Please let me know if you need more info.
The exception causing this is NoClassDefFoundError which usually means you are missing something from your classpath. In this you're missing org.apache.hadoop.hbase.util.Bytes which comes from hbase-common.jar. However, if one is missing, there are probably others too. This might mean you're starting HBase the wrong way. Have you tried the included start-up scripts?

Neo4j store upgrade error

I have created a large graph using the Neo4j's 2.2M02 import tool.
Now I want to use the same database in embedded version in 2.2RC01. I get the following error in Java, when I initialize the database:
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, D:\Neo4j\data\test3.db
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:331)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:103)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:90)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:176)
at RCNeo4j.initDB(RCNeo4j.java:419)
at RCNeo4j.main(RCNeo4j.java:46)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.state.DataSourceManager#2c7e0aa0' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:326)
... 6 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource#37b86b14' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:117)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
... 8 more
Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UnexpectedUpgradingStoreVersionException: 'neostore.nodestore.db' has a store version number that we cannot upgrade from. Expected 'v0.A.3' but file is version 'NodeStore v0.A.4'.
at org.neo4j.kernel.impl.storemigration.UpgradableDatabase.checkUpgradeable(UpgradableDatabase.java:88)
at org.neo4j.kernel.impl.storemigration.StoreMigrator.needsMigration(StoreMigrator.java:157)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.getParticipantsEagerToMigrate(StoreUpgrader.java:259)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.migrateIfNeeded(StoreUpgrader.java:134)
at org.neo4j.kernel.NeoStoreDataSource.upgradeStore(NeoStoreDataSource.java:562)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:471)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
... 11 more
message.log inside the database doesn't seem to show any exception either. I get the same error when I try to move from 2.1.7 to RC01.
Also, on a different note I would also like to know if it's possible to use the database generated from 2.2M02 in 2.1.7 (kind of like a downgrade). Because I prefer to have a more stable version to do some analysis.
Neo4j does not provide an upgrade path between milestone releases, so there is no direct way to upgrade 2.2.0-M02 to 2.2.0-RC1. Upgrades are only supported from one stable to another stable version. Downgrades are not supported at all in the product.
However there is a potential way to do it. Use Michael's store-utils (https://github.com/jexp/store-utils) and change the code using classloader separation in a way that the store you're reading from and the one you're writing to are using separate classloaders with different Neo4j versions.

Categories

Resources