是否有可能从byte []生成java.security.cert.X509Certificate?
text使用Hibernate 从MySQL数据类型到Java 的正确映射类型是什么?
@Column(name = "STACKTRACE", length = Integer.MAX_VALUE)
public String getStacktrace() {
return this.stacktrace;
}
Run Code Online (Sandbox Code Playgroud) 我必须在Apache CXF客户端中设置一些http头字段:
我通过拦截器尝试过:
public class HttpHeaderInterceptor extends AbstractPhaseInterceptor<Message> {
private String userId;
private String xAuthorizeRoles;
private String host;
public HttpHeaderInterceptor() {
super(Phase.POST_PROTOCOL);
}
@Override
public void handleMessage(Message message) throws Fault {
Map<String, List> headers = (Map<String, List>) message.get(Message.PROTOCOL_HEADERS);
try {
System.out.println("HttpHeaderInterceptor Host: " + host + " UserId: " + userId + " X-AUTHORIZE-roles: " + xAuthorizeRoles);
headers.put("Host", Collections.singletonList(host));
headers.put("UserId", Collections.singletonList(userId));
headers.put("X-AUTHORIZE-roles", Collections.singletonList(xAuthorizeRoles));
} catch (Exception ce) {
throw new Fault(ce);
}
}
public void setUserId(String userId) {
this.userId = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种解决方案来为任何类型的Java对象生成校验和,对于生成相同对象的应用程序的每次执行,它都保持不变.
我试过了Object.hashCode(),但是api说
....从应用程序的一次执行到同一应用程序的另一次执行,这个整数不需要保持一致.
在tomcat容器中开发基于SPRING的调度程序期间,我总是在取消部署webapp或shutdown服务器时获得此logoutput:
Apr 28, 2010 4:21:33 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
Apr 28, 2010 4:21:33 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
Apr 28, 2010 4:21:33 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2] but has failed to stop it. This is very likely to create a memory leak. …Run Code Online (Sandbox Code Playgroud) 我在基于Spring Boot的Rest服务中定义了一个全局异常处理:
@ControllerAdvice
public class GlobalExceptionController {
private final Logger LOG = LoggerFactory.getLogger(getClass());
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR, reason = "Internal application error")
@ExceptionHandler({ServiceException.class})
@ResponseBody
public ServiceException serviceError(ServiceException e) {
LOG.error("{}: {}", e.getErrorCode(), e.getMessage());
return e;
}
}
Run Code Online (Sandbox Code Playgroud)
和自定义ServiceException:
public class ServiceException extends RuntimeException {
private static final long serialVersionUID = -6502596312985405760L;
private String errorCode;
public ServiceException(String message, String errorCode, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
}
// other constructors, getter and setters omitted
}
Run Code Online (Sandbox Code Playgroud)
到目前为止一切都那么好,当一个异常被触发时,控制器按预期工作并响应:
{
"timestamp": 1413883870237,
"status": …Run Code Online (Sandbox Code Playgroud) 在开发过程中,我经常需要将一个大型war文件(~45 MB)部署到远程测试服务器,通常我用scp将文件复制到服务器.
WEB-INF/lib文件夹构成war文件的最大部分,其中包括所有必需的库(spring,apache-cxf,hibernate,...).
现在我正在寻找一种快速简便的方法来重新部署我修改过的文件.
我怎么能确定webapp真正需要哪些软件包,因为spring和apache-cxf带有很多库,我相信我不需要所有这些软件包.
在开发期间,REST服务(Spring Boot 1.1.18)似乎都很好,但是当我们执行不同的性能和负载测试时,服务停止响应并出现以下错误:
org.apache.tomcat.util.net.NioEndpoint log -
java.lang.NoClassDefFoundError: org/apache/tomcat/util/ExceptionUtils
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:711) ~[tomcat-embed-core-7.0.55.jar!/:7.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736) [tomcat-embed-core-7.0.55.jar!/:7.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695) [tomcat-embed-core-7.0.55.jar!/:7.0.55]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_55]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-7.0.55.jar!/:7.0.55]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_55]
Run Code Online (Sandbox Code Playgroud)
测试涵盖了此工作流程:
该服务没有完全崩溃,它仍然可以通过JMX访问,但不响应HTTP - 请求.
我正在寻找一个理由,但没有运气.
更新:
我为堆,堆栈调整和永久生成大小添加了JAVA_OPTS,现在服务稳定并且性能更好.
-Xmx768m -Xms512m -Xss4m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m -XX:PermSize=128m
Run Code Online (Sandbox Code Playgroud)
那很好,但为什么呢?
更新:
没有任何帮助,错误仍然存在,Sprint Boot 1.2.0也是如此
我的代码如下:
URL url = new URL("1.0.0.25/otfg/services");
HttpURLConnection cnx = url.openConnection();
cnx.setRequestProperty("Host", "example.org");
Run Code Online (Sandbox Code Playgroud)
但是当我使用tcpdump记录传出包时,http-header"Host"是1.0.0.25.
可能是在发送过程的后期阶段覆盖了http-header"Host",如果是,我该如何避免这种行为.