Monday, May 11, 2020

Java app code generators

What I'm trying to do

Clear back in 2005 I wrote my first app to get CRUD pages for a web app from a quick look a the DB metadata. I've done it again  many times since. Always with an eye to making my task easier instead of a generic app. Every time I first look to see if anyone has done somehting similar for the framework I'm using for that project but it always turns out the be easier to just write something myself than the tools I found. Since I've been doing a lot of stuff with containers lately I though it would be good to be able to quickly spin up POC apps for project demos so I'm looking at generators again.

For this POC I started with a simple SQLite DB with just 2 tables. Shows and Networks.

Options tried

The Eclipse market place just lists a couple and I heard about others. Really only Telosys in the market place seemed to be used by more than a few people.

Spring Initializr

Creates a basic project template but need classes created. There are lots of Spring Boot classes on Lynda.com though and it does give you a projects with most of the dependencies you might need.

Telosys

The plugin seems have a lot of downloads and the screen shots look promising but there appears to be no documentation at all. I messed with a bit but

JMR

It is from a Chinese developer and only downloaded 39 times so that is probably a deal breaker right there. On the other hand it at least has documentation to get you started. But it seems to be mainly a GUI for creating JSP style templates to gen code from so again not sure how much of a time saver it would be.

New JPA project

My first issue was I was using  Spring Tools 4.3 from a previous project and creating a JPA project was not even an option.

From the Eclipse Oxygen I tried it just hung creating the project. After about 30 minutes or so it FINALLY unstuck. I generated the beans  per the instructions and got something close. That step went pretty fast but for the overhead I do not see it as worth it for just a few tables.

While I was waiting to see if Oxygen would ever return I downloaded the latest Spring Tools 4.6. But again creating a JPA project is not a option. (Granted I could keep installing tools till I got something to work or it stopped working but the point was to find something simpler than just writing my own code.)

In the end it seems to do "OK" if you do not have (or at least tell it you have) association between tables. Even then though you need to tell it what class to use for every field or it makes them all Objects. It also seems to fail if you do not tell it the id field. So still probably as much trouble to config as to just create the POJOs by hand.

g9 Database Import

Another POJO generator. Does not support SQLite though.

Speedment

To start you use their initializer instead of the Spring Boot one.

It wants Maven 3.5.3 (release Feb 2018) or better to run so that meant a newer IDE.
Note the newer Eclipse zips seem to have an error in them which means you need to manually edit the config.ini or use the installer.

After installing and running the generate tool on the 2 tables with defaults settings I had 91 files generated. I had to "disable" some other tables left over from importing the sheets into the DB. That left me with 46 files for the 2 tables. Note rerunning the tools removes the files for the "disabled" tables. Unfortunately the rest interface it generates appears to be broken and just gives you 404s.

JHipster

The one class there was for it on Lynda.com can not be accessed via LinkedIn Learning. Not sure what is going on there but does not bode well. I wanted to look at it first but was turned off this. But after trying the above I decided to give it a try.
I followed these instructions for setup. Note when running the generator the docs are a bit out of step with what is on screen starting at step 13.
Note I was missing several things it needed and had to run
npm install rimraf -g
npm install webpack (note the missing -g as it expects it to be below the app folder)
npm install write-file-webpack-plugin
npm install webpack-merge
npm install browser-sync-webpack-plugin
npm install browser-sync
npm install webpack-notifier
npm install xml2js
npm install copy-webpack-plugin
npm install html-webpack-plugin
npm install rxjs
npm install merge-jsons-webpack-plugin
then run jhipster again. Fortunately it remembered where it errored out each time.
After all that the java code did not build
ERROR in Entry module not found: Error: Can't resolve 'angular2-template-loader' in 'D:\eclipse-jee-2020-03\workspace\BugTrackerJHipster'

ERROR in Entry module not found: Error: Can't resolve 'angular2-template-loader' in 'D:\eclipse-jee-2020-03\workspace\BugTrackerJHipster'

ERROR in Entry module not found: Error: Can't resolve 'style-loader' in 'D:\eclipse-jee-2020-03\workspace\BugTrackerJHipster'

ERROR in   Error: Child compilation failed:
  Entry module not found: Error: Can't resolve 'html-loader' in 'D:\eclipse-jee-2020-03\workspace\BugTrackerJHipster':
  Error: Can't resolve 'html-loader' in 'D:\eclipse-jee-2020-03\workspace\BugTrackerJHipster'

  - compiler.js:76
    [BugTrackerJHipster]/[html-webpack-plugin]/lib/compiler.js:76:16

  - Compiler.js:300 compile
    [BugTrackerJHipster]/[webpack]/lib/Compiler.js:300:11

  - Compiler.js:510 applyPluginsAsync.err
    [BugTrackerJHipster]/[webpack]/lib/Compiler.js:510:14

  - Tapable.js:202 next
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:202:11

  - CachePlugin.js:78 Compiler.<anonymous>
    [BugTrackerJHipster]/[webpack]/lib/CachePlugin.js:78:5

  - Tapable.js:206 Compiler.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:206:13

  - Compiler.js:507 compilation.seal.err
    [BugTrackerJHipster]/[webpack]/lib/Compiler.js:507:11

  - Tapable.js:195 Compilation.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:195:46

  - Compilation.js:680 self.applyPluginsAsync.err
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:680:19

  - Tapable.js:195 Compilation.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:195:46

  - Compilation.js:671 self.applyPluginsAsync.err
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:671:11

  - Tapable.js:195 Compilation.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:195:46

  - Compilation.js:666 self.applyPluginsAsync.err
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:666:10

  - Tapable.js:195 Compilation.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:195:46

  - Compilation.js:662 sealPart2
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:662:9

  - Tapable.js:195 Compilation.applyPluginsAsyncSeries
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:195:46

  - Compilation.js:605 Compilation.seal
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:605:8

  - Compiler.js:504 applyPluginsParallel.err
    [BugTrackerJHipster]/[webpack]/lib/Compiler.js:504:17

  - Tapable.js:289
    [BugTrackerJHipster]/[tapable]/lib/Tapable.js:289:11

  - Compilation.js:507 _addModuleChain
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:507:11

  - Compilation.js:390 errorAndCallback.bail
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:390:4

  - Compilation.js:413 moduleFactory.create
    [BugTrackerJHipster]/[webpack]/lib/Compilation.js:413:13

  - NormalModuleFactory.js:235 factory
    [BugTrackerJHipster]/[webpack]/lib/NormalModuleFactory.js:235:20

  - NormalModuleFactory.js:60 resolver
    [BugTrackerJHipster]/[webpack]/lib/NormalModuleFactory.js:60:20

  - NormalModuleFactory.js:191 asyncLib.parallel
    [BugTrackerJHipster]/[webpack]/lib/NormalModuleFactory.js:191:21

  - async.js:3888
    [BugTrackerJHipster]/[async]/dist/async.js:3888:9

  - async.js:473
    [BugTrackerJHipster]/[async]/dist/async.js:473:16

  - async.js:1062 iteratorCallback
    [BugTrackerJHipster]/[async]/dist/async.js:1062:13

  - async.js:969
    [BugTrackerJHipster]/[async]/dist/async.js:969:16

  - async.js:3885
    [BugTrackerJHipster]/[async]/dist/async.js:3885:13


error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
If you find JHipster useful consider supporting our collective https://opencollective.com/generator-jhipster

Server application generated successfully.

Run your Spring Boot application:
 ./mvnw (mvnw if using Windows Command Prompt)
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: ERROR! webpack:build failed.
    at Environment.error (C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\generator-jhipster\node_modules\yeoman-environment\lib\environment.js:157:40)
    at module.exports.error (C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\generator-jhipster\generators\generator-base.js:2064:18)
    at module.exports.end (C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\generator-jhipster\generators\client\index.js:410:18)
    at Object.<anonymous> (C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\yeoman-generator\lib\index.js:399:25)
    at C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\run-async\index.js:25:25
    at new Promise (<anonymous>)
    at C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\run-async\index.js:24:19
    at self.env.runLoop.add.completed (C:\Users\avata\AppData\Local\Yarn\Data\global\node_modules\yeoman-generator\lib\index.js:400:11)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)



Tuesday, March 24, 2020

Review: Making water at home

Note I started this post to tell people about alternatives to bottled water but because of the SARS-CoV-2 (Covid-19) outbreak most of the items are already sold out. You might be able to find similar items though or after sanity comes back.

Mentioned in this post

Mophorn Water Distillers Countertop 4L BPA-Free Container 750W Digital Control Distilling Water Machine for Home with Handle Upgrade
BN-LINK 12 Hour Mechanical Accurate Countdown Timer with Grounded Pin - Energy Saving for Kitchen, Phone Charger, Lamps, Security 1875W, 1/2 HP, ETL Listed
ZeroWater (ZBD-040-1) 40 Cup Ready-Pour Glass Dispenser, BPA-Free, with Free Water Quality Meter, NSF Certified to Reduce Lead and Other Heavy Metals
Beverage Dispenser Replacement Spigot,Oak Leaf Stainless Steel Spigot Polished Finished, Dispenser Replacement Faucet
ZeroWater ZD-018 ZD018, 23 Cup Water Filter Pitcher with Water Quality Meter
ZeroWater Replacement Filters 12-Pack BPA-Free Replacement Water Filters for ZeroWater Pitchers and Dispensers NSF Certified to Reduce Lead and Other Heavy Metals
Etekcity Digital Handheld TDS Meter , +/- 2% High Accuracy, 0-9990 ppm (Blue)

Update 10/14/2021:
VEVOR Water Distiller, 1.1 Gal Distilled Water Maker, 4L Pure Water Distiller w/Dual Temperature Display, 750W Countertop Water Distiller, Distilled Water Machine for Home w/Plastic Container White

The issue

I'm on a well and the water that comes out of it is HARD as in averages in the mid 300s on a water purity meter AFTER going through the water softener. It also has Hydrogen Sulfide in it from time to time. So I store up water for the animals to use during the H₂S times. I was drinking mainly bottled water but hated all the extra plastic. (See my Drinking water post about testing the various brands and types. You will probably be surprised.( I bought a ZeroWater ZD-018 ZD018, 23 Cup Water Filter Pitcher with Water Quality Meter to try and avoid that but a filter was yielding me less than 9 gallons of water. Even buying the 12 pack of filters at $118 that comes out to over a dollar a gallon plus you have the filter to dispose of. Hard to say which has waste but the filters weight about 464 grams and a gallon water bottle about 70 grams. (Not including packaging.) Of course some of the filter weight is not plastic and it is compressed where the bottles will take some effort to get to the same size package and so on. Either way neither seemed like a good choice.

My setup

What I came up with

Step 1

I had decided on distilled water for bottled water from earlier testing I started thinking why not just distill the water? After reading reviews I figured out the base models are not very good. What you need is a model you can adjust the heat on and a timer to make sure it does not run dry. Here is the water I started with. It is hard to see but this is a relative soft batch at 284.



Starting with the review and then doing a bit of experimentation it appears the the temperature dial and readouts on the distiller might be off a bit. I set the dial right at 100C but it says it is cooler.


Then I set the timer for 3 hours. (Which is a good deal shorter than the 4 to 5 hours in reviews and still distilled almost all the water.) That gives me water purer than most of the bottled waters on the market.



This is what is left behind. I poured some of the less than 1/2 inch left in the boiling chamber into a beaker for this pic. That is 8260 on the meter! I did not notice till I was posting this the 10x indicator in the low left of the LED readout. Kind of shows why you do not want this to boil dry with a 320 degree auto shutoff like the base models do. Way too much of this ends up in your output.


Estimates were around 50 cents of electricity per gallon in review so it could be way cheaper too. I appear to be running it cooler and shorter than most so maybe even better.

Step 2 (optional)

You probably want something to hold s the water and possibly filter it. Which lead me to getting the ZeroWater (ZBD-040-1) 40 Cup. From the reviews the valve on this is junk so you will want an after market spigot too. This give me a 2+ gallon buffer ready to use water as pure as the distilled bottled water (zero on the meter) and the filters should last a long time since the water going in is pretty pure to start with I'm keeping tabs on how many gallons I get from a filter so we'll see if it is all worth it. More to come.

Update 9/18/2020 

After about 6 months I'm still very happy with this though I have put an upside down bowl (about 3 inches deep)  under the jug to raise it to lessen splashes escaping. Stopped using the distiller's carbon filters too given I run it through a ZeroWater. I think the carbon filters are only needed if you run the unit dry which my setup avoids and they tend to leave bits of carbon in the jug and ZeroWater reservoirs. Note making almost a gallon a day, I've still not needed to change the ZeroWater filters. I did clean out my smaller ZeroWater ZD-018 ZD018, 23 Cup Water Filter Pitcher with Water Quality Meter I was using to filter softened water when its filter needed changing. Between the 2 I can empty the whole jug in one go without waiting for the reservoir to empty. (The 40 cup's reservoir only holds about 4/5ths of a gallon. The 23 cup even less.) Given the price and rate I was going through those filters I'm sure the distiller is cheaper on top of less waste.

Something else you might find helpful is to add one of these Kichwit Dishwasher Magnet Clean Dirty Sign Indicator to the front. I set it to: 
  • Clean - when ready to go (I run it "off hours")
  • Running - when I set the timer to start a 3 hour run
  • Dirty - when I empty the jug till I have time to clean and refill the reservoir. 
After running it without refilling a couple times I figured the sign was well worth the $8.

Update 10/14/2021

Mophorns went out at about the same 9 month mark (~200 gallons) so I purchased a VEVOR Water Distiller the 3rd time. The first started cycling off and on while the second the heating element appears to have quit on so it might be possible to merge the two into one working one when I have the time. The Vevor is cheaper and has a digital control and read out and $40 cheaper. Assuming 50 cents in electricity and replacing every 200 gallons I'm looking at a dollar a gallon with the Vevor and again with a fair bit of waste if I have to toss it. I figure worst case I can give to Goodwill to repair or recycle. It also appears these are all basically the same so there is a fairly good chance I could use parts from one to fix another. I'm actually still using the same top cooler unit from the 1st distiller. Oddly the second Mophorn took ~3.5 hours to distill a gallon of water with about an inch left in the boiler will both the first Mophorn and the Vevor seem to do it in 3 hours. Interesting too that read out on the Vevor holds at 100 so maybe the temp control is not even needed. Just sort the run time to leave a bit in the boiler. In that case the cheapest unit (currently $75) might be fine.

Note I swapped out the jug for a beaker list a cover awhile back for something easier to clean. This worked will with the Mophorns.
Mophorn with beaker

The Vevor has the controls in the main unit instead of an add on base so it is much shorter requiring me to add a base on my own. If you use the jug it comes with it is not an issue of course.
Vevor with beaker


Update 02/07/2022

The VEVOR Water Distiller went out after 4 months. Shorted out actually, tripping the GFI breaker. After some experiments, I've decided the temperature control is not really important as long as you have a timer to shut it off before it boils dry so getting the cheapest model is probably good enough. Turned out though the VEVOR Water Distiller was the cheapest model Amazon had in stock, even without a temperature control, so that is what I got. Hopefully the 4 months lifespan was a fluke. Need to find time to see if the others can be repaired. So far it is running about $20-30 per month for hardware alone.  Add in electricity and it is getting close to the cost of the Zero filters and no savings in waste either. It does remove the Hydrogen Sulfide (HS) gas when that is an issue where the Zero filters do not, so maybe still be a bit of an advantage. 

Update 07/13/2022

The second VEVOR Water Distiller also went out after 4 months. So bought the cheapest, no frills one I could find which was the Mophorn Pure Water Distiller 750W which runs ~$80. After about 2 months of use it seems to work about as well as the ones with temp controls as long as you still have the timer keep it from boiling dry. 







Thursday, January 16, 2020

Review:Firewalla

From the info on the website it appeared I could use the one feature of the Firewalla Blue I wanted. Something to monitor what things the devices on my IoT network are talking to and give me a notification if they try and connect to something unexpected. Essentially monitor if any device may have been co-opted and or is trying to co-opt. It did give me alerts for remote sites my Wyze cams, Echos and SmartThings hubs connected to along with every new device it saw. But the Firewalla seems to insist on inserting itself via arp spoofing and messes with DNS which caused all kinds of issues. Among the top things I noticed were:

Alerts from antivirus software about bad arp packets. That would be kind of expected but why it does this even with most of the features disabled is unclear. All this should need to do is log traffic like Wireshark and only need arp spoofing to try and stop traffic. Same with DNS.

Despite claims it works with Unifi it seems to have caused all kinds of issues with APs and switches not getting heartbeats to the controller and generally dropping data so the topology map was only showing a few devices and those all connected directly to the router. The client listing would often show the wrong AP/Port for a device.

Some security cams started having issues staying connected too. I'm to the point this morning I'm shutting it down so we'll see if the camera issues correct or were a coincidence. Update other than the Wyze cams, they did.

So if you are looking for something simple to monitor your home network of a few devices and the ISP provided router this might work well for you. If your network is at all advanced beyond basic, give it a pass.