java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass

Upgrading from JDK8 to 17+ caused jaxb to run into this errors at run time. Solution remove older Jaxb jars and replace with newer jars that still provide “xml.bind”. When replacing try with 2.3.X jar versions as they still maintain the old sun class path, 3.XX jars have switched to the jarkarta class path which will mean updating some of your project imports and dependencies.

Remove any of the below libs

implementation group:'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
implementation group:'com.sun.xml.bind',name:'jaxb-impl', version: '2.3.0'
implementation group:'com.sun.xml.bind',name:'jaxb-core', version: '2.3.0'

replace with

implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '2.3.3'
implementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.3'

Chomebook Secure Shell – Remove ssh key from known_hosts

One problem with the Secure Shell plugin is when you need to remove an ssh key from the known_hosts file there is no direct access to the file from the file system. This issue comes up normally when you run into the error message below.

Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
Please contact your system administrator.
Add correct host key in /.ssh/known_hosts to get rid of this message.
Offending ED25519 key in /.ssh/known_hosts:9
Host key for xx.xx.xx.xx has changed and you have requested strict checking.
Host key verification failed.

Which will come up when you re-image an existing host or replace an existing host with another host using the same IP address/host name. The previous way of doing this used to be do (CTRL + SHIFT + J) to bring up the terminal and then run the command “term_.command.removeKnownHostByIndex(INDEX); ” but this doesn’t always work for me as “command” isn’t always available. The most consistent way I have found to resolve this is to bring up Secure Shell and choose Options -> SSH Files you will see your known_hosts file with the ability to modify and save it. Remember to save after your changes and you should be good to go.

No appropriate protocol

I saw this error message once I updated to JDK 11 when trying to send emails initially I didn’t have time to figure out a long term solution so I took a shortcut and removed Tls 1.0 from blocked algorithms in the file. (I know that was a bad move but I was on a time crunch so I wasn’t thinking clearly 🙂 )
Things were ok for a while until an update of JDK replaced my update to file, at this point I figured I would have to keep repeating this dance every few months or get a long term solution.

I use apache commons library to send email and by default it uses < TLS v1.2 and JDK 11+ supports > TLS v1.2. The permanent fix just turned out to be specifying TLS version to be used and my app was able to get back to sending emails without any issues and this time it was future proofed from future update breakage due to JDK updates. Below are the parmeter updates needed.

#Method 1 adding a system property
System.setProperty("mail.smtp.ssl.protocols", "TLSv1.2");
System.setProperty("mail.pop3s.ssl.protocols", "TLSv1.2");
#Method 2 setting value in a property file

I went with Method #2 as it allows easier management of properties but every bodies use case is different so you can go with whatever works for your situation.

Update Remi PHP to next version

Since Centos ships with an old PHP version, there are many tutorials on how to install Remi PHP which enables you to use more modern versions of PHP on your site. But when it came time to update from PHP72 to php73/4 I couldn’t find a lot of docs on this so I decided to put this one up to remind me next time am doing this.

First, we will need to enable the PHP version we want to install such as below.

# yum-config-manager --enable remi-php73
# yum-config-manager --enable remi-php74

In my case, I was moving from php72 to 73 before 74 so I enabled 73 and disabled 72.

# yum-config-manager --enable remi-php73
# yum-config-manager --disable remi-php72

After enabling the version you want to move to and disabling your current version, run yum update and restart your webserver.

# yum update
# apachectl restart

To validate the update was successful check the current version of PHP as reported in your terminal, and those are the steps needed to move from one Remi PHP version to another.

# php -v
PHP 7.3.29 (cli) (built: Jun 29 2021 09:30:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies

VP8/9 vs h264/5 for personal videos

Recently I needed to encode some clips taken with my phone to a web optimized format since the videos were already in mp4 my initial thought was to keep them in mp4 format h264 video/AAC Audio.
First things first to get the videos to a web optimized format a re-encode would be needed so I had to accept that some drop in quality was going to happen. That was the easy part. A little googling and I found that libfdk_aac is the best AAC codec currently to use with ffmpeg, so I uninstalled my RPM installed ffmpeg and tried to compile my own. Getting sources for all the codecs I needed to have in my ffmpeg was pretty straight forward, but the build failed with some make error gcc was having issues building for the platform. This left me with 2 options wipe the OS fedora 20 and upgrade to the latest 21 or spin up a VM and use that to do the compile. The second option seemed like the way to go but I still wasn’t sold on the idea of having to do all this extra effort just to encode some phone clips.

During this thinking period when I was trying to get some time to go with option two I came across an article about vp9 and it hit me I was willing to jump through all this hoops to use a proprietary codec while there was a comparable opensource codec I could use with ffmpeg out of the box. So I re-installed ffmpeg from RPM spent about an hour tweaking some scripts to do the conversion and rotation of the clips.
Played back the newly encoded webm files and I could barely notice a difference with the original files, they were also 50% – 70% the size of the original files. Getting my video hosting application to work with webm files took about another hour as it was not on the list of supported extensions this was uprising since it’s an open source application.

Right now am feeling pretty happy with my choice as expected safari and IE don’t support webm so for those needing to watch the clips am just telling them to use Chrome or firefox. While the video hosting application allows me to share the clips with outsiders for my internal consumption of the clips I use Plex Media Server once they add support for webm to their native clients I will be converting the whole collection of clips from mp4 to webm.

Update: I received some feedback from family members and they are able to view the videos without a problem, so looks like I will be sticking with VP8/9.

Useful Git commands

Sometimes when using apps checked out from Git an update might break something so it’s good to know a few git commands. Move to root of the app folder you had checked out to perform git commands.

git log
This command will list all the commits so you can see at which commit you are and pick the one before yours and copy the commit hashcode it will be a long string.

git checkout hashcode
With ‘hashcode’ being the commit hashcode copied from the log. This command will move/revert your app/code to the commit you specified. Just restart your app after that to run it with the new code.

git checkout master
This command will move your code to the master branch from development. Do this if you want your app to be more stable Alpha/Developement branches break now and then as people checkin new code. They have the benefit of getting new features before the stable branch if you don’t mind having something break now and then which is ok with me 🙂

Python IMAP search and SMTP with Gmail

Recently I had a need to search through my gmail and fwd some emails on a daily basis. I checked out Gmails rest interface but it was a bit of an overkill for what I was doing. So I settled on just plain IMAP and SMTP. The main idea was search through my inbox using several search parameters, get all the emails that match the pattern and fwd them to a list of emails. So I wrote a script to do this and had cron call the script at the end of the day. I put up the source in github for anyone interested.

Love OOP Python

Python makes it easy to automate manual tasks. Over time I have accumulated some scripts each for a different task but not sharing any code between them but having some similar logic, basically a few of them were having duplicate logic. So this week as I was adding another script to download and add the latest plex media server to my local repo, I came over an article about OOP python on Stackoverflow.
After creating a class for all the common logic in my scripts I was able to reduce the size of most of them by over half, I make my living writing OOP code for java but OOP for python was new to me. I wish there was OOP for bash 🙂 I have a bunch of bash scripts that need culling.

[Solution] ALSA lib conf.c:4514:(parse_args) Unknown parameter AES0

I would get this error while trying to watch certain movies over HDMI with XBMC on my tv and no audio would be available.

ALSA lib conf.c:4514:(parse_args) Unknown parameter AES0
ALSA lib conf.c:4647:(snd_config_expand) Parse arguments error: No such file or directory
ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM plughw:0,0,AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2

My solution to this error is in audio settings section under passthrough output device choose custom and enter whatever output you use for your HDMI mine is “plughw:1,7”. To my understanding it’s an ALSA issue with ac3 where it passes the wrong output parameters, and the AES0 parameter is supposed to set the digital audio output connector in the right mode. Thats my understanding from what I have read about it so google it if you want to find out more on this. As for me am content that it all works and I can stream all my stuff with sound to my tv.

The ResourceConfig instance does not contain any root resource classes

I have finished building a web service several times start up tomcat and get the above error even though my classes have @path annotations and my web.xml is properly setup for web services.

Here is a solution I found out, make sure to do a manual project build from Eclipse when you are done working on it. For some unknown reason even though the project is on auto build, the resource configurator did not pick up my new restful project until I did a manual build. The manual build is only required the first time you need to add the restful service to your resources, the servlet entry below is all you need to add to your web.xml to enable restful services to be configured by resource locator.

[cc lang=”xml”]