简体   繁体   中英

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

  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

And some other links on eclipse support. But nothing helped me

This is my 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 .

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 -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. I have installed Mozilla FirefoxESR 24.0 on my computer. I have installed VisualC++ Redistributable also

Now my questions are ?

  1. Does Firefox version installed on my PC needs to meet version of xulrunner.
  2. As SWT FAQ says requirements of 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

    Does OS architecture matters for xulrunner?

  3. I have installed eclipse neon 3, and tried creating a project and adding runtime arguments in .ini file. But still got the same issue. So final question is how to run it in a maven project on a Windows 64 bit platform.

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.

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

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/

However, I have also re-hosted it as xulrunner-1.9.2.25.en-US.win64.zip in my repository.

In regards to doing this in a Maven project, I'm not sure. You could simply package it with your application in a lib directory. 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).

Let me know if this doesn't work and I'll be happy to take another look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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