简体   繁体   English

Windows 10 64位上的Maven SWT项目中的XPCOM错误

[英]XPCOM error in maven SWT project on windows 10 64 bit

I am trying to run simplest example of SWT browser with MOZILLA as default renderer. 我正在尝试使用MOZILLA作为默认渲染器运行SWT浏览器的最简单示例。 and getting this error 并得到这个错误

--- 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)
------------------------------------------------------------------------

I googled this problem and got these answers, but none of these are any help 我用谷歌搜索了这个问题并得到了这些答案,但是这些都无济于事

  1. Creating a SWT.MOZILLA browser on Windows 64 bit and SWT 4.3 在Windows 64位和SWT 4.3上创建SWT.MOZILLA浏览器

  2. How to make SWT Browser control use mozilla instead of IE on Windows 如何使SWT浏览器控件在Windows上使用Mozilla而不是IE

  3. Cannot run due to XPCOM error 0x80004005 #48 由于XPCOM错误0x80004005#48无法运行

  4. The SWT FAQ SWT常见问题

And some other links on eclipse support. 以及其他有关eclipse支持的链接。 But nothing helped me 但是没有任何帮助

This is my pom.xml 这是我的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>

I have downloaded xulrunner 24.0 and extracted it to C:\\Program Files\\xulrunner24 . 我已经下载了xulrunner 24.0并将其解压缩到C:\\ Program Files \\ xulrunner24。

This is my main class 这是我的主班

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();
    }
}

This is my java version 这是我的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)`

I am trying this on Windows 10 amd64 environment. 我正在Windows 10 amd64环境中尝试此操作。 I have installed Mozilla FirefoxESR 24.0 on my computer. 我已经在计算机上安装了Mozilla FirefoxESR 24.0。 I have installed VisualC++ Redistributable also 我还安装了VisualC ++ Redistributable

Now my questions are ? 现在我的问题是?

  1. Does Firefox version installed on my PC needs to meet version of xulrunner. 我的PC上安装的Firefox版本是否需要符合xulrunner的版本。
  2. As SWT FAQ says requirements of Windows (x86_64): 正如SWT常见问题解答所说的Windows(x86_64)要求:

    Any XULRunner release with version 1.9.2.x - 3.6.x, 10.x or 24.x, and the Visual C++ 2010 runtime must be installed 必须安装任何具有版本1.9.2.x-3.6.x,10.x或24.x的XULRunner,以及Visual C ++ 2010运行时

    Does OS architecture matters for xulrunner? OS架构对xulrunner有影响吗?

  3. I have installed eclipse neon 3, and tried creating a project and adding runtime arguments in .ini file. 我已经安装了eclipse neon 3,并尝试创建一个项目并在.ini文件中添加运行时参数。 But still got the same issue. 但是仍然有同样的问题。 So final question is how to run it in a maven project on a Windows 64 bit platform. 因此,最后一个问题是如何在Windows 64位平台上的Maven项目中运行它。

With 64-bit 4.3 SWT (and 4.4 - I've only tested those two) I was able to run your code by using XULRunner version 1.9.2.25 runtime. 使用64位4.3 SWT(和4.4(我仅测试了这两个)),我可以使用XULRunner 1.9.2.25版运行时来运行您的代码。

I also had to update your pom.xml to pull 64-bit SWT ( org.eclipse.swt.win32.win32.x86_64 instead of org.eclipse.swt.win32.win32.x86 ) because of the 64-bit JVM (1.8.0_131 in my case). 由于64位JVM(1.8),我还必须更新pom.xml以提取64位SWT( org.eclipse.swt.win32.win32.x86_64而不是org.eclipse.swt.win32.win32.x86 ) .0_131)。

Originally I found the xulrunner download from here: https://osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/ 最初,我从这里找到xulrunner下载: https : //osdn.net/projects/sfnet_runawfe/downloads/SRC%20and%20BIN%20files/extras/xulrunner-1.9.2.25-win64.zip/

However, I have also re-hosted it as xulrunner-1.9.2.25.en-US.win64.zip in my repository. 但是,我还在我的存储库中将其重新托管为xulrunner-1.9.2.25.en-US.win64.zip

In regards to doing this in a Maven project, I'm not sure. 关于在Maven项目中执行此操作,我不确定。 You could simply package it with your application in a lib directory. 您可以将其与您的应用程序一起打包在一个lib目录中。 If it would help to have the xulrunner runtime packaged and put in a Maven repository I can host it that was as well (our you can host it yourself on a repo that you own). 如果将xulrunner运行时打包并放入Maven存储库中有帮助,我也可以托管它(我们可以将其托管在您拥有的存储库中)。

Let me know if this doesn't work and I'll be happy to take another look. 让我知道这是否无效,我很乐意再看一遍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM