gpt4 book ai didi

java.lang.ClassNotFoundException : org. jpos.iso.ISOException 异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:01 25 4
gpt4 key购买 nike

我是使用 JPOS 和 ISO8583 的初学者。此时,我尝试使用 Spring 在我的应用程序中构建使用 JPOS 的请求,并将其发送到 BASE24。

这里是我的构建代码:

public class BuildISO {

public void sentISOMsg(String hostname, int portNumber) {

// Create Packager based on XML that contain DE type
GenericPackager packager;
ASCIIChannel channel;

try {
packager = new GenericPackager("packager/iso93ascii.xml");
channel = new ASCIIChannel(hostname, portNumber, packager);

ISOMUX isoMux = new ISOMUX(channel) {
@Override
protected String getKey(ISOMsg m) throws ISOException {
return super.getKey(m);
}
};

new Thread(isoMux).start();

// Create ISO Message
ISOMsg isoRequest = new ISOMsg();
isoRequest.setMTI("1800");
isoRequest.set(3, "123456");
isoRequest.set(7, new SimpleDateFormat("yyyyMMdd").format(new Date()));
isoRequest.set(11, "000001");
isoRequest.set(12, new SimpleDateFormat("HHmmss").format(new Date()));
isoRequest.set(13, new SimpleDateFormat("MMdd").format(new Date()));
isoRequest.set(48, "Tutorial ISO 8583 Dengan Java");
isoRequest.set(70, "001");

ISORequest req = new ISORequest(isoRequest);
isoMux.queue(req);

ISOMsg isoReply = req.getResponse(50*1000);

if (isoReply != null) {
System.out.println("Req ["+new String(isoRequest.pack()) + "]");
System.out.println("Res ["+new String(isoReply.pack()) + "]");
}


// print the DE list
logISOMsg(isoRequest);

// Get and print the output result
byte[] data = isoRequest.pack();
System.out.println("RESULT : " + new String(data));
} catch (ISOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private static void logISOMsg(ISOMsg msg) {

System.out.println("----ISO MESSAGE-----");
try {
System.out.println(" MTI : " + msg.getMTI());
for (int i=1;i<=msg.getMaxField();i++) {
if (msg.hasField(i)) {
System.out.println(" Field-"+i+" : "+msg.getString(i));
}
}
} catch (ISOException e) {
e.printStackTrace();
} finally {
System.out.println("--------------------");
}
}
}

接下来,当我想在这里调用那个类时:

public @ResponseBody ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
String hostname = request.getParameter("hostname");
int portNumber = Integer.parseInt(request.getParameter("portNumber"));

System.out.println("handleRequest... : " + hostname + " : " + portNumber);

BuildISO buildISO = new BuildISO();
buildISO.sentISOMsg(hostname, portNumber);

return null;
}

我遇到这样的错误:

SEVERE: Servlet.service() for servlet spring threw exception
java.lang.ClassNotFoundException: org.jpos.iso.ISOException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.sprint.controller.HandleController.handleRequest(HandleController.java:28)
at org.sprint.controller.HandleController$$FastClassByCGLIB$$fc3d18c.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.interceptor.CustomizableTraceInterceptor.invokeUnderTrace(CustomizableTraceInterceptor.java:256)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at org.sprint.controller.HandleController$$EnhancerByCGLIB$$fbdc3830.handleRequest(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)

我搜索了 StackOverflow 已经提出的问题,但没有发现任何对项目进行更改的情况。所以我现在感到非常沮丧,因为我实际上什么都没改变,我的项目已经停止工作。请帮助我,任何想法将不胜感激。

最佳答案

您应该确保在 CLASSPATH 中拥有所有 jar。在您的例子中,它是 jpos.jar。而且它们(使用 Spring)都应该使用相同的 classloader 加载。

还有一个建议:将 -verbose 选项添加到 java(我猜是 Tomcat)以查看从何处加载您的类。

关于java.lang.ClassNotFoundException : org. jpos.iso.ISOException 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24443639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com