【问题标题】:XPCOM error in maven SWT project on windows 10 64 bitWindows 10 64 位 maven SWT 项目中的 XPCOM 错误
【发布时间】:2017-10-08 23:18:39
【问题描述】:

我正在尝试以 MOZILLA 作为默认渲染器运行 SWT 浏览器的最简单示例。并收到此错误

--- exec-maven-plugin:1.2.1:exec (default-cli) @ SwtBrowser ---
Exception in thread "main" org.eclipse.swt.SWTError: XPCOM error 0x80004005
    at org.eclipse.swt.browser.Mozilla.error(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.initXULRunner(Unknown Source)
    at org.eclipse.swt.browser.Mozilla.create(Unknown Source)
    at org.eclipse.swt.browser.Browser.<init>(Unknown Source)
    at dev.nazm.swt.Mozilla.main(Mozilla.java:57)
------------------------------------------------------------------------

我搜索了这个问题并得到了这些答案,但这些都没有任何帮助

  1. Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3

  2. How to make SWT Browser control use mozilla instead of IE on Windows

  3. Cannot run due to XPCOM error 0x80004005 #48

  4. The SWT FAQ

还有一些关于 Eclipse 支持的其他链接。但是没有任何帮助

这是我的pom.xml

    <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>dev.nazm</groupId>
    <artifactId>SwtBrowser</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <name>SwtBrowser</name>
    <url>http://maven.apache.org</url>

    <repositories>
        <repository>
            <id>maven-eclipse-repo</id>
            <url>http://maven-eclipse.github.io/maven</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${swtGroup}</groupId>
            <artifactId>${swtArtifact}</artifactId>
            <version>${swtVersion}</version>
        </dependency>

        <dependency>
            <groupId>naz.dev</groupId>
            <artifactId>javafx.embed.swt</artifactId>
            <version>8.0.0-Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.0</version>
        </dependency> 

        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt-main</artifactId>
            <version>2.3.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jogamp.jogl/jogl-all-main -->
        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version>6.0.0</version>
            <type>jar</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.eclipse.core/org.eclipse.core.runtime -->
        <dependency>
            <groupId>org.eclipse.core</groupId>
            <artifactId>org.eclipse.core.runtime</artifactId>
            <version>3.7.0</version>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <name>Mac OS X</name>
                    <arch>x86_64</arch>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.6.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-XstartOnFirstThread</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>dev.nazm.browser.SwtBrowser</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.cocoa.macosx.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>                
            </properties>
        </profile>

        <profile>
            <id>windows10_64</id>
            <activation>
                <os>
                    <name>windows 10</name>
                    <family>Windows</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86_64</swtArtifact>
                <swtVersion>4.4</swtVersion>
            </properties>
        </profile>

        <profile>
            <id>windows32</id>
            <activation>
                <os>
                    <family>Windows</family>
                    <arch>x86</arch>
                </os>
            </activation>
            <properties>
                <swtGroup>org.eclipse.swt</swtGroup>
                <swtArtifact>org.eclipse.swt.win32.win32.x86</swtArtifact>
                <swtVersion>4.4</swtVersion>
                <!--<classifier>debug</classifier>-->
            </properties>
        </profile>       
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>dev.nazm.browser.SwtBrowser</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

我已经下载了 xulrunner 24.0 并将其解压缩到 C:\Program Files\xulrunner24 。

这是我的主要课程

public class SwtBrowser {
    public static void main(String[] args) {
        String path = "C:\\Program Files\\xulrunner24";
        System.getProperties().setProperty("org.eclipse.swt.browser.XULRunnerPath",path);
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        Browser browser = new Browser(shell, SWT.MOZILLA);
        browser.setUrl("https://chromium.github.io/octane/");
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
}

这是我的java版本

java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)`

我正在 Windows 10 amd64 环境中尝试此操作。 我已经在我的电脑上安装了 Mozilla FirefoxESR 24.0。 我也安装了 VisualC++ Redistributable

现在我的问题是?

  1. 我的电脑上安装的 Firefox 版本是否需要满足 xulrunner 的版本。
  2. 正如 SWT FAQ 所说的 Windows (x86_64) 的要求:

    具有 1.9.2.x - 3.6.x、10.x 或 24.x 版本的任何 XULRunner 版本,以及 必须安装 Visual C++ 2010 运行时

    操作系统架构对 xulrunner 重要吗?

  3. 我已经安装了 eclipse neon 3,并尝试创建一个项目并在 .ini 文件中添加运行时参数。但仍然遇到同样的问题。所以最后一个问题是如何在 Windows 64 位平台上的 maven 项目中运行它。

【问题讨论】:

    标签: java maven swt xulrunner


    【解决方案1】:

    使用 64 位 4.3 SWT(和 4.4 - 我只测试了这两个)我能够使用 XULRunner 版本 1.9.2.25 运行时运行您的代码。

    由于 64 位 JVM(在我的情况下为 1.8.0_131),我还必须更新您的 pom.xml 以提取 64 位 SWT(org.eclipse.swt.win32.win32.x86_64 而不是 org.eclipse.swt.win32.win32.x86)。

    最初我从这里找到了 xulrunner 下载:https://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/

    但是,我还在我的存储库中将其重新托管为 xulrunner-1.9.2.25.en-US.win64.zip

    关于在 Maven 项目中执行此操作,我不确定。您可以简单地将它与您的应用程序一起打包到lib 目录中。如果将 xulrunner 运行时打包并放入 Maven 存储库会有所帮助,我也可以托管它(您可以自己托管在您拥有的存储库上)。

    如果这不起作用,请告诉我,我很乐意再看看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 2018-01-29
      • 2013-01-05
      • 1970-01-01
      • 2016-09-18
      • 2018-11-23
      • 1970-01-01
      相关资源
      最近更新 更多