当前位置: 首页 > 知识库问答 >
问题:

嵌入Neo4J的Jersey web应用程序在Tomcat服务器上不能正确关闭

魏高邈
2023-03-14

初步说明:我在SO上查找了类似的问题,其中一个与我最相似的问题是:无法关闭Tomcat内的neo4j jetty服务器。我试过那里提出的所有解决办法,但都没有成功。

我在Tomcat上运行嵌入Neo4j数据库的Jersey应用程序时遇到了关机问题。部署(使用Maven 3.3.9)工作正常,数据库也启动了,但是在重新部署/取消部署时,我会得到一个Tomcat警告:


    21-Feb-2017 17:37:10.242 WARNING [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [mytest] appears to have started a thread named [pool-17-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
     sun.misc.Unsafe.park(Native Method)
     java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
     java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
     java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362)
     java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:941)
     java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
     java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
     java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     java.lang.Thread.run(Thread.java:745)
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@2c930a78]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@4c0b4554]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@1c3e6e38]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@3f71b23c]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@b05bf60]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@1d326ab1]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@72929881]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@40c024bd]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@66987d7a]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@68f1f4fa]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@e413ff5]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@4f65074c]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@6ab3d077]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@d02bfff]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.242 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@a3b973d]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@6d03be51]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@1947fbee]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@1a2527e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@5776bf08]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@27776281]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@149750a]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@12ebf6ff]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@70078555]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@6cf882be]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@26d35b0e]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@6bc20d25]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@27a30025]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@f669b1d]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@33d1bad4]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@480122ae]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@779cb1a3]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@4c19623e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@72206673]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@33f53ecb]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@21f680bf]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@26f91e2d]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@571bf77f]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@4d828831]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@58e40a46]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@36026f01]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.243 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@3eaac6b1]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@67300255]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@1f7e82cf]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@3a218c46]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@52d64afd]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@3513d858]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@5e104ccf]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@68e5b8f7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@80486b4]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@237e5ef4]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@7fd41860]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@3a33256d]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@16ae35b9]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@47f65066]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@18be57e0]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@3b0501d7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.io.pagecache.impl.muninn.CursorPool] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool@5ce1e8f3]) and a value of type [org.neo4j.io.pagecache.impl.muninn.CursorPool.CursorSets] (value [org.neo4j.io.pagecache.impl.muninn.CursorPool$CursorSets@2961f669]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.244 SEVERE [http-nio-8080-exec-6] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mytest] created a ThreadLocal with key of type [org.neo4j.collection.pool.MarshlandPool$1] (value [org.neo4j.collection.pool.MarshlandPool$1@438ab5f2]) and a value of type [org.neo4j.collection.pool.MarshlandPool.LocalSlot] (value [org.neo4j.collection.pool.MarshlandPool$LocalSlot@50120fed]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    21-Feb-2017 17:37:10.762 INFO [http-nio-8080-exec-6] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/mytest]


    package org.mytest;

    import javax.ws.rs.core.Application;
    import javax.annotation.PostConstruct;
    import javax.annotation.PreDestroy;
    import java.util.HashSet;
    import java.util.Set;

    import java.io.File;

    import org.neo4j.graphdb.GraphDatabaseService;
    import org.neo4j.graphdb.factory.GraphDatabaseFactory;
    import org.neo4j.shell.shellSettings;

    /**
     * Created by marijn on 16-2-17.
     */
    public class TestApplication extends Application {

        File db_location = new File("/data/tagaid/neo4jdb");
        GraphDatabaseService db;

        public Set> getClasses() {
            Set> s = new HashSet>();
            s.add(HelloWorldService.class);
            return s;
        }


        @PostConstruct
        public void initialize() {
            try {
                db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(db_location)
                        .setConfig(shellSettings.remote_shell_enabled, "true")
                        .setConfig(shellSettings.remote_shell_port, 5555)
                        .newGraphDatabase();
                System.out.println("Neo4j startup succeeded"); // logged in tomcat catalina.out
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Neo4j startup failed"); // logged in tomcat catalina.out
            }
        }

        @PreDestroy
        public void cleanUp() {
            try {
                db.shutdown();
                System.out.println("Neo4j shutdown succeeded"); // logged in tomcat catalina.out
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Neo4j shutdown failed!"); // logged in tomcat catalina.out
            }
            db = null; // should not be necessary
        }
    }

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>
    <servlet>
        <servlet-name>jersey-servlet</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.marijn.jerseytest</param-value>
        </init-param>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>org.mytest.TestApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey-servlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mytest</groupId>
    <artifactId>org.mytest</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>org.mytest Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>se.jiderhamn</groupId>
            <artifactId>classloader-leak-prevention</artifactId>
            <scope>runtime</scope>
            <version>1.15.4</version>
            <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
          <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.22.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.22.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
            <artifactId>jersey-test-framework-provider-jdk-http</artifactId>
            <version>2.22.1</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-io</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-kernel</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-shell</artifactId>
            <version>3.1.1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>org.mytest</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>UnixTomcatServer</server>
                    <path>/mytest</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

设置:

  • Java版本:1.8.0_121
  • Maven版本:3.3.9

在原始应用程序中使用:

  • Tomcat版本6、8和9
  • Neo4J版本2.2.3、2.2.5和3.1
  • 泽西版本1.19和2.22.1

在这里报道的简单app中:

  • Tomcat 8和9
  • NEO4J 3.1
  • 泽西2.22.1

更新2017-03-02我已经更新到Tomcat9,并将远程shell连接添加到上面的应用程序代码中。在我所做的GitHub repo中,我添加了@jerome-b建议的一个简单的单元测试,以显示远程shell端口在关机时不会被释放。

共有1个答案

轩辕鸿
2023-03-14

我向Neo4J(#8929)提交了一个问题。这是一个bug(端口保持绑定直到JVM终止),在问题#8949中提出了一个修复方案。

 类似资料:
  • 我正在尝试将Spring Boot应用程序作为WAR部署到tomcat服务器。我可以很好地构建war并将其部署到tomcat服务器。但是,当我启动服务器时,我的spring应用程序从未运行。服务器启动得很好。Spring要我做的我都做了, http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-creat

  • 我试图构建一个ReactJS应用程序,我希望在tomcat服务器上托管它。我已经使用命令npm run build,构建已经就绪…我在tomcat服务器中的哪里复制这些文件?我是否需要创建另一个应用程序并将其部署到调用React应用程序的服务器上?

  • 目前,我正在开发一个利用Neo4J的webapp。我们的应用程序需要部署在Tomcat环境中(客户需求)。我们决定嵌入Neo4j,因为这样我们可以使用Neo4j提供的Java API,部署起来更容易,性能也更好。但是,我们还需要访问REST API,因为我们有一个用Angular编写的单页webapp,目前正在使用这个接口。但是,嵌入式Neo4j数据库并不公开REST API。Neo4j-serv

  • 我对w.r.t从Neo4J Embedded迁移到Neo4J服务器有一些疑问,如果您能提供这些问题的澄清,我将不胜感激。 出身背景 我们的一个应用程序(事件管理平台)一直在嵌入式模式下使用Neo4J(1.8.x),SDN(2.x)与Neo4J 1.8兼容。x,从而利用SDN提供的基础设施(NodeEntity、RelationshipEntity等)。 CUD操作通过Neo4JTemplate路由

  • 我在同一个jvm中运行Netty客户端和服务器并试图停止服务器时遇到问题。以下是我的代码来举例说明: 我已经用Netty 3.4.0测试过了。最终和3.4.4。最后,我不知道我做错了什么。 为什么在服务器关闭后,客户端仍然可以向服务器发送数据?

  • neo4j数据库应在哪种模式下使用嵌入式或rest服务器? 我主要关注的是: > 性能 水平扩展(HA,集群)-因为应用程序非常大,所以非常重要。 事务支持(在SDN、Grails插件、结构等框架中) 部署服务器支持,如amazon、GrapheneDB等。 易于从一个切换到另一个 缩放(数据库大小)