Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Java error #1076

Closed
gorstj opened this issue Apr 18, 2019 · 10 comments · Fixed by #1085
Closed

New Java error #1076

gorstj opened this issue Apr 18, 2019 · 10 comments · Fixed by #1085
Assignees
Milestone

Comments

@gorstj
Copy link

gorstj commented Apr 18, 2019

My HA-Bridge has stopped working today.
Running on ubuntu 18.04.02
I ahve not changed, rebooted or updated anything for a long time.

I understand that there was an issue with Java 9..... I am on Java 11.0.02.... I am not sure when this got updated..... however I think javax.xml.bind was removed from Java at version 11???

Any thoughts?
Thanks

Error is:
john@Kit:~$ sudo service ha-bridge status
● ha-bridge.service - HA Bridge
Loaded: loaded (/etc/systemd/system/ha-bridge.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-04-18 20:36:12 BST; 5min ago
Process: 26858 ExecStart=/usr/bin/java -jar -Dconfig.file=/home/john/ha-bridge/data/habridge.config --add-modules java.xml.bind /ho
Main PID: 26858 (code=exited, status=1/FAILURE)

Apr 18 20:36:11 Kit systemd[1]: Started HA Bridge.
Apr 18 20:36:12 Kit java[26858]: Error occurred during initialization of boot layer
Apr 18 20:36:12 Kit java[26858]: java.lang.module.FindException: Module java.xml.bind not found
Apr 18 20:36:12 Kit systemd[1]: ha-bridge.service: Main process exited, code=exited, status=1/FAILURE
Apr 18 20:36:12 Kit systemd[1]: ha-bridge.service: Failed with result 'exit-code'.

@Twit123
Copy link

Twit123 commented Apr 19, 2019

Hi,

I just removed the reference to javax.xml.bind in my start up file.

It was:
ExecStart=/usr/bin/java -jar --add-modules java.xml.bind -Dsecurity.key=?????????????????? -Dconfig.file=/opt/habridge/data/habridge.config /opt/habridge/ha-bridge-5.2.2RC2.jar

Now:
ExecStart=/usr/bin/java -jar -Dsecurity.key=????????????????? -Dconfig.file=/opt/habridge/data/habridge.config /opt/habridge/ha-bridge-5.2.2RC2.jar

HA-Bridge now starts, I haven't run it for long enough to see if there will we any other issues,

Simon

@gorstj
Copy link
Author

gorstj commented Apr 19, 2019

Doing the above leads to ha-bridge service starting, the web interface is reachable however none of the 'test on' or 'test off' switches work.

Lots of these in the log:

04-19-2019 09:58:12.631 ERROR   spark.http.matching.GeneralError

It would seem java.xml.bind is necessary for ha-bridge...... it has been removed in java 11 I think?

@Twit123
Copy link

Twit123 commented Apr 19, 2019

You are correct, some of my items work like Home Assistant calls but calls to my RM Pro error out.

I'm think bwssystems will have to compile a new jar file and explicitly add the module as it has been removed in Java 11.

Si

@Twit123
Copy link

Twit123 commented Apr 19, 2019

I compiled a new jar file with this added to the pom.xml

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>

I also have to up the mavin.shade.plugin to 3.2.1 as it would not compile

				<artifactId>maven-shade-plugin</artifactId>
				<version>3.2.1</version>

I've only just done it but all my test on / test off buttons seem to trigger correctly, I'll test over the weekend and report.

Si

@gorstj
Copy link
Author

gorstj commented Apr 19, 2019

If it is working well would you mind sharing the binary or sharing the exact changes you made to the source so I can try to compile myself?

Thanks

@Twit123
Copy link

Twit123 commented Apr 19, 2019

Hi,

I basically have no idea what I'm doing, I Googled how to compile with Maven which involved installing Maven and Jave SDK. I then changed the pom.xml to the below and compiled:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.bwssystems.HABridge</groupId>
	<artifactId>ha-bridge</artifactId>
	<version>5.2.2</version>
	<packaging>jar</packaging>

	<name>HA Bridge</name>
	<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA systems, i.e. Vera or Harmony Hub or Nest, using lightweight frameworks</description>

	<properties>
		<java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<repositories>
		<repository>
	    	<id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	    <repository>
	        <id>Eclipse Paho Repo</id>
	        <url>https://repo.eclipse.org/content/repositories/paho-releases/</url>
	    </repository>
	</repositories>

	<dependencies>
		<dependency>
		    <groupId>com.github.bwssytems</groupId>
		    <artifactId>harmony-java-client</artifactId>
		    <version>master-SNAPSHOT</version>
		    <exclusions>
		       <exclusion> 
		          <groupId>org.slf4j</groupId>
		          <artifactId>slf4j-simple</artifactId>
		       </exclusion>
		       <exclusion> 
		            <groupId>org.slf4j</groupId>
		            <artifactId>log4j-over-slf4j</artifactId>
		       </exclusion>
		    </exclusions> 
		</dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.github.bwssytems</groupId>
            <artifactId>nest-controller</artifactId>
            <version>1.0.14</version>
		    <exclusions>
		       <exclusion> 
		          <groupId>org.slf4j</groupId>
		          <artifactId>slf4j-simple</artifactId>
		       </exclusion>
		       <exclusion> 
		            <groupId>org.slf4j</groupId>
		            <artifactId>log4j-over-slf4j</artifactId>
		       </exclusion>
		    </exclusions> 
        </dependency>
		<dependency>
		    <groupId>com.sparkjava</groupId>
		    <artifactId>spark-core</artifactId>
		    <version>2.7.1</version>
		    <exclusions>
		    	<exclusion>
		    		<artifactId>slf4j-simple</artifactId>
		    		<groupId>org.slf4j</groupId>
		    	</exclusion>
		    </exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.5.1</version>
		</dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.24</version>
        </dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>1.2.1</version>
		</dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.6.2</version>
        </dependency>
		<dependency>
		  <groupId>net.java.dev.eval</groupId>
		  <artifactId>eval</artifactId>
		  <version>0.5</version>
		</dependency>
		<dependency>
			<groupId>com.google.inject</groupId>
			<artifactId>guice</artifactId>
			<version>4.1.0</version>
		</dependency>
		<dependency>
		  <groupId>org.igniterealtime.smack</groupId>
		  <artifactId>smack-core</artifactId>
		  <version>4.2.0</version>
		</dependency>
	    <dependency>
	        <groupId>org.eclipse.paho</groupId>
	        <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
	        <version>1.1.0</version>
	    </dependency>
		<dependency>
		    <groupId>junit</groupId>
		    <artifactId>junit</artifactId>
		    <version>4.12</version>
		</dependency>
		<dependency>
		  <groupId>com.github.bwssytems</groupId>
		  <artifactId>lifx-sdk-java</artifactId>
		  <version>2.1.6</version>
		</dependency>
		<dependency>
		    <groupId>com.github.mob41</groupId>
		    <artifactId>broadlink-java-api</artifactId>
		    <version>master-SNAPSHOT</version>
		</dependency>
		<dependency>
		  <groupId>org.apache.commons</groupId>
		  <artifactId>commons-lang3</artifactId>
		  <version>3.5</version>
		</dependency>
	</dependencies>

	<build>
	    <resources>
	      <resource>
	        <directory>src/main/resources</directory>
	        <includes>
	          <include>version.properties</include>
	        </includes>
	        <filtering>true</filtering>
	      </resource>
	      <resource>
	        <directory>src/main/resources</directory>
	        <excludes>
	          <exclude>version.properties</exclude>
	        </excludes>
	        <filtering>false</filtering>
	      </resource>
	    </resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.2.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<minimizeJar>true</minimizeJar>
							<filters>
								<filter>
									<artifact>*:*</artifact>
									<excludes>
										<exclude>META-INF/*.SF</exclude>
										<exclude>META-INF/*.DSA</exclude>
										<exclude>META-INF/*.RSA</exclude>
										<exclude>META-INF/*.txt</exclude>
										<exclude>META-INF/maven/**</exclude>
										<exclude>about_files/**</exclude>
									</excludes>
								</filter>
								<filter>
									<artifact>*:*</artifact>
								</filter>
								<filter>
									<artifact>org.slf4j:slf4j-api</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
								<filter>
									<artifact>commons-logging:commons-logging</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
								<filter>
									<artifact>xpp3:xpp3</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
								<filter>
									<artifact>org.igniterealtime.smack:*</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
								<filter>
									<artifact>com.github.bwssytems:harmony-java-client</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
								<filter>
									<artifact>org.eclipse.paho:org.eclipse.paho.client.mqttv3</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
							</filters>
							<transformers>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>com.bwssystems.HABridge.HABridge</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

@gorstj
Copy link
Author

gorstj commented Apr 22, 2019

Compiling myself didn't seem to solve the issue - no http requests seem to work

(I did add the dependency as per your instructions)

@gorstj
Copy link
Author

gorstj commented Apr 22, 2019

Ok, here is what I have done

Remove openjdk-11
install openjdk-8

It still wasn't working as a service but worked from the command line.

If I removed the following from my startup file it started working.....

-Dconfig.file=/home/pi/ha-bridge/data/habridge.config

All is good here now! I don't understand..... I may try and go back to openjdk-11 to try....

@bwssytems
Copy link
Owner

For java 9 and later, you need to add a module on the command line. Please see https://github.com/bwssytems/ha-bridge/wiki/HA-Bridge-FAQs#q-ha-bridge-errors-when-running-with-java9

@bwssytems
Copy link
Owner

I'm removing the need for the JAXB libraries since they are only used for a tiny hex conversion.

@bwssytems bwssytems added this to the v5.2.2 milestone Apr 23, 2019
@bwssytems bwssytems self-assigned this Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants