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

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)

Related

App crashes whenever I press login. Need help in Debugging

I am building a dating app. I coded the part where a swipe of left or right would register it in the Firebase Database. App runs and everything but now when I try to login from the login page the app crashes. The only thing that I changed prior to the crashes was in the MainActivty so therefore I am including that. Since i am new to this i dont really know how to fix this.
The following is the MainActivity.java
package com.example.macdate;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.lorentzos.flingswipe.SwipeFlingAdapterView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private cards cards_data[];
private ArrayAdapter arrayAdapter;
private int i;
private FirebaseAuth mAuth;
private String currentUId;
private DatabaseReference usersDb;
ListView listView;
List<cards> rowItems;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usersDb = FirebaseDatabase.getInstance().getReference().child("Users");
mAuth = FirebaseAuth.getInstance();
checkUserSex();
rowItems = new ArrayList<cards>();
arrayAdapter = new arrayAdapter(this, R.layout.item, rowItems);
SwipeFlingAdapterView flingContainer = (SwipeFlingAdapterView) findViewById(R.id.frame);
flingContainer.setAdapter(arrayAdapter);
flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() {
#Override
public void removeFirstObjectInAdapter() {
// this is the simplest way to delete an object from the Adapter (/AdapterView)
Log.d("LIST", "removed object!");
rowItems.remove(0); // Every time the swipe is done completely the card is removed
arrayAdapter.notifyDataSetChanged();
}
#Override
public void onLeftCardExit(Object dataObject) {
//Do something on the left!
//You also have access to the original object.
//If you want to use it just cast it (String) dataObject
cards obj = (cards) dataObject;
String userId = obj.getUserId();
usersDb.child(oppositeUserSex).child(userId).child("connections").child("nope").child(currentUId).setValue(true); //registering the swipes to the database
Toast.makeText(MainActivity.this, "left", Toast.LENGTH_SHORT).show();
}
#Override
public void onRightCardExit(Object dataObject) {
cards obj = (cards) dataObject;
String userId = obj.getUserId();
usersDb.child(oppositeUserSex).child(userId).child("connections").child("yeps").child(currentUId).setValue(true);
Toast.makeText(MainActivity.this, "right", Toast.LENGTH_SHORT).show(); }
#Override
public void onAdapterAboutToEmpty(int itemsInAdapter) {
}
#Override
public void onScroll(float scrollProgressPercent) {
}
});
// Optionally add an OnItemClickListener
flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {
#Override
public void onItemClicked(int itemPosition, Object dataObject) {
Toast.makeText(MainActivity.this, "click", Toast.LENGTH_SHORT).show(); }
});
}
private String userSex;
private String oppositeUserSex;
public void checkUserSex(){
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
DatabaseReference maleDb = FirebaseDatabase.getInstance().getReference().child("Users").child("Male");
maleDb.addChildEventListener((new ChildEventListener() {
#Override
public void onChildAdded(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
if(dataSnapshot.getKey().equals(user.getUid())){
userSex = "Male";
oppositeUserSex = "Female";
getOppositeSexUsers();
}
}
#Override
public void onChildChanged(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onChildRemoved(#NonNull DataSnapshot dataSnapshot) {
}
#Override
public void onChildMoved(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
}));
DatabaseReference femaleDb = FirebaseDatabase.getInstance().getReference().child("Users").child("Female");
femaleDb.addChildEventListener((new ChildEventListener() {
#Override
public void onChildAdded(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
if(dataSnapshot.getKey().equals(user.getUid())){
userSex = "Female";
oppositeUserSex = "Male";
getOppositeSexUsers();
}
}
#Override
public void onChildChanged(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onChildRemoved(#NonNull DataSnapshot dataSnapshot) {
}
#Override
public void onChildMoved(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
}));
}
public void getOppositeSexUsers(){
DatabaseReference oppositeSexDb = FirebaseDatabase.getInstance().getReference().child("Users").child(oppositeUserSex);
oppositeSexDb.addChildEventListener((new ChildEventListener() {
#Override
public void onChildAdded(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
if(dataSnapshot.exists() && !dataSnapshot.child("connections").child("nope").hasChild(currentUId) && !dataSnapshot.child("connections").child("yeps").hasChild(currentUId)){
cards item = new cards(dataSnapshot.getKey(),dataSnapshot.child("name").getValue().toString());
rowItems.add(item);
arrayAdapter.notifyDataSetChanged();
}
}
#Override
public void onChildChanged(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onChildRemoved(#NonNull DataSnapshot dataSnapshot) {
}
#Override
public void onChildMoved(#NonNull DataSnapshot dataSnapshot, #Nullable String s) {
}
#Override
public void onCancelled(#NonNull DatabaseError databaseError) {
}
}));
}
public void logoutUser(View view){
mAuth.signOut();
Intent intent = new Intent(MainActivity.this,ChooseLoginRegistrationActivity.class); //takes out to the choose page
startActivity(intent);
finish();
return;
}
}
The following is the Logcat
2020-04-11 00:23:27.262 12387-12431/com.example.macdate D/EGL_emulation: eglMakeCurrent: 0xaf6b2ca0: ver 3 0 (tinfo 0xa5f308f0)
2020-04-11 00:23:27.301 12387-12488/com.example.macdate D/FA: Connected to remote service
2020-04-11 00:23:27.303 12387-12488/com.example.macdate V/FA: Processing queued up service tasks: 4
2020-04-11 00:23:27.684 12387-12387/com.example.macdate D/AndroidRuntime: Shutting down VM
2020-04-11 00:23:27.685 12387-12387/com.example.macdate E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.macdate, PID: 12387
java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
at java.util.regex.Matcher.reset(Matcher.java:1052)
at java.util.regex.Matcher.<init>(Matcher.java:180)
at java.util.regex.Pattern.matcher(Pattern.java:1006)
at com.google.firebase.database.core.utilities.Validation.isValidPathString(com.google.firebase:firebase-database##19.2.1:40)
at com.google.firebase.database.core.utilities.Validation.validatePathString(com.google.firebase:firebase-database##19.2.1:44)
at com.google.firebase.database.DataSnapshot.hasChild(com.google.firebase:firebase-database##19.2.1:80)
at com.example.macdate.MainActivity$5.onChildAdded(MainActivity.java:165)
at com.google.firebase.database.core.ChildEventRegistration.fireEvent(com.google.firebase:firebase-database##19.2.1:79)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database##19.2.1:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database##19.2.1:55)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

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.

how to fix error 'int java.util.List.size()'

I am all time worked by one source! but now get error
int java.util.List.size()
now my adapter source its :
public class MessagesAdapter extends RecyclerView.Adapter<MessagesAdapter.msgsViewHoler> {
List<QueryMessages> queryMessages;
Context mtContext;
public MessagesAdapter(List<QueryMessages> queryMessages, MainActivity mainActivity){
this.queryMessages=queryMessages;
}
#NonNull
#Override
public msgsViewHoler onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.message_row,parent,false);
return new msgsViewHoler(view);
}
#Override
public void onBindViewHolder(#NonNull msgsViewHoler holder, int position) {
final QueryMessages queryMessageses=queryMessages.get(position);
Picasso.get()
.load(queryMessageses.getMpic())
.error(R.mipmap.ic_launcher)
.fit()
.into(holder.mpic);
holder.mname.setText(queryMessageses.getMname());
holder.message.setText(queryMessageses.getMessage());
holder.tarikh.setText(queryMessageses.getTarikh());
}
#Override
public int getItemCount() {
return queryMessages.size();
}
public class msgsViewHoler extends RecyclerView.ViewHolder{
int id;
CardView parent;
ImageView mpic;
TextView mname,message,tarikh;
public msgsViewHoler(View itemView) {
super(itemView);
parent=itemView.findViewById(R.id.message_row);
mpic=itemView.findViewById(iv_profile);
mname=itemView.findViewById(R.id.tv_mastername);
message=itemView.findViewById(R.id.tv_msg);
tarikh=itemView.findViewById(R.id.tv_date);
}
}
and give this error :
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at ir.arvandit.channeleto.adapter.MessagesAdapter.getItemCount(MessagesAdapter.java:62)
thats line is :
return queryMessages.size();
my Activity Main its :
RecyclerView rvmsg;
CardView message_row;
List<QueryMessages> queryMessages;
MessagesAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cast();
onClick();
ApiService service=ApiClient.getClient().create(ApiService.class);
Call<List<QueryMessages>> call=service.getQueryMessages();
call.enqueue(new Callback<List<QueryMessages>>() {
#Override
public void onResponse(Call<List<QueryMessages>> call, Response<List<QueryMessages>> response) {
pros.setVisibility(View.GONE);
queryMessages=response.body();
adapter=new MessagesAdapter(queryMessages,MainActivity.this);
rvmsg.setAdapter(adapter);
}
#Override
public void onFailure(Call<List<QueryMessages>> call, Throwable t) {
pros.setVisibility(View.GONE);
nonet.setVisibility(View.VISIBLE);
}
});
}
public void cast(){
rvmsg=findViewById(R.id.rv_message);
rvmsg.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
}
now I need help for fix this error!
Issue is in bellow code
private static final String TAG = "CurrentActivity";
#Override
public void onResponse(Call<List<QueryMessages>> call,
Response<List<QueryMessages>> response) {
Log.v(TAG, "onResponse=" + response.body().toString());
}
check weather response.body() or response is the ArrayList of <List<QueryMessages>>
in new version retrofit if in your json have free parameter , get this error
for example i need id,name,number
but in my json have id,name,number,date ....
i give this error!
and some time if in ApiService have false url!
tanks for help all

#SpringIntegrationTest annotation does not load context as expected

Normally, when I use #SpringBootTest I get the full context of beans. I can the #Autowire all kinds of beans that are available after the application has started.
Now, in the scope of spring-integration-test libary, the #SpringIntegrationTest does not do this.
As the testing module promises, you can use
#Autowired
private MockIntegrationContext mockIntegrationContext;
However, after inspecting the bean map on that instance, I found out there are no beans!
Example test:
#ActiveProfiles("test")
#RunWith(SpringRunner.class)
#SpringIntegrationTest
public class AppTest {
#Autowired
private MockIntegrationContext mockIntegrationContext;
#Test
public void contextLoads() {
// put breakpoint to inspect field
System.out.println(mockIntegrationContext);
}
}
When I however run the following code, I get a complete context:
#ActiveProfiles("test")
#RunWith(SpringRunner.class)
#SpringBootTest
public class App2Test {
#Autowired
private ListableBeanFactory beanFactory;
#Test
public void contextLoads() {
Assert.isTrue(beanFactory.getBeanDefinitionCount() > 0)
}
}
Why is that? How can I achieve a similar result with spring-integration-test?
Reading materials: https://docs.spring.io/spring-integration/docs/current/reference/html/testing.html
They are independent annotations; you need both.
EDIT
This works fine for me:
#RunWith(SpringRunner.class)
#SpringBootTest
#SpringIntegrationTest
public class So52297757ApplicationTests {
#Autowired
private MockIntegrationContext mockIntegrationContext;
#Autowired
private String foo;
#Test
public void contextLoads() {
System.out.println(foo);
System.out.println(mockIntegrationContext);
}
}
and
#SpringBootApplication
public class So52297757Application {
public static void main(String[] args) {
SpringApplication.run(So52297757Application.class, args);
}
#Bean
public String foo() {
return "foo";
}
}
and
foo
org.springframework.integration.test.context.MockIntegrationContext#1de5f0ef

java.lang.ClassCastException: org.apache.log4j.Logger cannot be cast

I extended org.apache.log4j.Logger for implementing logging for method starts and exists.
It works fine, when I don't set the loglevel for a class in my log4j.properties.
When I set
log4j.logger.de.martinm.tools.UniCredit.ExportOperator=INFO
I get an exception:
Exception in thread "main" java.lang.ClassCastException: org.apache.log4j.Logger cannot be cast to de.martinm.tools.Logging.MMLogger
at de.martinm.tools.UniCredit.ExportOperator.(ExportOperator.java:21)
at de.martinm.tools.UniCredit.ExportOperator.main(ExportOperator.java:330)
public class MMLogger extends Logger {
private static MyLoggerFactory myFactory = new MyLoggerFactory();
public MMLogger(String name) {
super(name);
}
public static Category getInstance(String name) {
return Logger.getLogger(name, myFactory);
}
public static Logger getLogger(String name) {
return Logger.getLogger(name, myFactory);
}
public void enter(Logger logger, String method) {
super.debug(method+" enter");
}
public void exit(Logger logger, String method) {
super.debug(method+" exit");
}
public void debug(Logger logger, String method, String text) {
super.debug(method+" "+text);
}
public void warn(Logger logger, String method, String text) {
super.warn(method+" "+text);
}
public void info(Logger logger, String method, String text) {
super.info(method+" "+text);
}
public void error(Logger logger, String method, String text) {
super.error(method+" "+text);
}
}
public class MyLoggerFactory implements LoggerFactory {
/**
The constructor should be public as it will be called by
configurators in different packages. */
public
MyLoggerFactory() {
}
public
Logger makeNewLoggerInstance(String name) {
return new MMLogger(name);
}
}
Here is part of my code
public class ExportOperator {
//public static Logger logger = Logger.getLogger(ExportOperator.class.getName());
public MMLogger Mylogger = (MMLogger) MMLogger.getLogger(ExportOperator.class.getName());
public Connection db_con;
static Utils my_utils = new Utils();
public Properties props = new Properties();
public String output_dir;
public int mid;
public String admin_id;
public int op_id;

Resources