No virtual method getBaseContext()Landroid/content/Context #litho - android-ndk

litho
Error
java.lang.NoSuchMethodError: No virtual method
getBaseContext()Landroid/content/Context; in class
Lcom/facebook/litho/ComponentContext; or its super classes
(declaration of 'com.facebook.litho.ComponentContext' appears in
/data/app/com.midhilaj.myapplication-1/split_lib_dependencies_apk.apk)
My code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ComponentContext context = new ComponentContext(this);
Component component2 =GlideImage.create(context)
.imageUrl("https://d2b41ce3jhhjt0.cloudfront.net/uploads/social/posts/medium/c57365ec934af9814503ae2de8d252e9.jpg")
// .aspectRatio(aspectRatio)
.centerCrop(true)
.build();
setContentView(LithoView.create(context, component2));
Rejecting re-init on previously-failed class java.lang.Class<com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl>: java.lang.LinkageError: Method java.lang.String com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl.getSimpleName() overrides final method in class Lcom/facebook/litho/Component; (declaration of 'com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl' appears in /data/app/com.midhilaj.myapplication-Aet8ZQAr7vjva0PZdq2jhg==/split_lib_dependencies_apk.apk)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at com.github.charbgr.litho.picasso.PicassoImage$Builder com.github.charbgr.litho.picasso.PicassoImage.create(com.facebook.litho.ComponentContext) (PicassoImage.java:170)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void com.midhilaj.myapplication.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:45)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6984)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1235)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2857)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2986)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1671)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:108)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.os.Looper.loop() (Looper.java:206)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6784)
2019-02-06 17:04:05.996 12850-12850/com.midhilaj.myapplication I/zygote64: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-02-06 17:04:05.997 12850-12850/com.midhilaj.myapplication I/zygote64: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-02-06 17:04:05.997 12850-12850/com.midhilaj.myapplication I/zygote64: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:852)
2019-02-06 17:04:05.997 12850-12850/com.midhilaj.myapplication D/AndroidRuntime: Shutting down VM
2019-02-06 17:04:06.000 12850-12850/com.midhilaj.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.midhilaj.myapplication, PID: 12850
java.lang.LinkageError: Method java.lang.String com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl.getSimpleName() overrides final method in class Lcom/facebook/litho/Component; (declaration of 'com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl' appears in /data/app/com.midhilaj.myapplication-Aet8ZQAr7vjva0PZdq2jhg==/split_lib_dependencies_apk.apk)
at com.github.charbgr.litho.picasso.PicassoImage.create(PicassoImage.java:170)
at com.midhilaj.myapplication.MainActivity.onCreate(MainActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1235)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2986)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:206)
at android.app.ActivityThread.main(ActivityThread.java:6784)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:852)
Now i am trying with picasso
java.lang.LinkageError: Method java.lang.String
com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl.getSimpleName()
overrides final method in class Lcom/facebook/litho/Component;
(declaration of
'com.github.charbgr.litho.picasso.PicassoImage$PicassoImageImpl'
appears in
/data/app/com.midhilaj.myapplication-zt-xfqQ6-UlHEkWlTDfqyg==/split_lib_dependencies_apk.apk)
at com.github.charbgr.litho.picasso.PicassoImage.create(PicassoImage.java:170)
at com.midhilaj.myapplication.MainActivity.onCreate(MainActivity.java:44)
at android.app.Activity.performCreate(Activity.java:6984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1235)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2986)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:206)
at android.app.ActivityThread.main(ActivityThread.java:6784)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:852)

Neither com.github.charbgr.litho.picasso.PicassoImage nor GlideImage is a part of Litho framework. You probably should try updating the libraries that provide those classes. Or, if they haven't been updated to work with newer versions of Litho, pull back to using the older versions of the framework, that those libraries are still compatible with. Although, latter seems like a bad idea to me

Related

Why do I get the exception "Found ambiguous parameter type"? Spring Batch Integration

I am learning Spring Batch Integration from here and I know how to launch a job when a message is received. Now, I wanted to get both the name and path of the message (which is a file). Below are my working codes. However, if I uncomment the setFileParameterName method, then I get the following exception:
java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.String] for method match: [public void com.example.batchprocessing.FileMessageToJobRequest.setFileParameterName(java.lang.String), public void com.example.batchprocessing.FileMessageToJobRequest.setJob(org.springframework.batch.core.Job)]
Why does this exception occur? The message makes no sense to me. I pass in a String and it is somehow confused between the two methods, but one of them takes in a String and the other a Job? Any help with this is appreciated.
FileMessageToJobRequest.java
public class FileMessageToJobRequest {
private String filePathParameterName;
private Job job;
private String fileParameterName;
public void setFilePathParameterName(String filePathParameterName) {
this.filePathParameterName = filePathParameterName;
}
public void setJob(Job job) {
this.job = job;
}
// public void setFileParameterName(String fileParameterName) {
// this.fileParameterName = fileParameterName;
// }
#Transformer
public JobLaunchRequest toRequest(Message<File> message) throws IOException {
JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
// jobParametersBuilder.addString(fileParameterName, message.getPayload().getName());
jobParametersBuilder.addString(filePathParameterName, message.getPayload().getCanonicalPath());
jobParametersBuilder.addDate("dummy", new Date()); // need to add at least one unique identifier so that it will run more than once
return new JobLaunchRequest(job, jobParametersBuilder.toJobParameters());
}
}
BatchIntegrationConfiguration.java
#Configuration
#EnableIntegration
#EnableBatchProcessing
public class BatchIntegrationConfiguration {
#Autowired
private JobBuilderFactory jobBuilderFactory;
#Autowired
private StepBuilderFactory stepBuilderFactory;
#Autowired
private JobRepository jobRepository;
#Bean
public MessageChannel files() {
return new DirectChannel();
}
#Bean
public FileMessageToJobRequest fileMessageToJobRequest() {
FileMessageToJobRequest fileMessageToJobRequest = new FileMessageToJobRequest();
// fileMessageToJobRequest.setFileParameterName("input.file.name")
fileMessageToJobRequest.setFilePathParameterName("input.file.path");
fileMessageToJobRequest.setJob(runBatchScriptJob());
return fileMessageToJobRequest;
}
#Bean
public JobLaunchingGateway jobLaunchingGateway() {
SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
simpleJobLauncher.setJobRepository(jobRepository);
simpleJobLauncher.setTaskExecutor(new SyncTaskExecutor());
JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(simpleJobLauncher);
return jobLaunchingGateway;
}
#Bean
public IntegrationFlow integrationFlow(JobLaunchingGateway jobLaunchingGateway) {
return IntegrationFlows.from(Files.inboundAdapter(new File("./src/main/resources")).
filter(new SimplePatternFileListFilter("simplebatchfile.bat")),
c -> c.poller(Pollers.fixedRate(10000).maxMessagesPerPoll(1))).
handle(fileMessageToJobRequest()).
handle(jobLaunchingGateway).
log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload").
get();
}
#Bean
public Job runBatchScriptJob() {
return jobBuilderFactory.get("runBatchScriptJob")
.listener(new JobCompletionNotificationListener())
.start(runBatchScriptStep())
.build();
}
#Bean
public Step runBatchScriptStep() {
return stepBuilderFactory.get("runBatchScriptStep")
.tasklet(runBatchScriptTasklet(null))
.build();
}
#Bean
#StepScope
public Tasklet runBatchScriptTasklet(#Value("#{jobParameters['input.file.path']}") String filePath) {
RunBatchScriptTasklet tasklet = new RunBatchScriptTasklet();
tasklet.setFilePath(filePath);
return tasklet;
}
}
StackTrace
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationFlow' defined in class path resource [com/example/batchprocessing/BatchIntegrationConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'integrationFlow' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.String] for method match: [public void com.example.batchprocessing.FileMessageToJobRequest.setFileParameterName(java.lang.String), public void com.example.batchprocessing.FileMessageToJobRequest.setJob(org.springframework.batch.core.Job)]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at com.example.batchprocessing.BatchProcessingApplication.main(BatchProcessingApplication.java:14) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'integrationFlow' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.String] for method match: [public void com.example.batchprocessing.FileMessageToJobRequest.setFileParameterName(java.lang.String), public void com.example.batchprocessing.FileMessageToJobRequest.setJob(org.springframework.batch.core.Job)]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 18 common frames omitted
Caused by: java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.String] for method match: [public void com.example.batchprocessing.FileMessageToJobRequest.setFileParameterName(java.lang.String), public void com.example.batchprocessing.FileMessageToJobRequest.setJob(org.springframework.batch.core.Job)]
at org.springframework.util.Assert.isNull(Assert.java:176) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.validateFallbackMethods(MessagingMethodInvokerHelper.java:755) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:740) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:294) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:231) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.support.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:225) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:62) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.handler.ServiceActivatingHandler.<init>(ServiceActivatingHandler.java:39) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.BaseIntegrationFlowDefinition.handle(BaseIntegrationFlowDefinition.java:960) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:510) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:65) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.BaseIntegrationFlowDefinition.handle(BaseIntegrationFlowDefinition.java:939) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:503) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:65) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.BaseIntegrationFlowDefinition.handle(BaseIntegrationFlowDefinition.java:926) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:498) ~[spring-integration-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.batchprocessing.BatchIntegrationConfiguration.integrationFlow(BatchIntegrationConfiguration.java:78) ~[classes/:na]
at com.example.batchprocessing.BatchIntegrationConfiguration$$EnhancerBySpringCGLIB$$238a9f8a.CGLIB$integrationFlow$1(<generated>) ~[classes/:na]
at com.example.batchprocessing.BatchIntegrationConfiguration$$EnhancerBySpringCGLIB$$238a9f8a$$FastClassBySpringCGLIB$$b8a5aaf.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.batchprocessing.BatchIntegrationConfiguration$$EnhancerBySpringCGLIB$$238a9f8a.integrationFlow(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_211]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 19 common frames omitted
This one handle(fileMessageToJobRequest()) has to be changed to the transform(fileMessageToJobRequest()) since your FileMessageToJobRequest is really a #Transformer. The handle() doesn't understand that annotation and tries to figure out any candidate method to execute at runtime.
The message Found ambiguous parameter type means that there are several methods with different parameters which can be as message handling candidates. In this case we need to be more specific. Like your #Transformer is a good marker, but it is used from the wrong place - the handle() is for a #ServiceActivator.

after updating to android studio 3.5 ,i am not able to debug the application?

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.margmaker.dnb-hHAt7yiqXvda4ywPos6iBw==/base.apk"],nativeLibraryDirectories=[/data/app/com.margmaker.dnb-hHAt7yiqXvda4ywPos6iBw==/lib/x86, /data/app/com.margmaker.dnb-hHAt7yiqXvda4ywPos6iBw==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) ((null):-1)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() ((null):-1)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() ((null):-1)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) ((null):-1)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) ((null):-1)
at void com.margmaker.dnb.activities.DnbLoginRegistration.LoginActivity.onCreate(android.os.Bundle) ((null):-1)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)

How to create a new(original) struts path?

I have tried overriding existing StrutsPortletAction before with their existing struts path with success. However, I can't seem to do the same if I were to try creating my own struts action path.
<hook>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
<struts-action>
<struts-action-path>/portal/set_viewers/</struts-action-path>
<struts-action-impl>com.mine.blogs.hook.BlogEntryViewerStrutsPortletAction</struts-action-impl>
</struts-action>
</hook>
The eclispe IDE gives me this error "/portal/set_viewers/" is not among possible values" and when I go ahead and deploy the built war anyways, tomcat errors as: com.liferay.portal.kernal.util.InstanceFactory can not access a member of class com.mine.blogs.hook.BlogEntryViewerStrutsPortletAction with modifiers ""
Tried with struts-action-path as /blogs/set_viewers/ failed as well.
This is the .java i'm using. Very basic actually.
package com.mine.blogs.hook;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import com.liferay.portal.kernel.struts.StrutsPortletAction;
public class BlogEntryViewerStrutsPortletAction implements StrutsPortletAction {
BlogEntryViewerStrutsPortletAction(){
super();
}
#Override
public void processAction(
PortletConfig arg0, ActionRequest arg1, ActionResponse arg2)
throws Exception {
// TODO Auto-generated method stub
System.out.println("process1");
}
#Override
public void processAction(
StrutsPortletAction arg0, PortletConfig arg1, ActionRequest arg2,
ActionResponse arg3)
throws Exception {
// TODO Auto-generated method stub
System.out.println("process2");
}
#Override
public String render(
PortletConfig arg0, RenderRequest arg1, RenderResponse arg2)
throws Exception {
// TODO Auto-generated method stub
System.out.println("render1");
return null;
}
#Override
public String render(
StrutsPortletAction arg0, PortletConfig arg1, RenderRequest arg2,
RenderResponse arg3)
throws Exception {
// TODO Auto-generated method stub
System.out.println("render2");
return null;
}
#Override
public void serveResource(
PortletConfig arg0, ResourceRequest arg1, ResourceResponse arg2)
throws Exception {
// TODO Auto-generated method stub
System.out.println("serve1");
}
#Override
public void serveResource(
StrutsPortletAction arg0, PortletConfig arg1, ResourceRequest arg2,
ResourceResponse arg3)
throws Exception {
// TODO Auto-generated method stub
System.out.println("serve2");
}
}
And the corresponding liferay-hook.xml
<hook>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
<struts-action>
<struts-action-path>/blogs_entry/set_viewers/</struts-action-path>
<struts-action-impl>com.mine.blogs.hook.BlogEntryViewerStrutsPortletAction</struts-action-impl>
</struts-action>
</hook>
Please try changing the struts action URL to something other than starting with "/portal". Liferay may be reserving "/portal" for portal level action paths.
For example,
<struts-action-path>/blogs_entry/set_viewers/</struts-action-path>
The error was because of the Constructor. I've removed it and it's now deploying properly

'ExceptionHandlerFactory was not configured properly' on Glassfish 3.1.2.2

I'm trying to handle uncaught exceptions through ExceptionHandler. Following the code in JSF2 complete reference, I've created the classes for my handler. But when I deploy my app, it throws the next stackTrace:
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.ExceptionHandlerFactory' was not configured properly.
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.FacesException: exception.ExceptionHandlerFactory
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643)
at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509)
at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139)
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343)
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303)
... 45 more
Caused by: java.lang.InstantiationException: exception.ExceptionHandlerFactory
at java.lang.Class.newInstance0(Class.java:342)
at java.lang.Class.newInstance(Class.java:310)
at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641)
... 50 more
This is my faces-config.xml:
<factory>
<exception-handler-factory>
exception.ExceptionHandlerFactory
</exception-handler-factory>
</factory>
ExceptionHandlerFactory.java
public class ExceptionHandlerFactory extends javax.faces.context.ExceptionHandlerFactory {
private transient Logger logger = Logger.getLogger(this.getClass().getName());
private ExceptionHandlerFactory parent;
public ExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
#Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = parent.getExceptionHandler();
result = new CustomExceptionHandler(result);
return result;
}
}
CustomExceptionHandler.java
public class CustomExceptionHandler extends ExceptionHandlerWrapper {
private ExceptionHandler parent;
public CustomExceptionHandler(ExceptionHandler parent) {
this.parent = parent;
}
#Override
public ExceptionHandler getWrapped() {
return this.parent;
}
#Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i =
getUnhandledExceptionQueuedEvents().iterator();
i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context =
(ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
ViewExpiredException vee = (ViewExpiredException) t;
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nav =
fc.getApplication().getNavigationHandler();
try {
fc.getExternalContext().
getFlash().put("currentViewId",
vee.getViewId());
nav.handleNavigation(fc, null, "/login?faces-redirect=true");
fc.renderResponse();
} finally {
i.remove();
}
}
}
getWrapped().handle();
}
}
Server is Glassfish 3.1.2.2.
I need to to some logic when I get the ViewExpiredException. Did I miss something?
Thanks in advance !!!!
EDIT:
As #BalusC pointed, I changed my factory class name, so this is my CustomExceptionHandlerFactory.java:
public class CustomExceptionHandlerFactory extends ExceptionHandlerFactory {
private ExceptionHandlerFactory parent;
public CustomExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
#Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = parent.getExceptionHandler();
result = new CustomExceptionHandler(result);
return result;
}
}
and my faces-config.xml:
<factory>
<exception-handler-factory>
com.exception.CustomExceptionHandlerFactory
</exception-handler-factory>
</factory>
I hope this could be helpful for anyone with this silly problem.
Your mistake is that you reused the same classname as an existing API class for some unclear reason and got them mixed up in the code.
The parent constructor argument (and local variable) has to be of type javax.faces.context.ExceptionHandlerFactory, not of your exception.ExceptionHandlerFactory. This wrong type caused that JSF was unable to invoke the constructor and hence the -rather self explaining- InstantiationException (it couldn't be instantiated).
Better rename your class to something unique like CustomExceptionHandlerFactory.

Liferay Hook calling extension method

I have new action in a liferay hook which ideally will be calling methods created in an extension. But at run time when executing the action, it throws the exception
java.lang.ClassNotFoundException
for the methods created in the extension.
Has anybody created similar action in liferay hook? if so, what was the solution for this problem if encountered?
Here is my code:
public class ExampleStrutsAction extends BaseStrutsAction {
public String execute( HttpServletRequest request, HttpServletResponse response) throws Exception {
String name = ParamUtil.get(request, "name", "World");
ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
BSCDynamicDataListLocalServiceUtil.cloneDynamicDataListPageInSuborganization(the‌​meDisplay, name);
return "/portal/sample.jsp";
}
}
Try below code,
hook.xml
<hook>
<portal-properties>portal.properties</portal-properties>
<language-properties>
content/Language.properties
</language-properties>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
<struts-action>
<struts-action-path>/my_account/edit_user</struts-action-path>
<struts-action-impl>com.test.hook.action.EditUserAction</struts-action-impl>
</struts-action>
<struts-action>
<struts-action-path>/users_admin/edit_user</struts-action-path>
<struts-action-impl>com.test.hook.action.EditUserAction</struts-action-impl>
</struts-action>
</hook>
EditUserAction class
public class EditUserAction extends BaseStrutsPortletAction
{
#Override
public void processAction(final StrutsPortletAction originalStrutsPortletAction, final PortletConfig portletConfig,
final ActionRequest actionRequest, final ActionResponse actionResponse) throws Exception
{
// add your custom code
originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
}
#Override
public String render(final StrutsPortletAction originalStrutsPortletAction, final PortletConfig portletConfig, final RenderRequest renderRequest,
final RenderResponse renderResponse) throws Exception
{
//add your custom code
return originalStrutsPortletAction.render(portletConfig, renderRequest, renderResponse);
}
}
I have created above hook for EditUserAction in Control Panel
Hope it helps you!!

Resources