Weasis icon indicating copy to clipboard operation
Weasis copied to clipboard

Error building on FreeBSD

Open leonardorame opened this issue 3 years ago • 19 comments

Hi, I'm trying to build Weasis v3.7.0 on FreeBSD by following this https://nroduit.github.io/en/getting-started/building-weasis/

The "Building all plugins" steps runs without issues, but on "Building Weasis Distributions" fails.

cd weasis-distributions
mvn clean package -Dportable=true -P compressXZ

After a while I get this:

...
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-descriptor/2.2.1/maven-plugin-descriptor-2.2.1.jar (39 kB at 22 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar (228 kB at 115 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8.2/ant-1.8.2.jar (1.9 MB at 634 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:28 min
[INFO] Finished at: 2021-02-12T08:27:06-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.akathist.maven.plugins.launch4j:launch4j-maven-plugin:1.7.23:launch4j (l4j-clui) on project weasis-distributions: Sorry, Launch4j doesn't support the 'FreeBSD' OS. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Can someone help me fix this?

leonardorame avatar Feb 12 '21 11:02 leonardorame

If I run mvn clean package -Dportable=false -P compressXZ it builds without issues.

To run it I had to go to target/portable-dist and change a line in viewer-linux.sh. Just modify the 1nst line from #!/bin/bash to #!/usr/local/bin/bash.

Now I'll try to figure out how to create a protocol handler in this platform.

leonardorame avatar Feb 12 '21 12:02 leonardorame

I found a way to make the protocol handler work at least in Firefox (I'm running XFCE as Desktop Environment, I don't know if this works on others):

Create the file weasis.desktop in cd ~/.local/share/applications:

[Desktop Entry]
Name=weasis
Exec=/home/leonardo/Weasis/weasis-distributions/target/portable-dist/viewer-linux.sh %u
Type=Application
Terminal=false
MimeType=x-scheme-handler/weasis;

Add the line x-scheme-handler/weasis=weasis.desktop to /home/leonardo/.config/mimeapps.list.

Finally run update-desktop-database ~/.local/share/applications.

That's it.

leonardorame avatar Feb 12 '21 12:02 leonardorame

It runs, but I'm getting this error when trying to open jpeg lossless images.

image

leonardorame avatar Feb 12 '21 12:02 leonardorame

Mmm, in ~/.weasis/log/boot-0.0.log I found this:

***** End of Configuration *****
12.02.2021 09:21:14.626 *INFO* [main] org.weasis.launcher.WeasisLauncher: 
Starting OSGI Bundles...

         | | /| / /__ ___ ____ (_)__
         | |/ |/ / -_) _ `(_-</ (_-<
         |__/|__/\__/\_,_/___/_/___/

12.02.2021 09:21:14.760 *SEVERE* [main] org.weasis.launcher.FileUtil: Cannot install xz compressed bundle file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/bundle/weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar.xz
java.io.FileNotFoundException: /usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/bundle/weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar.xz (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
	at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
	at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
	at org.weasis.launcher.AutoProcessor.installBundle(AutoProcessor.java:543)
	at org.weasis.launcher.AutoProcessor.processAutoProperties(AutoProcessor.java:354)
	at org.weasis.launcher.AutoProcessor.process(AutoProcessor.java:82)
	at org.weasis.launcher.WeasisLoader.setFelix(WeasisLoader.java:256)
	at org.weasis.launcher.WeasisLauncher.launch(WeasisLauncher.java:256)
	at org.weasis.launcher.WeasisLauncher.main(WeasisLauncher.java:184)
12.02.2021 09:21:14.761 *SEVERE* [main] org.weasis.launcher.FileUtil: Cannot install a native bundle weasis-opencv-core-freebsd-x86-64-4.5.0-dcm
java.io.FileNotFoundException: /usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/bundle/weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
	at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86)
	at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184)
	at org.weasis.launcher.AutoProcessor.installBundle(AutoProcessor.java:554)
	at org.weasis.launcher.AutoProcessor.processAutoProperties(AutoProcessor.java:354)
	at org.weasis.launcher.AutoProcessor.process(AutoProcessor.java:82)
	at org.weasis.launcher.WeasisLoader.setFelix(WeasisLoader.java:256)
	at org.weasis.launcher.WeasisLauncher.launch(WeasisLauncher.java:256)
	at org.weasis.launcher.WeasisLauncher.main(WeasisLauncher.java:184)

leonardorame avatar Feb 12 '21 12:02 leonardorame

Now I have to figure out how to build weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar, any hint @nroduit ?

leonardorame avatar Feb 12 '21 12:02 leonardorame

First install opencv-java with:

sudo pkg install opencv-java

Then when I try to run Weasis I get this:

ERROR : bundle weasis-core-api:3.7.0 (9)[org.weasis.core.api.internal.cv.NativeOpenCVCodec(0)] : The activate method has thrown an exception
java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path: [/usr/lib, /usr/local/lib]

leonardorame avatar Feb 12 '21 15:02 leonardorame

opencv-java is installed in:

pkg info -l opencv-java
opencv-java-3.4.1_37:
	/usr/local/share/OpenCV/java/libopencv_java341.so
	/usr/local/share/OpenCV/java/opencv-341.jar
	/usr/local/share/licenses/opencv-java-3.4.1_37/BSD3CLAUSE
	/usr/local/share/licenses/opencv-java-3.4.1_37/LICENSE
	/usr/local/share/licenses/opencv-java-3.4.1_37/catalog.mk

Knowing that I managed to set the java.library.path option by changing the DEFAULT_JVM_OPTIONS variable in viewer-linux.sh to:

DEFAULT_JVM_OPTIONS="-Xms64m -Xmx768m -Djava.library.path=/usr/local/share/OpenCV/java/ -Dgosh.args="

Now the error is this:

ERROR : bundle weasis-core-api:3.7.0 (9)[org.weasis.core.api.internal.cv.NativeOpenCVCodec(0)] : The activate method has thrown an exception
java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path: [/usr/local/share/OpenCV/java/]

Any hint?

leonardorame avatar Feb 12 '21 20:02 leonardorame

This is not possible because there is no native library for Freebsd. Unfortunately, I don't have the time and resources to manage the compilation and the validation on all systems (especially on more unusual systems). Moreover, all builds have been fully automated through Github action and I don't want to manage builds manually anymore.

The native library supports currently Windows, Mac OS X and Linux. I recently added ARM architecture for Linux.

nroduit avatar Feb 13 '21 08:02 nroduit

Thanks @nroduit, I understand that and of course is not my intention to ask you to make a FreeBSD version. As Weasis is an open source project anyone can contribute to it and that's what I'm trying to do here.

Regarding the native library, it should be created in the /weasis-opencv/ directory? or is there another place I should start looking?.

leonardorame avatar Feb 13 '21 10:02 leonardorame

Well, I think I'm in the right path.

I copied the file weasis/bundle/weasis-opencv-core-linux-x86-64-4.5.0-dcm.jar.xz to weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar.xz and uncompressed it into a subdirectory called freebsd and replaced all references to linux with freebsd, both directory names and inside all the files:

├── libopencv_java.so
└── META-INF
    ├── MANIFEST.MF
    └── maven
        └── org.weasis.opencv
            └── weasis-opencv-core-freebsd-x86-64
                ├── pom.properties
                └── pom.xml

Next I copied my /usr/local/lib/libopencv_java341.so to libopencv_java.so in this directory.

Also I commented and replaced this on config/config.properties:

#felix.auto.install.23= \                                                                                                                           
# ${weasis.codebase.url}/bundle/weasis-opencv-core-${native.library.spec}-4.5.0-dcm.jar.xz \                                                        
felix.auto.install.23= \                                                                                                                            
 ${weasis.codebase.url}/bundle/weasis-opencv-core-freebsd-x86-64-4.5.0-dcm.jar.xz \ 

At this step I don't get the java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path exception when opening Weasis, in fact, the log contains this:

 22 ***** Configuration *****                                                                                                           
 23   Last running version = 3.7.0                                                                                                      
 24   Current version = 3.7.0                                                                                                           
 25   Application name = Weasis                                                                                                         
 26   Application Source ID = 610972F7                                                                                                  
 27   Application Profile = default                                                                                                     
 28   Application local codebase = /usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis                           
 29   Application codebase URL = file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis                        
 30   Application configuration file = file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/conf/config.prope
 31   Application extension configuration file = file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/conf/ex
 32   User = leonardo                                                                                                                   
 33   User home directory = /home/leonardo/.weasis                                                                                      
 34   Resources path = /usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/resources                             
 35   Preferences directory = /home/leonardo/.weasis/preferences/leonardo/default                                                       
 36   Look and Feel = org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel                                                 
 37   Languages path = file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/bundle-i18n/                     
 38   Languages available = en,ar,bs_BA,bg_BG,zh_CN,zh_TW,hr_HR,cs,fr,de,el,hu_HU,it,ja,ko,ms_MY,pl_PL,pt,pt_BR,ro,ru_RU,sr_RS,sk_SK,es,
 39   OSGI native specs = freebsd-x86-64                                                                                                
 40   HTTP user agent = Weasis/3.7.0 (FreeBSD; 12.2-RELEASE-p1; amd64; default; DEFAULT)                                                
 41   Operating system = FreeBSD 12.2-RELEASE-p1 amd64                                                                                  
 42   Java vendor = OpenJDK BSD Porting Team                                                                                            
 43   Java version = 1.8.0_275                                                                                                          
 44   Java Path = /usr/local/openjdk8/jre                                                                                               
 45   Java max memory (less survivor space) = 684.0 MiB                                                                                 
 46 ***** End of Configuration *****                                                                                                    
 47 13.02.2021 07:48:12.686 *INFO* [main] org.weasis.launcher.WeasisLauncher:                                                           
 48 Starting OSGI Bundles...                                                                                                            
 49                                                                                                                                     
 50          | | /| / /__ ___ ____ (_)__                                                                                                
 51          | |/ |/ / -_) _ `(_-</ (_-<                                                                                                
 52          |__/|__/\__/\_,_/___/_/___/                                                                                                
 53                                                                                                                                     
 54 13.02.2021 07:48:12.988 *INFO* [FelixStartLevel] org.opencv.osgi: Successfully loaded OpenCV native library. 

But when I try to open an image I still get the Cannot read this media!... error.

leonardorame avatar Feb 13 '21 10:02 leonardorame

I'm using OpenCV 3.41. and Weasis needs 4.5.0 I'll upgrade mine and try again.

leonardorame avatar Feb 13 '21 11:02 leonardorame

This is not the public version of opencv because there are adaptations to handle all DICOM decoders and encoders.

The source code of this library is not public for the moment.

nroduit avatar Feb 13 '21 11:02 nroduit

Ok, then I'll try to run it via linuxulator.

1. Install linux compat: https://docs.freebsd.org/doc/4.10-RELEASE/usr/share/doc/handbook/linuxemu-lbc-install.html
2. Compile x11/linux-c7-xorg-libs (this is needed for libXext.so)
3. Download and install OpenJDK for linux from: https://adoptopenjdk.net/releases.html (choose O.S. Linux and architecture x64).
4. Uncompress the file OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz and copy it to contents to easis-distributions/target/portable-dist/runtime 

Now when I launch ./viewer-linux.sh I get this:

ERROR: Bundle weasis-core-ui [21] Error starting file:/usr/home/leonardo/Weasis/weasis-distributions/target/portable-dist/weasis/bundle/weasis-core-ui-3.7.0.jar (org.osgi.framework.BundleException: Activator start error in bundle weasis-core-ui [21].)
java.lang.ExceptionInInitializerError
	at org.weasis.core.ui.model.layer.LayerAnnotation.<clinit>(LayerAnnotation.java:20)
	at org.weasis.core.ui.model.layer.AbstractInfoLayer.<clinit>(AbstractInfoLayer.java:59)
	at org.weasis.core.ui.internal.Activator.start(Activator.java:53)
	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.util.MissingResourceException: Can't find bundle for base name org.weasis.core.ui.messages, locale en
	at java.base/java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
	at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
	at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
	at java.base/java.util.ResourceBundle.getBundleImpl(Unknown Source)
	at java.base/java.util.ResourceBundle.getBundle(Unknown Source)
	at org.weasis.core.ui.Messages.<clinit>(Messages.java:18)
	... 9 more
Caused by: java.lang.NullPointerException
	at java.base/java.util.Properties$LineReader.readLine(Unknown Source)
	at java.base/java.util.Properties.load0(Unknown Source)
	at java.base/java.util.Properties.load(Unknown Source)
	at java.base/java.util.PropertyResourceBundle.<init>(Unknown Source)
	at java.base/java.util.PropertyResourceBundle.<init>(Unknown Source)
	at java.base/java.util.ResourceBundle$Control.newBundle(Unknown Source)
	at java.base/java.util.ResourceBundle.loadBundle(Unknown Source)
	at java.base/java.util.ResourceBundle.findBundle(Unknown Source)
	at java.base/java.util.ResourceBundle.findBundle(Unknown Source)
	... 14 more

leonardorame avatar Feb 14 '21 14:02 leonardorame

I installed /usr/ports/x11-toolkits/linux-c7-gtk2. And after that I was able to open an study locally.

image

But I still have issues trying to open using the weasis:// protocol handler.

leonardorame avatar Feb 14 '21 15:02 leonardorame

I don't know what happened, now everything works!

leonardorame avatar Feb 14 '21 15:02 leonardorame

Mm, no, I have to run it a couple of times until it runs properly, also I noticed after opening and closing Weasis the border decorations of all windows (in XFCE) dissapear!, so I must xfce-session-logout and login again...

leonardorame avatar Feb 14 '21 15:02 leonardorame

Could you share the installation procedure that allow to run Weasis.

nroduit avatar Feb 16 '21 07:02 nroduit

Hi @nroduit, basically the process is:

  1. Configure the Linux compatibility layer, called "linuxulator".
  2. Build/download the portable version.
  3. In the directory portable-dist create a subdirectory called runtime and install java jre for Linux 64bit there (I installed the Oracle version).
  4. I made some changes to viewer-linux.sh to fit my config:
#!/compat/linux/bin/bash
# This script attempts to find an existing installation of Java that meets a minimum version
# requirement on a Linux machine.
#

# Specify the required Java version.
# Only major version is checked. Minor version or any other version string info is left out.

# JVM Options
DEFAULT_JVM_OPTIONS="-Xms64m -Xmx768m -Dgosh.args="
GOSH_ARGS="-sc telnetd -p 17179 start"

curPath=/home/leonardo/Weasis/weasis-distributions/target/portable-dist
cd $curPath
JAVA_HOME=$curPath/runtime
export $JAVA_HOME
JAVACMD=$JAVA_HOME/bin/java

# Get additional weasis arguments
userParameters=()
for var in "$@"
do
if [[ $var == \$* || $var == "weasis://"* ]]
then
  userParameters+=("$var")
fi
done

echo "Additional user arguments: ${userParameters[@]}"
echo "Weasis launcher directory: $curPath"

cps="$curPath/weasis/weasis-launcher.jar:$curPath/weasis/felix.jar:$curPath/weasis/substance.jar"
# Launch
$JAVACMD $DEFAULT_JVM_OPTIONS"$GOSH_ARGS" -Dweasis.portable.dir="$curPath" -classpath "$cps" org.weasis.launcher.WeasisLauncher \$dicom:get --portable ${userParameters[@]}

That's it.

leonardorame avatar Feb 18 '21 12:02 leonardorame

Thanks I'll try it.

nroduit avatar Feb 19 '21 07:02 nroduit

We don't have the resources or the capacity to support this type of system.

nroduit avatar May 27 '23 07:05 nroduit