Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “线程中的异常”;池-1-线程-1“;空指针异常NoSuchMethodError_Java_Multithreading - Fatal编程技术网

Java “线程中的异常”;池-1-线程-1“;空指针异常NoSuchMethodError

Java “线程中的异常”;池-1-线程-1“;空指针异常NoSuchMethodError,java,multithreading,Java,Multithreading,我正在开发一个多线程的应用程序,在这里我从JMS获得一些请求,线程正在运行以接收消息。下面是我的线程的工作方式: try块中的模型映射器导致了问题,我认为: patientAdder.addPatient(patientAddMessage, authResult, queueSender, baseUrl, modelMapper); 以下是完整的代码: Executors.newSingleThreadExecutor().execute(new Runnable() { public v

我正在开发一个多线程的应用程序,在这里我从JMS获得一些请求,线程正在运行以接收消息。下面是我的线程的工作方式:

try块中的模型映射器导致了问题,我认为:

patientAdder.addPatient(patientAddMessage, authResult, queueSender, baseUrl, modelMapper);
以下是完整的代码:

Executors.newSingleThreadExecutor().execute(new Runnable() {
public void run() {
  while (true) {
SonicQueueMessageSender queueSender = null;
                    try {
                        queueSender = new SonicQueueMessageSender(queueConnProvider);
                    } catch (JMSException e3) {
                        // TODO Auto-generated catch block
                        e3.printStackTrace();
                    }

                    String patientAddMessage = null;
                    try {
                        patientAddMessage = new SonicMessageReceiver(connectionProvider)
                                .getAddJsonMessage("MirthMessage");
                    } catch (JMSException e2) {
                        // TODO Auto-generated catch block
                        e2.printStackTrace();
                    }
                    final AuthModel auth = new AuthModel();
                    String authResult = null;
                    final PatientAdder patientAdder = new PatientAdder();
                    SecurityTokenModel securityToken = null;


                    String authPostString = null;
                    try {
                        authPostString = new ObjectMapper()
                                .writeValueAsString(auth);
                    } catch (JsonGenerationException e) {
                        e.printStackTrace();
                    } catch (JsonMappingException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    System.out.println("Auth post string is: "+ authPostString);
                    System.out.println("base url is: " + baseUrl);
                    String authPostOutput = client
                            .doGetAuthRestPost(authPostString, url);
                    try {
                        securityToken = getAuth(authPostOutput);
                    } catch (JsonParseException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (JsonMappingException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    authResult = securityToken.getAccessToken();
                    try {
                        patientAdder.addPatient(patientAddMessage, authResult, queueSender, baseUrl, modelMapper);
                    } catch (JsonParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (JsonMappingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    // poster.postMessage(patientAddMessage, authResult);
                    catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }catch(Exception e){
                        e.printStackTrace();
                    }

}
}
});
我需要将请求中收到的消息映射到一个bean类,为此我创建了一个
ModelMapper
类对象,该对象具有映射属性的函数,但当我尝试创建映射器类的新对象时,我得到了一个NPE:

Exception in thread "pool-1-thread-1" java.lang.NullPointerException
    at com.prnreferral.util.commons.ModelMapper.mapCanonicalMessageToPatientModel(ModelMapper.java:82)
    at com.prnreferral.patientprocess.add.PatientAdder.addPatient(PatientAdder.java:52)
    at com.prnreferral.patientprocess.add.PIXSAddPatient$1.run(PIXSAddPatient.java:148)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
我确信该对象是在我通过添加一些条件进行检查时创建的,但我缺少一些东西导致了这个问题 我还尝试添加一个新函数来检查此函数是否存在任何问题,但是

Exception in thread "pool-1-thread-1" java.lang.NoSuchMethodError: com.prnreferral.util.commons.ModelMapper.printString()V
at com.prnreferral.patientprocess.add.PatientAdder.addPatient(PatientAdder.java:49)
at com.prnreferral.patientprocess.add.PIXSAddPatient$2.run(PIXSAddPatient.java:173)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

我被困在这个问题上,不知道该怎么办,有人能帮我吗。提前感谢。

更多代码片段和堆栈跟踪将有助于调查issue@Apollo好了,你现在能查一下吗,如果您对此有任何想法,A
NoSuchMethodError
通常是针对依赖项的版本B进行编译的结果,但使用版本A运行。在客户端和服务器之间存在库版本不匹配的网络应用程序中,这很容易发生。检查以确保编译时使用的依赖项与运行测试时使用的依赖项相同。更多代码段和堆栈跟踪将有助于调查issue@Apollo好了,你现在能查一下吗,如果您对此有任何想法,A
NoSuchMethodError
通常是针对依赖项的版本B进行编译的结果,但使用版本A运行。在客户端和服务器之间存在库版本不匹配的网络应用程序中,这很容易发生。检查以确保编译时使用的依赖项与运行测试时使用的依赖项相同。