起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1506|回复: 3

[结贴] java 类中两个同样的代码一个可以执行,一个不行,是为什

[复制链接]

32

主题

94

帖子

392

积分

中级会员

Rank: 3Rank: 3

积分
392
发表于 2017-2-16 16:06:40 | 显示全部楼层 |阅读模式
UI层调用sxcx报错:
把同样的代码放在main中就没有问题,错在哪?



public static void main(String[] args) {
       
                String host = "http://jshmgsdmfb.market.alicloudapi.com";
                    String path = "/shouji/query";
                    String method = "GET";
                    Map<String, String> headers = new HashMap<String, String>();
                    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
                    headers.put("Authorization", "APPCODE 5f01998661424161bf86f92e468d2188");
                    Map<String, String> querys = new HashMap<String, String>();
                    querys.put("shouji", "13807122945");



       try {
           /**
           * 重要提示如下:
           * HttpUtils请从
           * https://github.com/aliyun/api-ga ... util/HttpUtils.java
           * 下载
           *
           * 相应的依赖请参照
           * https://github.com/aliyun/api-ga ... blob/master/pom.xml
           */
           HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
           System.out.println(response.toString());
           //获取response的body
           System.out.println(EntityUtils.toString(response.getEntity()));
       } catch (Exception e) {
           e.printStackTrace();
       }
                }



public static void sxcx(String param_string){
                System.out.println(param_string);
                  
               
                String host = "http://jshmgsdmfb.market.alicloudapi.com";
                    String path = "/shouji/query";
                    String method = "GET";
                    Map<String, String> headers = new HashMap<String, String>();
                    //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
                    headers.put("Authorization", "APPCODE 5f01998661424161bf86f92e468d2188");
                    Map<String, String> querys = new HashMap<String, String>();
                    querys.put("shouji", "13807122745");



       try {
           /**
           * 重要提示如下:
           * HttpUtils请从
           * https://github.com/aliyun/api-ga ... util/HttpUtils.java
           * 下载
           *
           * 相应的依赖请参照
           * https://github.com/aliyun/api-ga ... blob/master/pom.xml
           */
           HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
           System.out.println(response.toString());
           //获取response的body
           System.out.println(EntityUtils.toString(response.getEntity()));
       } catch (Exception e) {
           e.printStackTrace();
       }
                }
       

32

主题

94

帖子

392

积分

中级会员

Rank: 3Rank: 3

积分
392
 楼主| 发表于 2017-2-16 16:07:38 | 显示全部楼层
param_string
2017-02-16 16:07:15 excute stream action, params:{"accept":"application/json","action":"sxcx","actionFlag":"__action_0__","activity":"mainActivity","contentType":"json","executeContext":"","executor":"","parameters":{"param_string":"param_string"},"process":"/WHRHT/welfare/process/sxcx/sxcxProcess"}
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.justep.system.action.Engine.invokeActions(Native Method)
        at com.justep.system.action.Engine.invokeActions(Unknown Source)
        at com.justep.business.server.BusinessServer.doAction(Unknown Source)
        at com.justep.business.server.BusinessServer.doExcute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.execService(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at com.justep.x.bs.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        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:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory
        at Welfare.sxcx(Welfare.java:235)
        ... 27 more
Caused by: java.lang.ClassNotFoundException: 模块"/WHRHT/welfare/logic/code"中找不到类"org.apache.http.conn.scheme.SchemeSocketFactory"
        at com.justep.model.impl.ModelImpl$ModelClassLoader$1.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 28 more
回复 支持 反对

使用道具 举报

32

主题

94

帖子

392

积分

中级会员

Rank: 3Rank: 3

积分
392
 楼主| 发表于 2017-2-16 16:07:54 | 显示全部楼层
param_string
2017-02-16 16:07:15 excute stream action, params:{"accept":"application/json","action":"sxcx","actionFlag":"__action_0__","activity":"mainActivity","contentType":"json","executeContext":"","executor":"","parameters":{"param_string":"param_string"},"process":"/WHRHT/welfare/process/sxcx/sxcxProcess"}
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.justep.system.action.Engine.invokeActions(Native Method)
        at com.justep.system.action.Engine.invokeActions(Unknown Source)
        at com.justep.business.server.BusinessServer.doAction(Unknown Source)
        at com.justep.business.server.BusinessServer.doExcute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServer.excute(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.execService(Unknown Source)
        at com.justep.business.server.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at com.justep.x.bs.BusinessServerServlet.service(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        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:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SchemeSocketFactory
        at Welfare.sxcx(Welfare.java:235)
        ... 27 more
Caused by: java.lang.ClassNotFoundException: 模块"/WHRHT/welfare/logic/code"中找不到类"org.apache.http.conn.scheme.SchemeSocketFactory"
        at com.justep.model.impl.ModelImpl$ModelClassLoader$1.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 28 more
回复 支持 反对

使用道具 举报

32

主题

94

帖子

392

积分

中级会员

Rank: 3Rank: 3

积分
392
 楼主| 发表于 2017-2-16 16:17:17 | 显示全部楼层
已搞定了,差包
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-4 03:30 , Processed in 0.062723 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表