0

Я где-то в IDEA разорвал связь html-страницы c главным запускающим классом, теперь выводится только HTML страничка без контролов и прочей логики.

Подскажите куда смотреть плз?

Main.gwt.xml

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"
        "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
<module>

    <inherits name='com.google.gwt.user.User'/>

    <entry-point class='ru.javastudy.gwtPersistence.client.Main'/>

    <!-- Inherit the UiBinder module.                               -->
    <inherits name="com.google.gwt.uibinder.UiBinder"/>

    <!-- Specify the paths for translatable code -->

    <source path='client' />
    <source path='shared' />

    <!-- Specify the app servlets.                   -->
    <servlet path='/MainRpcService' class='ru.javastudy.gwtPersistence.server.MainRpcServiceImpl'/>

</module>

Main.html

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Main Application</title>

    <link type="text/css" rel="stylesheet" href="Main.css">
    <script type="text/javascript" language="javascript" src="ru.javastudy.gwtPersistence.Main.nocache.js"></script>

</head>
<body>
...
</body>

pom.xml

<?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>ru.javastudy</groupId>
    <artifactId>gwtPersistence</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>

    <properties>
        <gwtVersion>2.6.0</gwtVersion>
        <hibernate-version>5.1.0.Final</hibernate-version>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- ensure all GWT deps use the same version (unless overridden) -->
            <dependency>
                <groupId>com.google.gwt</groupId>
                <artifactId>gwt</artifactId>
                <version>${gwtVersion}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt</artifactId>
            <version>${gwtVersion}</version>
            <scope>compile</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-codeserver</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>

        <!-- javax -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>

        <!-- PostgreSQL -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1205-jdbc42</version>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.0.6.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-orm</artifactId>
            <version>5.5.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-infinispan</artifactId>
            <version>5.5.3.Final</version>
        </dependency>

    </dependencies>

    <build>

        <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>ru.javastudy.gwtPersistence.client.Main</mainClass>
                            <packageName>ru.javastudy.gwtPersistence.client</packageName>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>compile</includeScope>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.6.0</version>
                <configuration>
                    <port>8080</port>
                    <hostedWebapp>war</hostedWebapp>
                </configuration>
            </plugin>

        </plugins>

    </build>

</project>

Хочу сказать, что у меня разрывается связь html-страницы c gwt-приложением, сразу же после того, как я переношу Main.html и Main.css из папки public модуля в папку webapp. Если этого не сделать, то после компоновки war-ника, томкат не может найти Main.html

Да собственно и хотелось бы знать, что нужно сделать, чтобы после переноса Main.html и Main.css в блок webapp связь не рвалась?

2 ответа 2

2

Приветствую.

Наконец то нашел решение своего вопроса. Как оказалось, не смотря на всю структурную схожесть с тем что должно быть, мое gwt-приложение было изначально то ли с ошибкой, то ли неверно сконфигурировано.

Буквально "на коленках" создал пустой Maven-проект, добавил поддержку GWT с параллельным созданием простейшего приложения, чтобы правильно выстроилась структура (client, server, public, shared).

Теперь, html-страница и соседствующий css-файл преспокойно переносятся в src\main\webapp.

Нормально компилируется как GWT так и TomCat приложение. Что это было? Я не знаю. В качестве предположения допускаю, что где-то неправильно прописался конфиг в дебрях IntellijIDEA.

Но факт остается фактом: два рядом лежащие приложения как две капли воды похожие друг на друга, идентичные в структурном плане - но одно запускается, второе нет. War-ник получился со всеми необходимыми библиотеками на 30MB.

0

В файле имя_модуля.gwt.xml есть строка

<entry-point class='полный.путь.к.классу'/>

Также в твоей html'ке должно быть вытягивание сгенерированного скрипта примерно так

<script type="text/javascript" language="javascript"
            src="полное_имя_модуля/имя_точки_входа.nocache.js"></script>
2
  • Вроде бы всё верно указал. И всё равно, сразу HTML-страница, даже сообщение о компиляции модуля не видно в серой рамочке ((
    – Vard32
    7 июн 2016 в 15:48
  • @vard32 приложи содержимое этих файлов и файла pom.xml 8 июн 2016 в 10:50

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.