Tag - java

jenkins docker tomcat java restful shell    2017-07-19 21:50:48    8

前提:jenkins是装在CentOS6.7中,同时,我的这台linux上面安装有docker


一、项目代码:

项目主要是jersey 1.x 版本的maven项目,重点在与我在项目中放置了tomcat,以及使用maven对tomcat进行解压,并将项目打包的文件放置到项目中,那么项目信息就不多写了,把maven配置信息重点写出来吧:

    <build>
        <finalName>testjersey</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>copy-package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>

                                <unzip dest="target/apache/">
                                    <fileset dir="${basedir}">
                                        <include name="apache-tomcat-7.0.68.zip" />
                               
java mongodb exception    2017-07-19 21:43:42    3
分析:
    参考地址:https://github.com/brianfrankcooper/YCSB/issues/277
    应该是官方的update策略有变化,3.0以前,使用updateOne,3.0以后使用replaceOne
解决办法:
    将updateOne替换为replaceOne即可

完整错误栈:

java.lang.IllegalArgumentException: Invalid BSON field name _id
    at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[bson-3.2.2.jar:na]
    at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[bson-3.2.2.jar:na]
    at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) ~[mongodb-driver-core-3.2.2.jar:na]
    at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(Upd
jersey java 拦截器 微服务 MicroService    2017-07-19 21:37:32    11
1、web.xml配置
    <servlet>
        <servlet-name>Rest_Servlet</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>cn.firewarm.testRestShiro.rest</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
            <param-value>cn.firewarm.testRestShiro.filter.TestFilter</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

2、TestFilter代码
public class TestFilter implements ContainerRequestFilter {
    public ContainerRequest filter(ContainerRequest request) {
        if(判断条件){
            return request;
        }else{
            Response response = Response.ok("error").status(401).type(MediaType.APPLICATION_JSON).build();  
            throw new WebApplicationException(response); // Throw new UnAuthor
java eclipse VM arguments    2017-07-19 21:27:01    247
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2209)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun
java xwiki restful    2017-07-19 21:22:41    9

xwiki测试流程

  1. 测试页面
  1. public void normalTest()throws Exception, IOException{
  2. CloseableHttpClient httpclient = HttpClients.createDefault();
  3. JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
  4. Unmarshaller unmarshaller = context.createUnmarshaller();
  5. HttpUriRequest httpPost = RequestBuilder.get()
  6. .setUri(new URI("http://172.16.200.220:8082/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome"))
  7. .setHeader("Accept", "application/xml").build();
  8. CloseableHttpResponse response = httpclient.execute(httpPost);
  9. System.out.println(response.getEntity());
  10. HttpEntity responseEntity=response.getEntity();
  11. Page page = (Page) unmarshaller.unmarshal(responseEntity.getContent());
  12. System.out.println(new Gson().toJson(page));
  13. }
  1. 登录并获取session
  1. public void testLogin() throws Exception{
  2. CloseableHttpClient httpclient =
4/7