java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Lcom/google/android/gms/common/util/PlatformVersion - gmsmapview

java.lang.NoSuchMethodError: No static method isAtLeastR()Z in class Lcom/google/android/gms/common/util/PlatformVersion; or its super classes (declaration of 'com.google.android.gms.common.util.PlatformVersion' appears in /data/app/~~GCVLMYDjF3i3OD21L0W7_A==/dt.wms.lavajet-HGYaYmhF88IIMNnZR4F3RQ==/base.apk!classes30.dex)
I tried adding the library
implementation 'com.google.android.gms:play-services-base:17.1.0'

Related

I get exception with axon-mongo 4.5, spring boot 2.4.3 and mongodb 4.2 in AxonConfig class

When running the project I get this exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'axonMongoTemplate' defined in com.springbank.user.core.configuration.AxonConfig: Bean
instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.axonframework.extensions.mongo.MongoTemplate]: Factory method 'axonMongoTemplate'
threw exception; nested exception is java.lang.IllegalStateException: #Bean method
AxonConfig.mongo called as bean reference for type [com.mongodb.MongoClient] but overridden
by non-compatible bean instance of type [com.mongodb.client.internal.MongoClientImpl].
Overriding bean of same name declared in: class path resource
[org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.axonframework.extensions.mongo.MongoTemplate]: Factory method 'axonMongoTemplate'
threw exception; nested exception is java.lang.IllegalStateException: #Bean method
AxonConfig.mongo called as bean reference for type [com.mongodb.MongoClient] but overridden
by non-compatible bean instance of type [com.mongodb.client.internal.MongoClientImpl].
Overriding bean of same name declared in: class path resource
[org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]
Caused by: java.lang.IllegalStateException: #Bean method AxonConfig.mongo called as bean
reference for type [com.mongodb.MongoClient] but overridden by non-compatible bean instance
of type [com.mongodb.client.internal.MongoClientImpl]. Overriding bean of same name declared
in: class path resource
[org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]
this is my axon configuration class:
#Configuration
public class AxonConfig {
#Value("${spring.data.mongodb.host:127.0.0.1}")
private String mongoHost;
#Value("${spring.data.mongodb.port:27017}")
private int mongoPort;
#Value("${spring.data.mongodb.database:user}")
private String mongoDatabase;
#Bean
public MongoClient mongo() {
var mongoFactory = new MongoFactory();
mongoFactory.setMongoAddresses(Collections.singletonList(new ServerAddress(mongoHost, mongoPort)));
return mongoFactory.createMongo();
}
#Bean
public MongoTemplate axonMongoTemplate() {
return DefaultMongoTemplate.builder()
.mongoDatabase(mongo(), mongoDatabase)
.build();
}
...
}
The spring boot version and dependencies I use are:
org.springframework.boot:spring-boot-starter-parent:2.4.3
org.axonframework:axon-spring-boot-starter:4.5.9
org.axonframework.extensions.mongo:axon-mongo:4.3
this is my application.properties:
#spring
server.port=8082
#mongodb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=user
spring.main.allow-bean-definition-overriding=true
spring.main.allow-circular-references=true
I think you can just remove the MongoClient Bean, as Spring Boot is already doing that for you.
After several tests of dependency versions, I found the dependencies that did not conflict with each other.
Here's the list of versions used:
Java JDK 14
spring-boot-starter-parent:2.2.6.RELEASE
axon-spring-boot-starter:4.3.1
lombok:1.18.20
Using other versions of spring boot exceptions occurred.

How do you inherit FirebaseAuth class in a new class?

class FireAuth extends FirebaseAuth{
FireAuth({Key? key}) : super.instanceFor(app: app);
...
I want to be able to build my own class based on the FirebaseAuth class
but I keep getting this error:
The generative constructor 'FirebaseAuth FirebaseAuth.instanceFor({required FirebaseApp app})' is expected, but a factory was found.
Try calling a different constructor of the superclass, or making the called constructor not be a factory constructor.
To get around the issue with inheriting the FirebaseAuth. I have used the extension function instead of the extends. So it looks like this
extension FireAuth on FirebaseAuth {
...
no need for a constructor now

Loading classes using Spring inside an eclipse OSGi container does not seem to work. Fix?

I am somewhat puzzled about Spring's classloading behavior inside an eclipse OSGi container (which is the basis for the TIBCO ActiveMatrix runtime I am trying to get this running on) and boiled this down to the below simple example.
In it (the TestComponent object is created and called inside an OSGi bundle's Activator class, but I don't think that this is important here) I first create an object direcly, just to double-check, that its class exists and can be instantiated. This of course works as one would expect...
Second, I want to create a second object of that very same class using Spring (as I originally intended), but this fails with a ClassNotFoundException.
Spring claims, it can't find that class (even though the package and class name definitely match), so I even added a .setClassLoader(...) call to pass it the very same classloader that just successfully loaded that very same class, but Spring still fails to locate that class.
Any clue of why that is so? I have ran out of ideas. What am I missing?
Later edit: I just had to realize, that it is NOT the ...getBean(...)-method call that crashes, but rather already the ClassPathXmlApplicationContext()-constructor. I.e. the object is already created in that constructor and not only later in the subsequent getBean(...)-method call. Thus my attempt to pass-in the classloader is futile as it already comes to late. So the question thus rather is: how can I pass-in the context's class loader to that constructor (or to the factory or whatever Spring uses internally to create the ClassPathXmlApplicationContext object)?
My example:
I first defined an interface for the class to be created via Spring:
package com.example.some_package_0;
public interface SomeInterface
{
public String getSomeString();
}
... and a class, implementing this interface:
package com.example.some_package_1;
import com.example.some_package_0.SomeInterface;
public class SomeClassA implements SomeInterface
{
private String someProperty;
public void setSomeProperty(String someProperty) {
this.someProperty = someProperty;
}
public String getSomeString() {
return this.someProperty;
}
}
My Test-program reads
public class TestComponent
{
import com.example.some_package_0.SomeInterface;
import com.example.some_package_1.SomeClassA;
public void test() {
SomeClassA obj1 = new SomeClassA();
obj1.setSomeProperty("SomeClassA-object (directly created)");
System.out.println("## message=\"" + obj1.getSomeString() + "\"");
ClassPathXmlApplicationContext applicationContext;
applicationContext = new ClassPathXmlApplicationContext("/META-INF/package1_beans.xml");
applicationContext.setClassLoader(Thread.currentThread().getContextClassLoader());
SomeInterface obj2 = (SomeInterface) applicationContext.getBean("bean1");
System.out.println("## message=\"" + obj2.getSomeString() + "\"");
}
}
The /META-INF/package1_beans.xml being used reads:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-2.5.xsd">
<bean id="bean1" class="com.example.some_package_1.SomeClassA">
<property name="someProperty"><value>SomeClassA-object (created via Spring)</value></property>
</bean>
</beans>
The exception reads:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.example.some_package_1.SomeClassA] for bean with name 'bean1' defined in class path resource [META-INF/package1_beans.xml]; nested exception is java.lang.ClassNotFoundException: com.example.some_package_1.SomeClassA
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.example.test_spring_example.TestComponent.testOperation(TestComponent.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.tibco.amf.platform.runtime.componentframework.internal.proxies.operation.OperationHandler.invokeMethodWithThreadContext(OperationHandler.java:667)
at com.tibco.amf.platform.runtime.componentframework.internal.proxies.operation.AsyncToSyncOperationHandler.invoke(AsyncToSyncOperationHandler.java:98)
at com.tibco.amf.platform.runtime.componentframework.internal.proxies.ProxyInvocationHandlerRegistry$ProxyInvocationContext.invoke(ProxyInvocationHandlerRegistry.java:411)
at $Proxy67.invoke(Unknown Source)
at com.tibco.amf.binding.soap.runtime.transport.http.SoapHttpInboundEndpoint.processHttpPost(SoapHttpInboundEndpoint.java:565)
at com.tibco.amf.binding.soap.runtime.transport.http.SoapHttpServer.doPost(SoapHttpServer.java:195)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at org.mortbay.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1213)
at com.tibco.governance.pa.amxcomponent.pep.http.HttpPepFilter.doFilter(HttpPepFilter.java:126)
at org.mortbay.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1205)
at com.tibco.amf.implementation.common.httpfilter.GenericComponentFilter.doFilter(GenericComponentFilter.java:65)
at org.mortbay.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1205)
at com.tibco.amf.hpa.tibcohost.jetty.internal.ConnectorFilter.doFilter(ConnectorFilter.java:49)
at org.mortbay.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1205)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.example.some_package_1.SomeClassA
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
... 46 more
Actually, the solution turned out to be almost trivial!
As I already stated in my comment to #Robin apparently in OSGi the current thread's classloader and the current context or class' classloader are not the same!
So, all I had to do in the end was to set the current thread's context-classloader to the calling object's classloader and that's it! I.e. one doesn't even need to dig into OSGi to obtain the bundle's class loader or fiddle with manifests or POMs or anything like that - just tell Spring to use "my" own class' classloader and off you go!
...
// need to set the context class loader to "my" class loader to make Spring work:
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
ClassPathXmlApplicationContext applicationContext;
applicationContext =
new ClassPathXmlApplicationContext("/META-INF/package1_beans.xml");
SomeInterface obj2 = (SomeInterface) applicationContext.getBean("bean1");
System.out.println("## message=\"" + obj2.getSomeString() + "\"");
...
And - yes - one probably should set the thread's class loader back to the original value after that, just in case - so another good used for a try { ... } finally { ... } clause. :-)
Thanks all for responding!
M.
I have one other idea.
Instead of initializing your Spring context manually. Try adding this to your pom.xml (if you are using Maven):
<configuration>
<instructions>
<Spring-Context>spring/*.xml</Spring-Context>
Make it point to the location of your applContext. This seems a neater way to hook it up as well. If you are not using Maven youll need to add manually to the Manifest, Im not sure exactly the right syntax for that

RESTEasy cannot call my annotated method on a scala class

Trying to implement a JAX-RS resource in Scala. My Java version of this has the following type signature:
#GET
#Path(value="echoold")
#Produces("application/json")
public Map<String,Object> get(
#QueryParam("param") String param,
#QueryParam("asOf") #DefaultValue(NOW) DateWrapper asOf,
#QueryParam("httpError") #DefaultValue("200") int httpError,
#QueryParam("httpErrorMessage") #DefaultValue("") String httpErrorMessage,
#QueryParam("fail") #DefaultValue("false") boolean fail) {
The Scala version is thus:
#GET
#Path(value="echo")
#Produces(Array("application/json"))
def get() = {
#QueryParam("param") param:String,
#QueryParam("asOf") #DefaultValue(NOW) asOf:DateWrapper,
#QueryParam("httpError") #DefaultValue("200") httpError:java.lang.Integer,
#QueryParam("httpErrorMessage") #DefaultValue("") httpErrorMessage:String,
#QueryParam("fail") #DefaultValue("false") fail:java.lang.Boolean):java.util.Map[String,Object] = {
When I start up my application, I get this strange error from RESTEasy (which I've formatted for readability):
org.jboss.resteasy.spi.InternalServerErrorException:
Bad arguments passed to
public java.util.Map opower.api.endpoint.echo.Echo.get(java.lang.String,
opower.api.support.DateWrapper,
java.lang.Integer,
java.lang.String,
java.lang.Boolean)
( java.lang.String someValue,
opower.api.support.DateWrapper opower.api.support.DateWrapper#28a34522,
java.lang.Integer 400,
java.lang.String This is the message,
java.lang.Boolean false )
The underlying exception is:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
Now, this class is configured via Spring, so it could be some crazy proxy class and it's getting messed up, but has anyone else seen something like this?
(If you don't know what RESTEasy/JAX-RS is doing, basically the container (RESTEasy) finds methods on classes that have those annotations on them, and then calls them when certain URL endpoints are hit)
I had the same with Spring/Scala and #Transactional method annotation.
needed to change proxy-target-class in
<tx:annotation-driven transaction-manager="txManager"
mode="proxy" proxy-target-class="true"/>
Default value for proxy-target-class is false. It requires cglib in classpath.
I guess mode="acpectj" might also work (didn't try)

GWT 2 CssResource how to

I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and my application compiled and worked fine. Now for GWT 2 I have created a ResourceBundle class and put all image sprites and CSS as follows:
public interface ResourceBundle extends ClientBundle {
public static final ResourceBundle INSTANCE = GWT.create(ResourceBundle.class);
#Source("com/web/tech/public/stylesheet1.css")
public Css stylesheet1();
#Source("com/web/tech/public/stylesheet2.css")
public Css stylesheet2();
#Source("com/docobo/keswick/keswickweb/public/images/organisnew.gif")
public ImageResource add_org();
.....
}
The Css class is an empty class extending CssResource :
public interface Css extends CssResource{
}
Then in my onModuleLoad() I use :
StyleInjector.inject(ResourceBundle.INSTANCE.stylesheet1().getText());
StyleInjector.inject(ResourceBundle.INSTANCE.stylesheet2().getText());
When I compile I get the following error:
Rebinding com.docobo.keswick.keswickweb.client.ClientResources.ResourceBundle
Invoking <generate-with class='com.google.gwt.resources.rebind.context.InlineClientBundleGenerator'/>
Creating assignment for gxt_gray()
Replacing CSS class names
[ERROR] The following unobfuscated classes were present in a strict CssResource:
[ERROR] x-tab-scroller-left
[ERROR] x-tab-strip-disabled
[ERROR] ......loads of other styles
Fix by adding String accessor method(s) to the CssResource interface for obfuscated classes, or using an #external declaration for unobfuscated classes.
Following the above instruction when I use #external above all my style classes inside the CSS file I get the following error :
[ERROR] Generator 'com.google.gwt.resources.rebind.context.InlineClientBundleGenerator' threw threw an exception while rebinding 'com.docobo.keswick.keswickweb.client.ClientResources.ResourceBundle'
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(Unknown Source)
at com.google.gwt.resources.css.GenerateCssAst$GenerationHandler.ignorableAtRule(GenerateCssAst.java:236)
at org.w3c.flute.parser.Parser.atRuleDeclaration(Parser.java:1178)
at org.w3c.flute.parser.Parser.ignoreStatement(Parser.java:622)
at org.w3c.flute.parser.Parser.parserUnit(Parser.java:452)
at org.w3c.flute.parser.Parser.parseStyleSheet(Parser.java:107)
at org.w3c.flute.parser.Parser.parseStyleSheet(Parser.java:119)
at com.google.gwt.resources.css.GenerateCssAst.exec(GenerateCssAst.java:663)
at com.google.gwt.resources.rg.CssResourceGenerator.prepare(CssResourceGenerator.java:506)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.initAndPrepare(AbstractClientBundleGenerator.java:531)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.initAndPrepare(AbstractClientBundleGenerator.java:502)
at com.google.gwt.resources.rebind.context.AbstractClientBundleGenerator.generate(AbstractClientBundleGenerator.java:179)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:49)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind(StandardRebindOracle.java:108)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:54)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:143)
at com.google.gwt.dev.Precompile$DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(Precompile.java:315)
at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.doFindAdditionalTypesUsingRebinds(WebModeCompilerFrontEnd.java:107)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.process(AbstractCompiler.java:161)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.compile(AbstractCompiler.java:84)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.compile(AbstractCompiler.java:196)
at com.google.gwt.dev.jdt.AbstractCompiler$CompilerImpl.access$300(AbstractCompiler.java:70)
at com.google.gwt.dev.jdt.AbstractCompiler.compile(AbstractCompiler.java:481)
at com.google.gwt.dev.jdt.BasicWebModeCompiler.getCompilationUnitDeclarations(BasicWebModeCompiler.java:113)
at com.google.gwt.dev.jdt.WebModeCompilerFrontEnd.getCompilationUnitDeclarations(WebModeCompilerFrontEnd.java:49)
at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:415)
at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:32)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:507)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:408)
at com.google.gwt.dev.Compiler.run(Compiler.java:194)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:145)
at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:89)
at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:83)
at com.google.gwt.dev.Compiler.main(Compiler.java:152)
Try with #NotStrict. Example:
#NotStrict
#Source("com/web/tech/public/stylesheet1.css")
public Css stylesheet1();
Got it solved.
As pointed out by Thomas#Google Groups --> The #external must not be put "above" the style
http://code.google.com/p/google-web-toolkit/wiki/CssResource#External...
The example from this link, the css will look like :
#external .legacySelectorA, .legacySelectorB;
.obfuscated .legacySelectorA { .... }
.obfuscated .legacySelectorB { .... }
/* #external also accepts tail-globs */
#external .myProject-*;
.myProject-text {}
.myProject-foo {}