MindSphere SDK V2 for Java - authorization fail - authorization

My code:
String token = request.getHeader("authorization"); // I was checked, token have value type Bearer.
MindsphereCredentials credentials = MindsphereCredentials.userTokenBuilder()
.authorization(token)
.build();
But my program returns an error at .authorization
ERROR get from
cf logs program_name --recent
2020-06-18T17:09:26.96+0900 [APP/PROC/WEB/0] OUT [CONTAINER] tainerBase.[Catalina].[localhost].[/].[dispatcher] SEVERE Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/auth0/jwt/exceptions/JWTDecodeException] with root cause
I follow this link: mindsphere-sdk-java-v2/sdkreadme_v2

A NoClassDefFoundError exception usually suggests that you're missing a dependency.
This is not stated anywhere in the documentation, but it's not enough to just include the MindSphere SDK to your project alone; you also need some additional dependencies to make it work. Try adding the following to your Gradle/Maven build scripts:
org.apache.httpcomponents:httpclient:4.5.12
com.auth0:java-jwt:3.10.2
They're available in Maven Central.

Related

keycloak custom identity provider giving build error .I have implemented a custom AbstractIdentityProvider but getting build error

I have implemented a custom idp class extending AbstractIdentityProviderMapper .
and i am getting below error while building and i am using keycloak 17 :
ERROR: Failed to run 'build' command.
ERROR: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.deployment.steps.MainClassBuildStep#build threw an exception: java.lang.RuntimeException: Failed to record call to method public void org.keycloak.quarkus.runtime.KeycloakRecorder.configSessionFactory(java.util.Map,java.util.Map,java.util.Map,java.lang.Boolean)
at io.quarkus.deployment.recording.BytecodeRecorderImpl.writeBytecode(BytecodeRecorderImpl.java:509)
at io.quarkus.deployment.steps.MainClassBuildStep.writeRecordedBytecode(MainClassBuildStep.java:444)
Entire Problem statement is well mentioned here
I have implemented a abstractIdentityProvider mapper to call logic execution upon authentication from external idp .

EclipseLink Moxy with Java11

I asked this questions already here:
https://www.eclipse.org/forums/index.php/t/1098133/
Now, after 3 weeks, i hope to have luck to reach a response here in stackoverflow.
I have a RCP applcation using MOXy to parse complex XML, the annotated classes are generated by XJC, and the package contains a ObjectFactory and a jaxb.properties pointing to MOXy.
The problem: The application works with Java8, but starting the application with Java11, i get this exception:
java.lang.RuntimeException: javax.xml.bind.JAXBException
- with linked exception:
[Exception [EclipseLink-50000] (Eclipse Persistence Services - 2.7.4.v20190115-ad5b7c6b2a): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The context path mypackage contains no ObjectFactory or jaxb.index, no external metadata was found in properties Map, and sessions.xml was found or was invalid.
Internal Exception: Exception [EclipseLink-7095] (Eclipse Persistence Services - 2.7.4.v20190115-ad5b7c6b2a): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The sessions.xml resource [sessions.xml] was not found on the resource path. Check that the resource name/path and classloader passed to the SessionManager.getSession are correct. The sessions.xml should be included in the root of the application's deployed jar, if the sessions.xml is deployed in a sub-directory in the application's jar ensure that the correct resource path using "/" not "\" is used.]
My target platform contains:
org.eclipse.persistence.moxy_2.7.4....jar
jaxb-osgi-2.3.2.jar
jakarta.activation.jar
jakarta.xml.bind-api.jar
I use Multi-Release: true to be able to handle Java8 vs. Java9+.
In the main MANIFEST.FM i require org.eclipse.persistence.moxy.
In the versions/9/OSGI-INF/MANIFEST.FM I add the import packages: com.sun.xml.bind.v2, javax.xml.bind
To start the application in the Eclipse run configuration dialog, i switch the JRE Java8 vs Java11, and in the plugins tab, i remove (J8) or add (J11) com.sun.xml.bind.jaxb-osgi (jaxb-osgi.jar) to make it startable.
Can someone help?
regards
Frank

Error building a request and initializing client for OkHttp3 on Kotlin

New to OkHttp, however I was able to track the following errors:
val url = "https://api.letsbuildthatapp.com/youtube/home_feed"
try {
val request = Request.Builder().url(url).build()
} catch(err: Error){
println("Request Error: $err")
}
This generates: "Request Error: java.lang.BootstrapMethodError: Exception from call site #5 bootstrap method"
try {
OkHttpClient()
} catch(err: Error){
println("Client Error: $err")
}
This returns an error "Client Error: java.lang.NoClassDefFoundError: okhttp3.internal.Util"
Any help with these will be greatly appreciated. TIA
It looks like you have an issue with the dependency and/or JVM. The java.lang.BootstrapMethodError may mean there is something work with the Java Runtime Environment. Please consider upgrading Java to the stable version (e.g. 11 or 1.8)
The NoClassDefFound error means you miss some classes from the OkHttp library in your project. There are likely to be several transitive dependencies from the .jar that you have in your project. Probably Gradle or Maven project will help to have all dependencies resolved correctly.

Bytecode verification issue tool

We are facing a VerifyError in our application while deploying to WAS environment. The following is the exception:
Error 500: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.VerifyError: JVMVRFY012 stack shape inconsistent; class=com/org/jaxb/Input_JAXB_Deserialization_Stub, method=write(ILjava/lang/Object;)V, pc=356
We are still trying to identify the issue, but all efforts not going well. Is there any way that the libraries used in run time is good in bytecode compatibility?. For example, we can add all the libraries and run the byte code verification.

Grails cant use Spock framework?

I am currently working on a project that had started with no TDD in place and now I have taken the following steps to start using Spock for Unit and Integration testing on this project:
Added the following to the buildconfig:
test ":spock:0.7"
Then created a spec at "test/unit/MYCLASSNAME" called MyfunctionControllerSpec as shown below:
import grails.test.mixin.*
import spock.lang.Specification
class MyfunctionControllerSpec extends Specification {
void "list() should return no results with no records in DB"() {
given:
def model = controller.list()
expect:
model.taskInstanceList.size() == 0
model.taskInstanceTotal == 0
}
}
However I am getting the following errors with the Specification import line:
Groovy:unable to resolve class spock.lang.Specification
I don’t understand what I am doing wrong, have I imported or install Spock wrong?
Thanks in advance
EDIT*
I have tried the suggestion below and then the solution wont run and it still doesnt recognise the Specification class, even when I start typing "inport spo" and press cntrl+space nothing comes up as if it cant even recogise the plugin either:
Loading Grails 2.1.0
| Configuring classpath
| Downloading: spock-grails-support-0.7-groovy-2.0.pom.sha1
| Downloading: spock-core-0.7-groovy-2.0.pom.sha1
| Downloading: spock-grails-support-0.7-groovy-2.0.jar.sha1
| Downloading: spock-core-0.7-groovy-2.0.jar.sha1.
| Environment set to development....
| Error Error loading event script from file [/media/system/workspace/sms_bskyb_New_V2(Dynam Messages)/plugins/tool-ui/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
| Error Error loading event script from file [/home/system/.grails/2.1.0/projects/sms_bskyb/plugins/database-migration-1.1/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
| Error Error loading event script from file [/home/system/.grails/2.1.0/projects/sms_bskyb/plugins/tomcat-2.1.0/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
| Error Error loading event script from file [/home/system/.grails/2.1.0/projects/sms_bskyb/plugins/spock-0.7/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
| Error Error loading event script from file [/home/system/.grails/2.1.0/projects/sms_bskyb/plugins/webxml-1.4.1/scripts/_Events.groovy] startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
| Environment set to development.....
| Packaging Grails application.
| Error Fatal error during compilation org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/system/.grails/ivy-cache/org.spockframework/spock-core/jars/spock-core-0.7-groovy-2.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.reflect.InvocationTargetException
1 error
(Use --stacktrace to see the full trace)
You are using Grails 2.1.0 whereas Groovy 2.0 was introduced in Grails 2.2.0 and above. Hopefully you do not need to explicit dependency org.spockframework:spock-grails-support:0.7-groovy-2.0. Only use as below:
plugins{
test ":spock:0.7"
}
In case you still find an issue then isolate the problem by creating a fresh new bare bone grails app and install the plugin as mentioned in the plugin docs. Try to see if there is any classpath clash. If the problem still exists, then clear ivy-cache and/or .m2 and retry.
I almost answered this here, but I see that you are using Grails 2.1.
For others that are getting this error with Grails 2.2.x see this answer