客户端调用服务端报 null?

ssm整合cfx 客户端调用服务端操作数据库的方法报null public static void main(String[] args) throws Exception {

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();

Client client = dcf.createClient("http://localhost:8081/ssm_2/webservice/HelloWorld?wsdl");
Object[] objects=client.invoke("all");

//调用web Service//输出调用结果

System.out.println(objects.length+"---"+objects[0].toString());

}

这是客户端调用

@Service
@WebService(endpointInterface="com.jksd.service.UserServices",serviceName="UserServices",targetNamespace="http://service.jksd.com/")
public class ServicesImpi implements UserServices {
@Autowired
private static UserDao user;

@Override
public List<Permissionlist> all() {
    // TODO Auto-generated method stub
    return user.all();
}

@Override
public String sys(String str) {
    // TODO Auto-generated method stub
    return "666";
}

}
报 user.all()为 null


Caused by: java.lang.NullPointerException: null
at com.jksd.service.servicesImpi.ServicesImpi.all(ServicesImpi.java:23) ~[classes/:na]

这是报的错

1个回答

debug分析一下user是否注入进来。

weixin_44695125
这个柠檬有丶酸 注入失败了,调到实现类那块去掉Dao就null 好像是没注入进去
大约一个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Webservice客户端调用服务端时,服务端一直报错
这个是服务端报错信息: 十一月 18, 2016 2:19:39 下午 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 警告: Application has thrown exception, unwinding now org.apache.cxf.interceptor.Fault at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:148) at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:83) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:114) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:55) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:98) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:452) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:196) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:220) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at org.apache.cxf.transport.servlet.AbstractCXFServlet.service(AbstractCXFServlet.java:211) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.hyjx.framework.interceptor.XSSFilter.doFilter(XSSFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 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:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 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:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at com.hyjx.framework.service.Ddzh_hdxxWebServiceImpl.getOneZhiXingAjxx(Ddzh_hdxxWebServiceImpl.java:39) 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:606) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:166) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82) ... 35 more 下面是客户端调用时的方法(客户端现在不能修改只能改服务端):/** * 执行远程调用,单例模式调用 * * @param url * wsdl URL * @param invokeFunc * 调用方法 * @param objArray * 参数 * @return * @throws Exception */ public static String remoteCall(String url, String invokeFunc, Object... param) { Client client = null; ClientPool pool = ClientPool.getInstance(url); LOGGER.debug("执行webservice使用参数:" + Arrays.toString(param)); LOGGER.debug("执行webservice调用方法:" + invokeFunc); try { client = pool.get(); if (null == client) { return CONNECT_TIMED_OUT; } return executeRemoteCall4String(client, invokeFunc, param); } catch (Exception e) { LOGGER.error("执行webservice调用失败,尝试重新初始化客户端后调用", e); pool.destory(client); client = pool.get(); try { return executeRemoteCall4String(client, invokeFunc, param); } catch (Exception e1) { LOGGER.error("error ro invoke function: " + invokeFunc + ", where remote call url=" + url + " and params:" + Arrays.toString(param)); } } finally { pool.reuse(client); } return null; } /** * 用指定客户端执行远程调用 * * @param Client * Client * @param invokeFunc * 调用方法 * @param objArray * 参数 * @return * @throws Exception */ private static String executeRemoteCall4String(Client client, String invokeFunc, Object[] objArray) throws Exception { if (client == null) { return null; } Object[] results = client.invoke(invokeFunc, objArray); if (results != null && results.length > 0) { String resultStr = (String) results[0]; LOGGER.debug("执行webservice返回结果:" + resultStr); return resultStr; } return null; }
关于webService 客户端 调用 对象数组 问题
我自己写的一个服务端需要的参数是一个对象数组 比如 public String getAge(Student[] ss ) { return ss[0].getAge(); } 这种形式的, 但是在客户端调用的时候 服务端接收到的 ss 对象数组的长度都为1,里面的对象的值都为null,哪位 大神指导一下新人啊 **下面是客户端调用代码** public static void main(String [] args) throws ServiceException, MalformedURLException, RemoteException{ String nameSpace="http://impl.webservice"; String method="getAge"; Service service = new Service(); Call call=(Call)service.createCall(); call.setTargetEndpointAddress(new java.net.URL("http://localhost:8070/TEST/services/testMyService?wsdl")); call.setUseSOAPAction(true); Student[] ss=new Student[2]; Student s0=new Student(); s0.setAge("123"); s0.setName("57"); ss[0]=s0; Student s1=new Student(); s1.setAge("123"); s1.setName("213"); ss[1]=s1; QName qn =new QName(nameSpace,method); call.setOperationName(qn); call.registerTypeMapping(Student.class, qn, new org.apache.axis.encoding.ser.BeanSerializerFactory(Student.class, qn), new org.apache.axis.encoding.ser.BeanDeserializerFactory(Student.class, qn)); String ret = (String) call.invoke(new Object[] {ss}); System.out.println(ret); }
webservice 客户端调用问题
问题: 服务端正常,能够正常访问wsdl地址。 客户端调用,偶尔出现一下错误,有时候不报,网上找了很多办法,都没有解决,不知道有没有高人能够解决,调用代码如下: Object service = null; JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(clazz); factory.setAddress(wsdl); service = factory.create(); (StrucSTaskService)service.sendChildList(); ----------------------- javax.xml.ws.WebServiceException: Could not send Message. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:149) at $Proxy106.send(Unknown Source) at cn.com.xx.turbo.adapter.structured.service.StrucSTaskService.sendChildList(StrucSTaskService.java:565) Caused by: java.net.SocketException: SocketException invoking http://10.1.7.40:8888/turbo/ws/data_exch_service?wsdl: Unexpected end of file from serverJaxWsDynamicClientFactory at sun.reflect.GeneratedConstructorAccessor275.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1364) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1348) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:651) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:138) ... 8 more Caused by: java.net.SocketException: Unexpected end of file from server at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:782) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:641) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1218) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:275) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1563) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1533) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1335) ... 18 more
CXF动态生成client调用服务端,服务端收到参数为空,请教如何解决?
请教大家一个问题。 java做客户端,c#做服务端。java用apache.cxf的DynamicClientFactory或者JaxWsDynamicClientFactory根据wsdl生成client,调用服务端传递UserSyncData对象,服务端方法收到的参数对象是null,请问大家有解决办法吗?(需求:一定要用动态生成客户端的方式) 传递的对象UserSyncData 是jdk或者用cxf的wsdl2java在本地生成的pojo,服务端接受的参数就是空。如果用代理服务类的方式调用,是可以成功的,可以正常收到参数。但是我的项目要求用动态方式调用,所以来请教大家 java中调用的代码 ![CSDN移动问答][1] .net服务端方法:打断点看到userSyncData为null ![CSDN移动问答][2] [1]: http://c.hiphotos.baidu.com/zhidao/pic/item/adaf2edda3cc7cd95ffea4b53b01213fb90e918f.jpg [2]: http://c.hiphotos.baidu.com/zhidao/pic/item/738b4710b912c8fce13d66a1fe039245d788218b.jpg 我自己分析可能是pojo对象在java和c#中定义要达成某种规范,仅是猜测,也不知道应该怎么做。以前和同时调试hessian的时候,要求java和c#的pojo必须一模一样,包括namespace也必须一样,我按这个方法试了以后也没用。
客户端调用web service服务异常
我是一个菜鸟,现在正在学着用wsdl、stub、连接webservice 现在出现的问题是: org.apache.axis2.AxisFault: Exception occurred while trying to invoke service method ReadClientDBByStrings at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at com.estar.test.ws.ReadDataBaseStub.readClientDBByStrings(ReadDataBaseStub.java:255) at com.estar.test.ws.testWebServices.main(testWebServices.java:36) 报这个错,不知道怎么解决,stub生成的两个文件应该是没错的,http://127.0.0.1:8099/webservice/services/ReadDataBase?wsdl连接也是可以成功的。 其中wsdl中的这部分的name应该是args,并且应该是6个,这块怎么改: <xs:sequence> <xs:element minOccurs="0" name="username" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="pwd" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="CustomSearch" nillable="true" type="xs:anyType"/> <xs:element maxOccurs="unbounded" minOccurs="0" name="CustomColumn" nillable="true" type="xs:string"/> <xs:element minOccurs="0" name="SearchTableName" nillable="true" type="xs:string"/> </xs:sequence> 这是测试类,不是我写的,所以也不知道是什么意思: public static void main(String[] args) { ReadDataBaseStub ms = null; try { System.out.println("----------------------getdata--------------------------------"); // 创建CallServiceStub对象,参数为webservice的wsdl地址 // DESPlus des = new DESPlus("estarcom");//自定义密�? String x = "2"; System.out.println(x.equalsIgnoreCase("2")); ms = new ReadDataBaseStub( "http://127.0.0.1:8099/webservice/services/ReadDataBase?wsdl"); System.out.println("1111111111111111111111111111"); ReadDataBaseStub.ReadClientDBByStrings rcbs = new ReadDataBaseStub.ReadClientDBByStrings(); String[] col = new String[2]; col[0] = "MC"; col[1] = "LX"; String[] fi = new String[1]; fi[0] = "MC like '%公司%'"; rcbs.setUsername("fr_select"); rcbs.setPwd("fr_select"); rcbs.setColumn(col); rcbs.setFilters(fi); rcbs.setTableName("T_FR_JBXX"); ReadClientDBByStringsResponse response = ms.readClientDBByStrings(rcbs); String retValue = response.get_return();// 获取到接口返回数�? System.out.println("retValue is : " + retValue); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } 烦请哪位大神可以帮忙解决下
运行在不同机器上的客户端可以共用一个线程向服务端发送不同的数据请求吗
没有开线程之前服务端开启之后总是卡死,必须用资源管理器才能结束任务,后来我打算用线程来负责跟客户端的通信,发现无论开几个客户端,线程名都一样,应该是共用线程了,难道是我两个客户端运行在一个机器上了??现在问题就在于两个客户端共用一个线程与服务端通信查询不同数据时,查询的数据是否是自己需要的数据?代码贴出来 ``` ok.addActionListener(new ActionListener() {//单击按钮开启服务端 @Override public void actionPerformed(ActionEvent arg0) { tip.setText(" 服务端已启动_"); CreateThread ct=new CreateThread(); Thread t1=new Thread(ct);//建立线程 t1.start(); //线程共用问题应该是在这 } }); Run(): @Override public void run() { try { startSocket();//不开线程直接调用startSocket()会导致服务端卡死 } catch (IOException e) { System.out.println("服务端口已开启"); } } 接收客户端请求的startSocket(): private void startSocket() throws IOException { ServerSocket ss=new ServerSocket(6666); Socket server=null; while(true) { //System.out.println(server); server=ss.accept(); if(server!=null) { System.out.println(server); InputStream is=server.getInputStream(); byte[] message=new byte[1024]; int len=is.read(message); String msg=new String(message,0,len); is.close(); server.close(); } } } ```
socket客户端如何主动断开与服务器的连接
这里是客户端 new Thread(new Runnable() { @Override public void run() { try { final Socket socket=new Socket("192.168.43.39",8080); OutputStream out=socket.getOutputStream(); PrintWriter pw=new PrintWriter(out); pw.write("123"); pw.flush(); socket.shutdownOutput(); socket.setSoTimeout(5000); InputStream inputStream=socket.getInputStream(); BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream)); String client=null; while ((client=bufferedReader.readLine())!=null){ System.out.print("这里是客户端。服务器说:"+client); textView.setText("这里是客户端,"+client); } //关闭相关资源 inputStream.close(); bufferedReader.close(); pw.close(); out.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } } }).start(); ``` 这是服务器端 try { ServerSocket serverSocket=new ServerSocket(8080); System.out.print("服务器已启动,正在等待客户端连接...\n"); //记录客户端的数量 int count=0; //循环监听等待客户端的连接 while (true){ //调用accept()方法监听,等待客户端的连接 socket= serverSocket.accept(); System.out.print("服务器已连接客户端!\n"); //创建一个新的线程 ServerThread serverThread=new ServerThread(socket); //开启线程 serverThread.start(); count++; System.out.print("当前客户端的数量为:"+count+"\n"); } } catch (IOException e) { e.printStackTrace(); } ```
dubbo服务端有返回,客户端接收到null的问题【紧急】
### 现象 服务端日志已经显示返回结果,结果为自定义对象 格式如下: ``` AcctQueryFacadeImpl.acctBalanceQuery00, resp=AcctBalanceQuery00Resp[uid=1355739,acctStatus=N,createTime=Fri Mar 04 21:36:31 CST 2016,updateTime=Wed Apr 20 19:52:24 CST 2016,acctId=4985191,balance=0,frozenBalance=0,withdrawBalance=0,respDesc=成功,respCode=000000], time=2ms ``` 客户端接收到的对象为null 该现象并不是必现, - 现象1:调用acctBalanceQuery00方法一天有几十万次,目前出现问题的仅3例 - 现象2:有2条失败数据,重试之后,1条成功,1条仍然失败 - 现象3:很多业务调用acctBalanceQuery00方法,但目前只有1个业务出问题,这些业务入参基本一样,(此现象也许是巧合) - 现象4:用dubbo telnet invoke acctBalanceQuery00方法,有结果返回,用出问题的数据invoke,也有结果返回,所有机器都试过 ### 环境 jdk1.8 dubbo版本 2.5.3 服务端4台,客户端10台左右 dubbo服务端配置如下: ``` <dubbo:application name="xxx" owner="yy"/> <dubbo:registry protocol="zookeeper" client="zkclient" address="${dubbo.zk.servers}" group="${dubbo.zk.group}"></dubbo:registry> <dubbo:protocol name="dubbo" port="20909"></dubbo:protocol> <dubbo:provider retries="0" timeout="6000"></dubbo:provider> <dubbo:service interface="xxxx" ref="xxx"></dubbo:service> ``` dubbo消费端配置: ``` <dubbo:application name="${application.name}" owner="${dubbo.application.owner}"/> <dubbo:registry protocol="zookeeper" client="zkclient" address="${dubbo.zk.servers}" group="${dubbo.zk.group}"></dubbo:registry> <dubbo:protocol name="dubbo" port="${dubbo.protocol.port}"></dubbo:protocol> <dubbo:monitor address="${dubbo.monitor.address}"></dubbo:monitor> <dubbo:consumer retries="0" timeout="6000" check="false"></dubbo:consumer> ```
xfire 客户端没有等待服务端返回,就向下执行,这样导致客户端获取不到返回值
服务端配置: <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" /> <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler" /> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames"> <list> <value>webServiceForPlaceRemote</value> </list> </property> </bean> <bean id="placeManager" class="com.rainsoft.yunReg.manage.PlaceManager" /> <!-- 场所编码生成,获取场所信息接口 --> <bean name="webServiceForPlaceRemote" class="org.codehaus.xfire.spring.ServiceBean"> <property name="serviceBean" ref="placeManager"></property> <property name="serviceClass" value="com.rainsoft.app.webservice.interfaces.WebServiceForPlace"></property> <property name="inHandlers"> <list> <ref bean="addressingHandler" /> </list> </property> </bean> 客户端调用: String url = "http://localhost:8080/yun_reg/service/WebServiceForPlace"; serviceFactory = new ObjectServiceFactory(); Service serviceModel = serviceFactory.create(WebServiceForPlace.class); WebServiceForPlace service=null; try { service = (WebServiceForPlace) new XFireProxyFactory().create(serviceModel,url); Map actionValues = new HashMap(); actionValues.put("areaCode", "342422"); actionValues.put("businessNature", "1"); actionValues.put("serviceType", "1"); String placeCode = service.savePlaceAndReturnPlaceCode(actionValues); System.out.println(placeCode); Map place = service.getPlace("65232810000001"); System.out.println(placeCode); } catch (MalformedURLException e) { e.printStackTrace(); } 服务端代码是执行了,但是客户端打印的都是null。客户端直接向下执行,并不会等待服务端执行结束
客户端读取服务端回执信息时出现error:org.apache.http.ConnectionClosedException
具体error: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body 。 (好像是回执信息数据太大) 网上搜了下,大概意思就是 : 本来在接管数据量,程序员显式封闭了连接(同步调用),而netty是异步处理惩罚,当连接被显式封闭后,后来的数据再次触发读写操纵时贯穿连接已经不成用。所以呈现读不一完全数据的题目。 服务端关键代码: InputStream is = t.getRequestBody(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuffer temp=new StringBuffer(); String lineMessage; while ((lineMessage = reader.readLine()) != null) { temp.append(lineMessage); } reader.close(); is.close(); String respXml=DuXmlDoc.execute(temp.toString()); System.out.println("!!"+respXml); t.sendResponseHeaders(2000, respXml.length()); OutputStream os = t.getResponseBody(); os.write(respXml.getBytes()); os.flush(); os.close(); t.close(); 客户端关键代码: HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); StringBuffer returnMessage = new StringBuffer(); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent())); String lineMessage; while ((lineMessage = bufferedReader.readLine()) != null) { returnMessage.append(lineMessage); } bufferedReader.close(); }
关于CXF webservice 使用JaxWsDynamicClientFactory 方式调用时问题
**关于CXF webservice 使用JaxWsDynamicClientFactory 方式客户端调用时 服务器端service 类和impl类 分开两个package 目录写的,这个时候使用JaxWsDynamicClientFactory 这种方式调用服务就会返回NULL对象,如果将接口类和实现类放在同一个package目录下就可以正常调用。请问各位是不是使用JaxWsDynamicClientFactory 这种方式调用服务 在对代码package结构又要求呢?求解**
C++ TCP CAsyncSocket一服务端对应多客户端的问题
CNetTcpLsn是CAsyncSocket的一个派生类,服务端接收客户端连接,同时要把数据发给连接的客户端,客户的socket保存在m\_ClientSockList里,当发送函数里调用Num = pSock->Send(\_buf,nLen,0) 失败时,想立即把客户端的socket Close并删掉,但是一close就会崩溃,原因是close内部的KillSocket里断言失败,如何才能实现Send失败时,立马释放代表客户端的socket void CNetTcpLsn::OnAccept(int nErrorCode) { if (nErrorCode == 0) { CNetAcpSock* pSock = new CNetAcpSock(m_pBase) ; if (Accept(*pSock)) { pSock->AsyncSelect(FD_READ|FD_CONNECT|FD_CLOSE|FD_OOB) ; pSock->m_bConnect = TRUE; m_ClientSockList.push_back(pSock); m_bConnect = TRUE ; //连接标志 SOCKADDR clientAddr; int iLength = sizeof(sockaddr); if(pSock->GetPeerName((struct sockaddr * )&clientAddr, &iLength)) { sockaddr_in * pSin = (sockaddr_in *)&clientAddr; m_pBase->m_ConAddr.Format("%s:%d",inet_ntoa(pSin->sin_addr),ntohs(pSin->sin_port)); }else m_pBase->m_ConAddr = "0.0.0.0:0"; } else { delete pSock ; pSock = NULL ; } } CAsyncSocket::OnAccept(nErrorCode); } ``` ``` //发送函数 int CNetTcpLsn::_Send(char *_buf, int nLen) { int Num = 0 ; vector<CNetAcpSock*>::iterator iter; for (iter=m_ClientSockList.begin();iter!=m_ClientSockList.end();++iter) { CNetAcpSock* pSock = (CNetAcpSock*) *iter; if (pSock) { Num = pSock->Send(_buf,nLen,0) ; if (Num == SOCKET_ERROR) { int ret = GetLastError() ; if( ret != 10035) { if (pSock->m_bConnect) { pSock->m_bConnect = FALSE ;//连接中断 } } } else { if (!m_bConnect) { pSock->m_bConnect = TRUE; } } } } return Num ; } ``` ``` void PASCAL CAsyncSocket::KillSocket(SOCKET hSocket, CAsyncSocket* pSocket) { // assert会失败CAsyncSocket::LookupHandle(hSocket, FALSE)返回是NULL ASSERT(CAsyncSocket::LookupHandle(hSocket, FALSE) != NULL); _AFX_SOCK_THREAD_STATE* pState = _afxSockThreadState; CAsyncSocket::DetachHandle(hSocket, FALSE); if (pState->m_hSocketWindow != NULL) { ::PostMessage(pState->m_hSocketWindow, WM_SOCKET_DEAD, (WPARAM)hSocket, 0L); CAsyncSocket::AttachHandle(hSocket, pSocket, TRUE); } } ```
请大神解答一下关于netty客户端定时发送消息给服务端
1 . 只有一个客户端和服务端 连着 , 发送消息的时候用channel 的 writeAndFlush , 用线程结果Channel 一直被线程占用 , 只能发消息 , 其他的事情做不了 2. 请问有什么解决的办法吗 , 或者netty 是有那个类可以专门处理客户端给服务端发送数据的呢 3. 还有就是有没有关于客户端给服务端发送数据执行流程的博文呢 4 . 谢谢帮助我的大神 ``` // workerGroup处理已经被接收的连接 NioEventLoopGroup workerGroup = new NioEventLoopGroup(); AtsClient client = this; //workerGroup.scheduleAtFixedRate(command, initialDelay, period, unit); try { // Bootstrap是一个启动 NIO 服务的辅助启动类 Bootstrap b = new Bootstrap(); b.group(workerGroup); // 使用NioSocketChannel类的新的channel接收进来的连接 b.channel(NioSocketChannel.class); // option() 是提供给NioSocketChannel用来接收进来的连接 b.option(ChannelOption.SO_KEEPALIVE, true); // 处理最近接收的channel b.handler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { // 设定IdleStateHandler心跳检测每五秒进行一次写检测,如果五秒内write()方法未被调用则触发一次userEventTrigger()方法,实现客户端每五秒秒向服务端发送一次消息 ch.pipeline().addLast( new IdleStateHandler(0, 5, 0, TimeUnit.SECONDS)); // 解码器 ch.pipeline().addLast("AtsDecoder", new AtsDecoder()); // 处理器 ch.pipeline().addLast("AtsHanler", new AtsHandler(client)); // 编码器 ch.pipeline().addLast("AtsEncoder", new AtsEncoder()); } }); // Start the client. 绑定端口然后启动服务 ChannelFuture f = b.connect(host, port).sync(); channel = f.channel(); System.out.println(channel); channel.eventLoop().scheduleAtFixedRate(new Runnable() { @Override public void run() { sendPlanTrain(); } }, 5, 3, TimeUnit.SECONDS); 这个是客户端连接服务端的代码 , 这里调用了channel的eventLoop().scheduleAtFixedRate , 启动了线程 , 里面是往服务端发送的数据方法 . channel 执行了sendPlanTrain(); 就一直被线程征用 , 其他处理器无法使用 ``` ``` class Sender implements Runnable { Channel channel = null; public Sender(Channel channel) { this.channel = channel; } @Override public void run() { Map<String,String> ScadaDataMap = null; Jedis jedis = null; try { ScadaDataMap = new HashMap<String,String>(); Thread.sleep(3 * 1000); //设置暂停的时间 3 秒 JedisUtilProxy.initJedisPoolUtil("127.0.0.1", 6379); jedis = JedisUtilProxy.getJedis(); for (int i = 1 ; i <= 30 ; i++) { String statu = jedis.hget("SCADA_DATA",String.valueOf(i)); ScadaDataMap.put(String.valueOf(i), statu); } sendPlanTrain(); } catch (Exception e) { e.printStackTrace(); } } ``` ``` @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { logger.debug("===AtsHandler.userEventTriggered.客户端循环心跳监测发送: " + new Date()); if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; if (event.state() == IdleState.WRITER_IDLE) { logger.debug("===AtsHandler.userEventTriggered.客户端没有信息发送给服务端 客户端每5秒发送 MESSAGE_POLLING 信息给服务端"); ByteBuf byteBuf = null; byte[] frameHead = new byte[4]; frameHead[0] = (byte) 0xff; frameHead[1] = 0; frameHead[2] = 5; frameHead[3] = 0; byte[] message = new byte[4]; message[0] = 0; message[1] = (byte) 2; message[2] = (byte) (AtsMessageIDCodeEnum.MESSAGE_POLLING .getCode() >> 8); message[3] = (byte) (AtsMessageIDCodeEnum.MESSAGE_POLLING .getCode() & 0xFF); byte[] frame = ArrayUtils.addAll(frameHead, message); byteBuf = ctx.channel().alloc().buffer(8 * 4); byteBuf.writeBytes(frame); ctx.writeAndFlush(byteBuf); } } ```
WCF客户端调用时出现”无法处理消息。这很可能是因为操作不正确“问题
今天在使用WCF调试时出现了以下异常 ![图片说明](https://img-ask.csdn.net/upload/201507/30/1438267117_354850.png) ”无法处理消息。这很可能是因为操作“http://tempuri.org/IUserInfo/GetUserUserList”不正确,或因为消息包含无效或过期的安全上下文令牌,或因为绑定之间出现不匹配。如果由于未处于活动状态导致服务中止了该通道,则安全上下文令牌无效。若要防止服务永久中止闲置会话,请增加服务终结点绑定上的接收超时“ 服务器端的配置如下 ``` <system.serviceModel> <!--测试配置--> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IUserInfo" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false"> <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/> <security mode="None"/> </binding> </wsHttpBinding> </bindings> <services> <service name="WCFMonitorInterface.UserInfoService"> <!-- Service Endpoints --> <endpoint address="http://192.168.14.18:20005/UserInfoService/mex" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUserInfo" contract="WCFMonitorInterface.Interfaces.IUserInfo"> </endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior> <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false --> <serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.14.18:20005/UserInfoService/metadata"/> <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <protocolMapping> <add binding="basicHttpsBinding" scheme="https" /> </protocolMapping> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel> ``` 客户端配置如下 ``` <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IUserInfo" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false"> <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/> <security mode="None"></security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://192.168.14.18:20005/UserInfoService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUserInfo" contract="UserInfoService.IUserInfo" name="WSHttpBinding_IUserInfo"> <identity> <userPrincipalName value="ludi\ODST" /> </identity> </endpoint> </client> </system.serviceModel> ``` 由于WCF服务是寄宿在一个控制台程序下,也做了一些初始设置,代码如下 ``` host.AddServiceEndpoint(typeof(IUserInfo), new WSHttpBinding(), uri); if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null) { ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; behavior.HttpGetUrl = new Uri(MetaUri); host.Description.Behaviors.Add(behavior); } host.Opened += delegate { Console.WriteLine("WCF服务已开启"); Console.WriteLine("WCF服务元数据地址:"+MetaUri); }; host.Open(); ``` 以上,望解答,谢谢
netty服务端接收报文由于客户端计算长度错误阻塞在decoder中
代码是这个逻辑,传输内容的前8位代表长度,获取长度后,在收到信息的长度等于获取到的内容长度时。将信息添加处理。但是如果客户端调用时计算长度错误,就会在这里阻塞。这个情景使用IdleStateHandler 时无法进行超时处理的。该如何才能够设置这个超时呢。 ``` protected void decode(ChannelHandlerContext context, ByteBuf byteBuf, List<Object> list) { int length = byteBuf.readableBytes(); if(length==0) return; byte[] message = new byte[length]; byteBuf.readBytes(message); if (content != null) { System.arraycopy(message,0,content,receiveLength+8,length); } receiveLength +=length; //如果还没获取总长度 if (xmlLength == 0) { byte[] l= Arrays.copyOf(message,8); xmlLength = Integer.parseInt(new String(l)); content=new byte[xmlLength+8]; System.arraycopy(message,0,content,0,length); } if (xmlLength == receiveLength) { //将报文信息打印到控制台查看 if(content!=null) { String recv = new String(content, StandardCharsets.UTF_8); log.info("收到报文:" + recv); log.info("总长度:[" + xmlLength + "] 接收长度:[" + receiveLength + "]"); list.add(recv); } } } ```
webservice服务器返回值为null
用myeclipse的jax-ws做的服务器,按照如下教程做的。 http://blog.csdn.net/flightme/article/details/6977191 服务器挂的tomcat7,用wsdl2objc转换为xcode的代码,在xcode中调用,以下是xcode的教程。 http://www.devdiv.com/iOS_iPhone-_wsdl_objc_web_service_soap_sample-thread-36521-1-1.html 现在的问题是,苹果的客户端发送数据成功,但是jax-ws的服务器端接收到的是null,但是客户端能够收到服务器端的返回值。 求大神帮忙~小弟先在此谢过。
CXF+spring+hibernate客户端调用总出错
问题在这里: http://www.iteye.com/problems/2056 因为不会用这个javaeye,没有回复自己的提问,点错了,把回复上一人的答案,所以只好点了采纳答案给结了贴! 请各位帮帮忙! 正如前面的贴子我也加入了cjlig包但还是有错误: 2008-7-31 12:54:51 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 信息: Application has thrown exception, unwinding now: Error creating bean with name sessionFactory defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V [b]问题补充:[/b] 这个我已经都加入,问题已经解决上面的问题!一个是因为我的cxf用的是cxf-2.1.1.jar 所以要用asm-2.2.3.jar包,并且要把asm.jar,asm-attrs.jar包删掉!不然冲突! 但现在客户端连接的时候出现以下错误: 2008-8-1 9:26:46 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1374765: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1374765]; startup date [Fri Aug 01 09:26:46 CST 2008]; root of context hierarchy 2008-8-1 9:26:46 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [applicationContext.xml] 2008-8-1 9:26:46 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1374765]: org.springframework.beans.factory.support.DefaultListableBeanFactory@10ad7c 2008-8-1 9:26:46 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10ad7c: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 9:26:47 org.hibernate.cfg.annotations.Version <clinit> 信息: Hibernate Annotations 3.3.0.GA 2008-8-1 9:26:47 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.2.5 2008-8-1 9:26:47 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2008-8-1 9:26:47 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : cglib 2008-8-1 9:26:47 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2008-8-1 9:26:47 org.hibernate.cfg.Configuration configure 信息: configuring from url: file:/F:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/hib3/WEB-INF/classes/hibernate.cfg.xml 2008-8-1 9:26:47 org.hibernate.cfg.Configuration addResource 信息: Reading mappings from resource : com/spingDao/Jobseekeruser.hbm.xml 2008-8-1 9:26:48 org.hibernate.cfg.Configuration doConfigure 信息: Configured SessionFactory: null 2008-8-1 9:26:48 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons 信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10ad7c: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 9:26:48 com.spingDao.JobseekeruserDAO findAll 严重: find all failed java.lang.NullPointerException at com.spingDao.JobseekeruserDAO.findAll(JobseekeruserDAO.java:128) at com.spingDao.cxfWebServerImpl.getJobseekeruser(cxfWebServerImpl.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:97) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:279) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 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:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Unknown Source) 2008-8-1 9:26:48 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 信息: Application has thrown exception, unwinding now org.apache.cxf.interceptor.Fault at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:119) at org.apache.cxf.jaxws.JAXWSMethodInvoker.createFault(JAXWSMethodInvoker.java:73) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:107) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:97) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:279) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 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:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException at com.spingDao.JobseekeruserDAO.findAll(JobseekeruserDAO.java:128) at com.spingDao.cxfWebServerImpl.getJobseekeruser(cxfWebServerImpl.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82) ... 26 more 总是说:信息: Configured SessionFactory: null 不知道这个应该是不是要在web.xml里配置什么吗? 而我的web.xml如下: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/beans.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 而bean.xml如下: <?xml version="1.0" encoding="UTF-8"?> <!-- START SNIPPET: beans --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:endpoint id="cxfWebServer" implementor="com.spingDao.cxfWebServerImpl" address="/cxfWebServer"> </jaxws:endpoint> </beans> [b]问题补充:[/b] package com.spingDao; import java.util.Date; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.LockMode; import org.springframework.context.ApplicationContext; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import org.springframework.orm.toplink.SessionFactory; /** * A data access object (DAO) providing persistence and search support for * Jobseekeruser entities. Transaction control of the save(), update() and * delete() operations can directly support Spring container-managed * transactions or they can be augmented to handle user-managed Spring * transactions. Each of these methods provides additional information for how * to configure it for the desired type of transaction control. * * @see com.spingDao.Jobseekeruser * @author MyEclipse Persistence Tools */ public class JobseekeruserDAO extends HibernateDaoSupport { private static final Log log = LogFactory.getLog(JobseekeruserDAO.class); // property constants public static final String JOBSEEKERLOGIN = "jobseekerlogin"; public static final String JOBSEEKERCODE = "jobseekercode"; public static final String EMAIL = "email"; public static final String PASSWORD = "password"; public static final String CHECKSTATUS = "checkstatus"; public static final String EMAILSTATUS = "emailstatus"; protected void initDao() { // do nothing } public void save(Jobseekeruser transientInstance) { log.debug("saving Jobseekeruser instance"); try { getHibernateTemplate().save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } } public void delete(Jobseekeruser persistentInstance) { log.debug("deleting Jobseekeruser instance"); try { getHibernateTemplate().delete(persistentInstance); log.debug("delete successful"); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } } public Jobseekeruser findById(java.lang.Long id) { log.debug("getting Jobseekeruser instance with id: " + id); try { Jobseekeruser instance = (Jobseekeruser) getHibernateTemplate() .get("com.spingDao.Jobseekeruser", id); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } public List findByExample(Jobseekeruser instance) { log.debug("finding Jobseekeruser instance by example"); try { List results = getHibernateTemplate().findByExample(instance); log.debug("find by example successful, result size: " + results.size()); return results; } catch (RuntimeException re) { log.error("find by example failed", re); throw re; } } public List findByProperty(String propertyName, Object value) { log.debug("finding Jobseekeruser instance with property: " + propertyName + ", value: " + value); try { String queryString = "from Jobseekeruser as model where model." + propertyName + "= ?"; return getHibernateTemplate().find(queryString, value); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } } public List findByJobseekerlogin(Object jobseekerlogin) { return findByProperty(JOBSEEKERLOGIN, jobseekerlogin); } public List findByJobseekercode(Object jobseekercode) { return findByProperty(JOBSEEKERCODE, jobseekercode); } public List findByEmail(Object email) { return findByProperty(EMAIL, email); } public List findByPassword(Object password) { return findByProperty(PASSWORD, password); } public List findByCheckstatus(Object checkstatus) { return findByProperty(CHECKSTATUS, checkstatus); } public List findByEmailstatus(Object emailstatus) { return findByProperty(EMAILSTATUS, emailstatus); } public List findAll() { log.debug("finding all Jobseekeruser instances"); try { String queryString = "from Jobseekeruser"; return getHibernateTemplate().find(queryString); } catch (RuntimeException re) { log.error("find all failed", re); throw re; } } public Jobseekeruser merge(Jobseekeruser detachedInstance) { log.debug("merging Jobseekeruser instance"); try { Jobseekeruser result = (Jobseekeruser) getHibernateTemplate() .merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } public void attachDirty(Jobseekeruser instance) { log.debug("attaching dirty Jobseekeruser instance"); try { getHibernateTemplate().saveOrUpdate(instance); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public void attachClean(Jobseekeruser instance) { log.debug("attaching clean Jobseekeruser instance"); try { getHibernateTemplate().lock(instance, LockMode.NONE); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public static JobseekeruserDAO getFromApplicationContext( ApplicationContext ctx) { return (JobseekeruserDAO) ctx.getBean("JobseekeruserDAO"); } } [b]问题补充:[/b] 什么都没有!只是hibernate自动生成的方法! [b]问题补充:[/b] 刚刚把问题以上的JobseekeruserDAO改了一下: public static JobseekeruserDAO getFromApplicationContext( ApplicationContext ctx) { return (JobseekeruserDAO) ctx.getBean("personDao"); ---- 这里和配置文件不一样,写错了,原因是加了事务!没有和配置一样 } 但是还是出错以下错误: 2008-8-1 11:05:26 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet CXFServlet threw exception java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:78) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:279) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 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:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) [b]问题补充:[/b] 提交得太快,问题还是一样: 信息: Configured SessionFactory: null [b]问题补充:[/b] 代码是这样写的: public Jobseekeruser getJobseekeruser(long id) { ApplicationContext ap = new ClassPathXmlApplicationContext( "applicationContext.xml"); System.out.println("insert Start oK!"); JobseekeruserDAO jdo = (JobseekeruserDAO) ap.getBean("personDao"); //JobseekeruserDAO jdo = new JobseekeruserDAO(); // TODO Auto-generated method stub return (Jobseekeruser) jdo.findAll().get(0); } 应该已经注入了吧? [b]问题补充:[/b] 我在Tomcat中打印出来的。 2008-8-1 13:49:21 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@135fd95: display name [org.springframework.context.support.ClassPathXmlApplicationContext@135fd95]; startup date [Fri Aug 01 13:49:21 CST 2008]; root of context hierarchy 2008-8-1 13:49:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [applicationContext.xml] 2008-8-1 13:49:21 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@135fd95]: org.springframework.beans.factory.support.DefaultListableBeanFactory@f1735 2008-8-1 13:49:21 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@f1735: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 13:49:21 org.hibernate.cfg.Configuration configure 信息: configuring from url: file:/F:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/hib3/WEB-INF/classes/hibernate.cfg.xml 2008-8-1 13:49:21 org.hibernate.cfg.Configuration addResource 信息: Reading mappings from resource : com/spingDao/Jobseekeruser.hbm.xml 2008-8-1 13:49:21 org.hibernate.cfg.Configuration doConfigure 信息: Configured SessionFactory: null 2008-8-1 13:49:21 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons 信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@f1735: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 13:49:21 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1c47dd5: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1c47dd5]; startup date [Fri Aug 01 13:49:21 CST 2008]; root of context hierarchy 2008-8-1 13:49:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [applicationContext.xml] 2008-8-1 13:49:21 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1c47dd5]: org.springframework.beans.factory.support.DefaultListableBeanFactory@10f8ed 2008-8-1 13:49:21 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10f8ed: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 13:49:21 org.hibernate.cfg.Configuration configure 信息: configuring from url: file:/F:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/hib3/WEB-INF/classes/hibernate.cfg.xml 2008-8-1 13:49:21 org.hibernate.cfg.Configuration addResource 信息: Reading mappings from resource : com/spingDao/Jobseekeruser.hbm.xml 2008-8-1 13:49:21 org.hibernate.cfg.Configuration doConfigure 信息: Configured SessionFactory: null===========这里!!! 2008-8-1 13:49:21 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons 信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10f8ed: defining beans [spingSF,JobseekeruserDAO,transactionManager,personDao]; root of factory hierarchy 2008-8-1 13:49:21 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 信息: Application has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Error creating bean with name 'spingSF' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/persistence/JoinTable at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:119) at org.apache.cxf.jaxws.JAXWSMethodInvoker.createFault(JAXWSMethodInvoker.java:73) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:107) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:97) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:279) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 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:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spingSF' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/persistence/JoinTable at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.spingDao.cxfWebServerImpl.getJobseekeruser(cxfWebServerImpl.java:15) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82) ... 26 more Caused by: java.lang.NoClassDefFoundError: javax/persistence/JoinTable at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:263) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333) ... 47 more Caused by: java.lang.ClassNotFoundException: javax.persistence.JoinTable at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 53 more [b]问题补充:[/b] 后面的信息: 信息: Application has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Error creating bean with name 'spingSF' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/persistence/JoinTable [b]问题补充:[/b] 这个我也不明白!但我可以看到值已经传回到服务端! 就是存取的时候出问题!看来是spring的问题!或者是如llade说的一样! 但是我现在还是不明白是那里出了问题! 在服务端写的测试也可以通过,但到了客户端为什么不可以, public boolean insertData(Jobseekeruser user) { try { System.out.println(user.getEmail()); jobseekeruserDAO.save(user); } catch (Exception ex) { System.out.println(ex.getLocalizedMessage()); System.out.println("kdkd"); return false; } return true; } 如方法改成了这样,在服务端的打印出来这样: 4454667@126.com null kdkd 2008-8-1 16:05:41 org.apache.cxf.phase.PhaseInterceptorChain doIntercept 信息: Application has thrown exception, unwinding now org.apache.cxf.interceptor.Fault at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:119) at org.apache.cxf.jaxws.JAXWSMethodInvoker.createFault(JAXWSMethodInvoker.java:73) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:107) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:97) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56) at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78) at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:279) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:161) at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 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:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException at com.spingDao.cxfWebServerImpl.getJobseekeruser(cxfWebServerImpl.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82) ... 26 more [b]问题补充:[/b] 都为空呀! 现在我按别人给的提示但我回传给服务器的时候怎么是long型的数据全为null 但是是String的就有 [b]问题补充:[/b] 问题得到了 lggege 的提示问题基本上解决,现在的问题是只要我的jobseekeruser里的一些字段为long型的,传到服务端时都为null了,但在客户端的时候是有值,而其他为string的都可以传到服务端!不知道大家有没有碰到这样的问题! [b]问题补充:[/b] 问题都解决了!原来是C#代码写得有问题,附值时还要把对应的更新让系统知道把对应的 Specified = true;
feign 通过服务名调用报错404
## feign 通过服务名调用报错404 eureka注册中心 ![图片说明](https://img-ask.csdn.net/upload/201908/21/1566361357_431785.png) **生产服务代码配置信息** ``` server: port: 8100 spring: application: name: admin-service-api eureka: instance: ##注册中心IP地址 hostname: localhost ### 实例名称显示IP配置 preferIpAddress: true instance-id: ${spring.application.name}:${server.port} client: serviceUrl: defaultZone: http://localhost:8700/eureka/ ``` ``` @RequestMapping("/admin-service-api") public interface DevicePrisionerService { @RequestMapping(value = "/getUser", method = RequestMethod.GET) String getUser(); } ``` **消费服务代码配置信息** eureka配置文件: ``` server: port: 8200 spring: application: name: NanhaiAdminWeb eureka: instance: ##注册中心IP地址 hostname: localhost ### 实例名称显示IP配置 preferIpAddress: true instance-id: ${spring.application.name}:${server.port} client: serviceUrl: defaultZone: http://localhost:8700/eureka/ ``` FeignClient客户端调用代码 ``` @FeignClient(name = "admin-service-api") public interface AdminService { @RequestMapping(value = "/getUser", method = RequestMethod.GET) String getUser(); } ``` Controller调用: ``` @RestController public class AdminController { @Autowired private AdminService adminService; @GetMapping("login") public Object login(){ return adminService.getUser(); } } ``` **错误信息:** ``` 2019-08-21 11:48:09.015 INFO 13252 --- [nio-8200-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2019-08-21 11:48:09.015 INFO 13252 --- [nio-8200-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2019-08-21 11:48:09.021 INFO 13252 --- [nio-8200-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms 2019-08-21 11:48:09.167 INFO 13252 --- [nio-8200-exec-1] c.netflix.config.ChainedDynamicProperty : Flipping property: admin-service-api.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2019-08-21 11:48:09.190 INFO 13252 --- [nio-8200-exec-1] c.n.u.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-admin-service-api 2019-08-21 11:48:09.191 INFO 13252 --- [nio-8200-exec-1] c.netflix.loadbalancer.BaseLoadBalancer : Client: admin-service-api instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=admin-service-api,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null 2019-08-21 11:48:09.195 INFO 13252 --- [nio-8200-exec-1] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater 2019-08-21 11:48:09.212 INFO 13252 --- [nio-8200-exec-1] c.netflix.config.ChainedDynamicProperty : Flipping property: admin-service-api.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2019-08-21 11:48:09.213 INFO 13252 --- [nio-8200-exec-1] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client admin-service-api initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=admin-service-api,current list of Servers=[192.168.1.134:8100],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;] },Server stats: [[Server:192.168.1.134:8100; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0] ]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@5539f1f1 2019-08-21 11:48:09.281 ERROR 13252 --- [nio-8200-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException: status 404 reading AdminService#getUser()] with root cause feign.FeignException: status 404 reading AdminService#getUser() at feign.FeignException.errorStatus(FeignException.java:78) ~[feign-core-10.1.0.jar:na] at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:93) ~[feign-core-10.1.0.jar:na] at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:149) ~[feign-core-10.1.0.jar:na] at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78) ~[feign-core-10.1.0.jar:na] at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) ~[feign-core-10.1.0.jar:na] at com.sun.proxy.$Proxy73.getUser(Unknown Source) ~[na:na] at com.zkja.nanhai.admin.controller.AdminController.login(AdminController.java:23) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) ~[spring-webmvc-5.1.4.RELEASE.jar:5.1.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.4.RELEASE.jar:5.1.4.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) ~[tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.14.jar:9.0.14] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.14.jar:9.0.14] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.14.jar:9.0.14] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144] 2019-08-21 11:48:10.203 INFO 13252 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: admin-service-api.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2019-08-21 11:52:11.573 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 11:57:11.577 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:02:11.582 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:07:11.591 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:12:11.595 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:17:11.596 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:22:11.599 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 2019-08-21 12:27:11.609 INFO 13252 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration ``` **HardCodedTarget获取信息:** HardCodedTarget(type=AdminService, name=admin-service-api, url=http://admin-service-api)
使用aidl,服务端和客户端不能正常通信?
服务端目录结构: ![图片说明](https://img-ask.csdn.net/upload/201608/30/1472552456_489544.png) 服务端Service代码: package com.example.remoteservice; import java.util.LinkedList; import java.util.List; import com.example.remoteservice.aidl.IMyService; import com.example.remoteservice.aidl.Person; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; public class RemoteService extends Service { private LinkedList<Person> personList = new LinkedList<Person>(); @Override public IBinder onBind(Intent intent) { return mBinder; } private final IMyService.Stub mBinder = new IMyService.Stub(){ @Override public void savePersonInfo(Person person) throws RemoteException { if (person != null){ personList.add(person); } } @Override public List<Person> getAllPerson() throws RemoteException { return personList; } @Override public String sayHello() throws RemoteException { // TODO Auto-generated method stub return "欢迎你通过AIDL访问服务器端"; } }; } 服务端配置文件: <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.remoteservice.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name="com.example.remoteservice.RemoteService" > <intent-filter > <action android:name="com.example.remoteservice.aidl.IMyService"/> </intent-filter> </service> </application> 客户端主活动: package com.example.remoteclient; import java.util.List; import com.example.remoteservice.aidl.IMyService; import com.example.remoteservice.aidl.Person; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.app.Activity; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { private TextView textHello,textPerson; private IMyService myService; private Button btnSave; private Button btnGet; private static Boolean mIsRemoteBound=false; private ServiceConnection conn=new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { // TODO Auto-generated method stub myService=null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { // TODO Auto-generated method stub myService=IMyService.Stub.asInterface(service); try { textHello.setText(myService.sayHello()); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textHello=(TextView) this.findViewById(R.id.textHello); btnSave=(Button) this.findViewById(R.id.btnSave); btnGet=(Button) this.findViewById(R.id.btnGet); textPerson=(TextView) this.findViewById(R.id.textPerson); if(mIsRemoteBound){ unbindService(conn); }else{ Intent intent=new Intent("com.example.remoteservice.aidl.IMyService"); bindService(intent, conn, BIND_AUTO_CREATE); } mIsRemoteBound = !mIsRemoteBound; btnSave.setOnClickListener(new OnClickListener() { private int index = 0; @Override public void onClick(View v) { // TODO Auto-generated method stub Person person = new Person(); index = index + 1; person.setName("Person" + index); person.setAge(20); person.setTelNumber("123456"); try { myService.savePersonInfo(person); // } catch (RemoteException e) { e.printStackTrace(); } } }); btnGet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub List<Person> list = null; try { list = myService.getAllPerson(); } catch (RemoteException e) { e.printStackTrace(); } if (list != null){ StringBuilder text = new StringBuilder(); for(Person person : list){ text.append("\n联系人:"); text.append(person.getName()); text.append("\n 年龄:"); text.append(person.getAge()); text.append("\n 电话:"); text.append(person.getTelNumber()); } textPerson.setText(text); }else { Toast.makeText(MainActivity.this, "得到数据出错", Toast.LENGTH_SHORT).show(); } } }); } } 客户端目录结构: ![图片说明](https://img-ask.csdn.net/upload/201608/30/1472553743_450725.png) 客户端配置文件里我没有注册活动,可以吗? 运行时需要先运行服务端程序,然后Home键再运行客户端程序,结果客户端调用不了接口中方法,怎么办? logcat:08-30 06:28:38.300: E/AndroidRuntime(781): at com.example.remoteclient.MainActivity$2.onClick(MainActivity.java:77) ![图片说明](https://img-ask.csdn.net/upload/201608/30/1472553120_915416.png) 点击添加报错崩溃 错误日志: 08-30 10:35:09.760: E/AndroidRuntime(791): FATAL EXCEPTION: main 08-30 10:35:09.760: E/AndroidRuntime(791): Process: com.example.remoteclient, PID: 791 08-30 10:35:09.760: E/AndroidRuntime(791): java.lang.NullPointerException 08-30 10:35:09.760: E/AndroidRuntime(791): at com.example.remoteclient.MainActivity$2.onClick(MainActivity.java:77) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.view.View.performClick(View.java:4424) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.view.View$PerformClick.run(View.java:18383) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.os.Handler.handleCallback(Handler.java:733) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.os.Handler.dispatchMessage(Handler.java:95) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.os.Looper.loop(Looper.java:137) 08-30 10:35:09.760: E/AndroidRuntime(791): at android.app.ActivityThread.main(ActivityThread.java:4998) 08-30 10:35:09.760: E/AndroidRuntime(791): at java.lang.reflect.Method.invokeNative(Native Method) 08-30 10:35:09.760: E/AndroidRuntime(791): at java.lang.reflect.Method.invoke(Method.java:515) 08-30 10:35:09.760: E/AndroidRuntime(791): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 08-30 10:35:09.760: E/AndroidRuntime(791): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 08-30 10:35:09.760: E/AndroidRuntime(791): at dalvik.system.NativeStart.main(Native Method)
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了无数
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
大学四年自学走来,这些珍藏的「实用工具/学习网站」我全贡献出来了
知乎高赞:文中列举了互联网一线大厂程序员都在用的工具集合,涉及面非常广,小白和老手都可以进来看看,或许有新收获。
《阿里巴巴开发手册》读书笔记-编程规约
Java编程规约命名风格 命名风格 类名使用UpperCamelCase风格 方法名,参数名,成员变量,局部变量都统一使用lowerCamelcase风格 常量命名全部大写,单词间用下划线隔开, 力求语义表达完整清楚,不要嫌名字长 ...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
Python绘图,圣诞树,花,爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
别低估自己的直觉,也别高估自己的智商
所有群全部吵翻天,朋友圈全部沦陷,公众号疯狂转发。这两周没怎么发原创,只发新闻,可能有人注意到了。我不是懒,是文章写了却没发,因为大家的关注力始终在这次的疫情上面,发了也没人看。当然,我...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
为什么听过很多道理,依然过不好这一生?
记录学习笔记是一个重要的习惯,不希望学习过的东西成为过眼云烟。做总结的同时也是一次复盘思考的过程。 本文是根据阅读得到 App上《万维钢·精英日课》部分文章后所做的一点笔记和思考。学习是一个系统的过程,思维模型的建立需要相对完整的学习和思考过程。以下观点是在碎片化阅读后总结的一点心得总结。
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
Linux 命令(122)—— watch 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] watch(1) manual
Linux 命令(121)—— cal 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] cal(1) manual
记jsp+servlet+jdbc实现的新闻管理系统
1.工具:eclipse+SQLyog 2.介绍:实现的内容就是显示新闻的基本信息,然后一个增删改查的操作。 3.数据库表设计 列名 中文名称 数据类型 长度 非空 newsId 文章ID int 11 √ newsTitle 文章标题 varchar 20 √ newsContent 文章内容 text newsStatus 是否审核 varchar 10 news...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告(本文) 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允
相关热词 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数 c#日期精确到分钟 c#自定义异常必须继承 c#查表并返回值 c# 动态 表达式树 c# 监控方法耗时 c# listbox c#chart显示滚动条
立即提问