Проблема при развертывании приложения на основе рестлета на tomcat

У меня проблема с развертыванием приложения рестлета на веб-сервере tomcat.

Я могу запустить приложение напрямую из Eclipse, но при развертывании на tomcat у меня возникают следующие проблемы.

    May 10, 2015 10:04:32 AM org.apache.catalina.loader.WebappClassLoader loadClass
    INFO: Illegal access: this web application instance has been stopped already.  Could not load org.simpleframework.transport.connect.Connection.
  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
    java.lang.IllegalStateException
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.getConstructor(Unknown Source)
        at org.restlet.engine.Engine.registerHelper(Engine.java:781)
        at org.restlet.engine.Engine.registerHelpers(Engine.java:813)
        at org.restlet.engine.Engine.registerHelpers(Engine.java:853)
        at org.restlet.engine.Engine.discoverConnectors(Engine.java:544)
        at org.restlet.engine.Engine.<init>(Engine.java:379)
        at org.restlet.engine.Engine.register(Engine.java:301)
        at org.restlet.engine.Engine.register(Engine.java:290)
        at org.restlet.engine.Engine.getInstance(Engine.java:199)
        at org.restlet.data.Method.<init>(Method.java:337)
        at org.restlet.data.Method.<init>(Method.java:396)
        at org.restlet.data.Method.<init>(Method.java:361)
        at org.restlet.data.Method.<clinit>(Method.java:48)
        at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)



            May 10, 2015 10:04:32 AM org.apache.catalina.loader.WebappClassLoader loadClass
        INFO: Illegal access: this web application instance has been stopped already.  Could not load org.simpleframework.transport.connect.Connection.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
        java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
            at java.lang.Class.getConstructor0(Unknown Source)
            at java.lang.Class.getConstructor(Unknown Source)
            at org.restlet.engine.Engine.registerHelper(Engine.java:781)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:813)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:853)
            at org.restlet.engine.Engine.discoverConnectors(Engine.java:544)
            at org.restlet.engine.Engine.<init>(Engine.java:379)
            at org.restlet.engine.Engine.register(Engine.java:301)
            at org.restlet.engine.Engine.register(Engine.java:290)
            at org.restlet.engine.Engine.getInstance(Engine.java:199)
            at org.restlet.data.Method.<init>(Method.java:337)
            at org.restlet.data.Method.<init>(Method.java:396)
            at org.restlet.data.Method.<init>(Method.java:361)
            at org.restlet.data.Method.<clinit>(Method.java:48)
            at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)



        INFO: Illegal access: this web application instance has been stopped already.  Could not load java.net.InetSocketAddress.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
        java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
            at java.lang.Class.getDeclaredConstructors0(Native Method)
            at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
            at java.lang.Class.getConstructor0(Unknown Source)
            at java.lang.Class.getConstructor(Unknown Source)
            at org.restlet.engine.Engine.registerHelper(Engine.java:781)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:813)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:853)
            at org.restlet.engine.Engine.discoverConnectors(Engine.java:544)
            at org.restlet.engine.Engine.<init>(Engine.java:379)
            at org.restlet.engine.Engine.register(Engine.java:301)
            at org.restlet.engine.Engine.register(Engine.java:290)
            at org.restlet.engine.Engine.getInstance(Engine.java:199)
            at org.restlet.data.Method.<init>(Method.java:337)
            at org.restlet.data.Method.<init>(Method.java:396)
            at org.restlet.data.Method.<init>(Method.java:361)
            at org.restlet.data.Method.<clinit>(Method.java:48)
            at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)


        INFO: Illegal access: this web application instance has been stopped already.  Could not load org.restlet.data.Protocol.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
        java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
            at org.restlet.ext.simple.HttpServerHelper.<init>(HttpServerHelper.java:57)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.restlet.engine.Engine.registerHelper(Engine.java:781)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:813)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:853)
            at org.restlet.engine.Engine.discoverConnectors(Engine.java:544)
            at org.restlet.engine.Engine.<init>(Engine.java:379)
            at org.restlet.engine.Engine.register(Engine.java:301)
            at org.restlet.engine.Engine.register(Engine.java:290)
            at org.restlet.engine.Engine.getInstance(Engine.java:199)
            at org.restlet.data.Method.<init>(Method.java:337)
            at org.restlet.data.Method.<init>(Method.java:396)
            at org.restlet.data.Method.<init>(Method.java:361)
            at org.restlet.data.Method.<clinit>(Method.java:48)
            at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)


        INFO: Illegal access: this web application instance has been stopped already.  Could not load java.util.logging.Logger.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
        java.lang.IllegalStateException
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
            at org.restlet.engine.log.LoggerFacade.getLogger(LoggerFacade.java:117)
            at org.restlet.engine.Engine.getLogger(Engine.java:255)
            at org.restlet.Context.getCurrentLogger(Context.java:81)
            at org.restlet.engine.Engine.registerHelper(Engine.java:785)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:813)
            at org.restlet.engine.Engine.registerHelpers(Engine.java:853)
            at org.restlet.engine.Engine.discoverConnectors(Engine.java:544)
            at org.restlet.engine.Engine.<init>(Engine.java:379)
            at org.restlet.engine.Engine.register(Engine.java:301)
            at org.restlet.engine.Engine.register(Engine.java:290)
            at org.restlet.engine.Engine.getInstance(Engine.java:199)
            at org.restlet.data.Method.<init>(Method.java:337)
            at org.restlet.data.Method.<init>(Method.java:396)
            at org.restlet.data.Method.<init>(Method.java:361)
            at org.restlet.data.Method.<clinit>(Method.java:48)
            at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)

Я проверил, и файл simple.jar является частью развернутой войны.

Может кто-нибудь подсказать, что это за незаконный доступ и как я могу его решить.

Благодарю.

1 ответ

Решение

Я предполагаю, что вы смешали автономный и встроенный подход Restlet:

  • При автономном подходе вам нужен серверный соединитель, такой как Simple framework или Jetty, и Restlet отвечает за их управление (запуск, остановка)
  • Благодаря встроенному подходу Restlet больше не нужно управлять этим. Вы запускаете свой механизм сервлетов, и запросы будут переданы в Restlet через его сервлет-адаптер.

Делаете ли вы попытку в Eclipse, используя автономный или встроенный подход (например, с WTP)?

Вот файл Maven, который позволяет вам создать встроенный проект:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.restlet</groupId>
    <artifactId>restlet-war</artifactId>
    <name>${project.artifactId}</name>
    <packaging>war</packaging>
    <version>1.0.0-snapshot</version>

    <properties>
        <java-version>1.7</java-version>
        <restlet-version>2.3.1</restlet-version>
        <wtp-version>2.0</wtp-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.restlet.jee</groupId>
            <artifactId>org.restlet</artifactId>
            <version>${restlet-version}</version>
        </dependency>

        <dependency>
            <groupId>org.restlet.jee</groupId>
            <artifactId>org.restlet.ext.servlet</artifactId>
            <version>${restlet-version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>maven-restlet</id>
            <name>Public online Restlet repository</name>
            <url>http://maven.restlet.com</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>sources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <wtpapplicationxml>true</wtpapplicationxml>
                    <wtpversion>${wtp-version}</wtpversion>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Инициализация проекта для Eclipse может быть выполнена с помощью команды mvn eclipse:eclipse,

Вы можете найти полный простой проект по этому адресу: https://github.com/templth/restlet-stackru/tree/master/restlet/test-restlet-servlet.

Надеюсь, это поможет тебе, Тьерри

Другие вопросы по тегам