Monday, February 25, 2019

100 Days of Code...formalizing learning and practice

Over the years, I've tried to make sure that I dip my toes in the new technologies that come up pertaining to programming.

Of course - there are far too many new avenues to be able to keep up with everything. And, for anyone that's been in tech for a while you know that not every shiny new thing lasts. So, there is a bit of fear that I'll head down a road that everyone else shuns.

Those two things (too many things to learn and fear) have made my efforts to stay 'current' less than stellar. Add on top of that the fact that I have a full time job in IT that has its own demands on my brain and time and it has been difficult to make the kind of progress that I would like to.

Well, last week I stumbled onto the 100 Days of Code challenge wandering around in Twitter.

And - I'm in...

Today is my third (should have been fourth but I missed a day) day and I have already worked on three separate topics:

  • Practicing Python by working through the exercises in the book 'Exercises for Programmers' by Brian P. Hogan
  • Going through the React course on Scrimba (about halfway through with this)
  • Digging into code that I wrote at least six years ago at work to refactor/improve it


Hopefully, I'll be able to finish these three things quickly and then make a more concerted and focused learning journey.

I've got many other topics that I want to study - so I have in the back of my head the plan to move on to round 2, round 3, round...

First things first though - this is day three.

Friday, August 7, 2015

Getting to the Nexus of the problem of Nexus-OSS on TomEE-RS...

As I have mentioned on previous posts, I am trying to move my development target to Apache TomEE.

As part of that, I am also trying to make my laptop into a complete development environment that includes:

  • TomEE to host my apps (and development tools)
  • Nexus-OSS for repository management (one of those aforementioned dev tools)
  • MariaDB as a database

Well, to start with - I run Kubuntu. So, I installed Tomcat 7 the usual 'apt-get' way and followed the directions on the TomEE site for installing it as a WAR (I used the TomEE-RS version) onto an existing server. Pretty straight forward.

MariaDB required a bit of back and forth with installing and purging Maria vs MySQL but eventually it settled down and I did not need to manually change anything.

Nexus caused some trouble. I found a good list of steps for doing the install here:

http://www.hackrunner.com/2012/04/installing-nexus/

That post is a bit dated - so, I adapted as I typed because I was working with Tomcat 7 and Nexus 2.11.4.

  1. sudo mkdir /usr/share/tomcat7/sonatype-work
  2. sudo chown tomcat7:tomcat7 /usr/share/tomcat7/sonatype-work
  3. wget http://www.sonatype.org/downloads/nexus-2.11.4.war
  4. sudo cp nexus-2.11.4.war /var/lib/tomcat7/webapps/nexus.war

And, it looked like it was working until - it didn't. I got an error in the log file that included:

java.lang.RuntimeException: javax.naming.NameNotFoundException: Name [com] is not bound in this Context. Unable to find [com].

So I searched for some solution online. There was nothing specifically related to installing Nexus on TomEE. Instead, there were results about installing apps that included Jersey on TomEE. People were running into trouble because there is already REST support in the TomEE-RS server. The solution was to remove Jersey from the WAR file that you are trying to deploy (as well as whatever references there are to the included jars in web.xml).

The Nexus WAR was already exploded so, I checked the web.xml to see if there were any references to Jersey - Nope. But, there were several jar files hiding in the WEB-INF directory. I got rid of those with these commands (hoping that it would not end up removing something that I actually needed):

cd /var/lib/tomcat7/webapps/nexus
find . -name jersey* -exec sudo rm -v {} +

And, restarted Tomcat...


Success!

Now, as a note - I probably should have at least specified that the find search for jar files rather than any old file that had a name starting with 'jersey'. I did know that there were only jar files because I had already done the search once before adding the remove. If you are going to try this for something other than installing Nexus on TomEE-RS make sure that you have verified what is going to be removed first.

Wednesday, March 5, 2014

I am a happy boy...

Finally!!!!

I got all of the pieces worked out on my app running on Apache TomEE.

Before you invest too much time reading - this is really dry reading. But, if you are planning on connecting to a MySQL database from an app running on TomEE it might help you get it working.

You're still here! Well...

It took a bit longer than I had expected it to (of course I didn't get to work on it full time). But it works!

I've got my JSP sending data to my servlet using AJAX. The servlet is properly parsing the XML and uses JPA to access my MySQL database.

Perhaps strangely enough, the biggest headache that I ran into was getting the data source properly configured.

Here is what it took...

In the WEB-INF directory is my resources.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
<Resource id="pInit" type="DataSource">
ignoreDefaultValues true
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://ksdb:3306/projectInit
UserName username
Password password
defaultAutoCommit true
jtaManaged true
</Resource>
</resources>


In the META-INF directory is the persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit transaction-type="JTA" name="pilCommon"> <jta-data-source>pInit</jta-data-source> <class>com.pubint.projInit.entity.Project</class> <properties> <property name="openjpa.jdbc.DBDictionary" value="mysql" /> <property name="openjpa.AutoDetach" value="close" /> <property name="openjpa.DetachState" value="fetch-groups(AccessUnloaded=true)" /> <property name="openjpa.Multithreaded" value="true" /> <property name="openjpa.TransactionMode" value="managed" /> <property name="openjpa.NontransactionalRead" value="true" /> <property name="openjpa.RestoreState" value="all" /> <property name="openjpa.jdbc.SynchronizeMappings" value="false" /> <property name="openjpa.InverseManager" value="true" /> </properties> </persistence-unit> </persistence>

I might have gone overboard on the properties that I set in the persistence file but the minimal version that I modeled after from the TomEE site did not work. TomEE kept trying to use HSQL to connect to the database rather than MySQL (which is what it really should have been).

But that is okay - it works and I can finally move on to building the real pages and implementing the needed functionality.

Whew...

Monday, February 24, 2014

Did someone get the number of that bus...

So, headache it is.

If you caught my post from Friday then you know that I planned to push through getting the beginning of an app that would be deployed to Apache TomEE over the weekend or get a headache trying.

Well...My Saturday got swallowed up by household maintenance issues so Sunday got the brunt of the coding effort.  And (did I mention that I have the attention of a squirrel in the face of new tech?) a decent chunk of my time got eaten up by trying to wrangle heroku into submission as a TomEE hosting service. There were a couple of existing 'buildpacks' (heroku's means of customizing the deployment environment) for Tomcat and TomEE - but they did not work for me. So, I set out on the path of trying to build one that would work.

After many hours of trial and error - no success. But, I do have some clues and a new resolution to search for more experienced eyes (just have to figure out where they would be...).

And, most importantly - I have a renewed resolution to get back to the main effort and to quit yak shearing (I love that term!).

Putting away the clippers now.

Back to coding...

Friday, February 21, 2014

TomEE can you hear me...

When I was listing out my priorities of languages/technologies that I am going to be focusing on in the next year, I forgot to mention (Apache) TomEE.

TomEE is a full Java EE server based on Apache Tomcat (http://tomee.apache.org) and should make it easier to set up, configure, and maintain application servers. But, I have gotten stuck in my ways and lazy. For the past six (or so) years I have been using Apache Geronimo for my app servers. When Geronimo went from version 2.2.x to version 3.x I got left behind. Time constraints kept me from putting in the time to clean up my app and get it into a state that can be deployed on the new OSGi environment.

I still need to put in that time and get my app converted to be compatible. But, recently there are a procession of smaller more self-contained apps that need writing and since we have one externally written app that is running on Tomcat - it makes sense for us to move that app to TomEE and write these new apps for TomEE as well.

So, I am now in the process of trying to develop my first app for TomEE...Using a responsive web framework (Foundation). And, it needs to be ready for beta testing in two weeks.



By Monday I should either have the first functioning bits of this new project running on a TomEE instance or a massive headache. Or...maybe both.

Wish me luck!

And I'll see you in a couple of days...

Wednesday, February 12, 2014

Where did that piece of paper go (part two)...

I have generally had fairly bad luck at predicting the future of where technology was headed.

Back in 1995 I thought that Java was a toy and that it was not going to ever make any real impact on programming. When I first started doing web development I thought that JavaScript was pointless and that there was no good reason that anyone would ever use it for anything serious.

Well, I was at least right that for the most part, applets have faded into the mists of time. But, I use Java pretty much every day. I love the performance that I am able to get on the back-end server. And, over the past six years I have been able to figure out that JavaScript is worth my time too. If I had just figured out that everyone was just misusing it when they made all of those scrolling marquees and flashing text sooner! AJAX has made web browsers into my preferred front end clients.

Since I keep having it pushed into my face that I have been a bad prognosticator I have been trying to be more open minded about technology. Which, has the unfortunate side effect of eating all of my free time. The parade of technology that has been demanding my attention has done nothing but speed up over the past few years. In its wake are hours of my time that were spent starting to learn about a tool, language, or technique only to have something else come along and steal my attention.

I am really tired of swimming so hard against the stream and getting nowhere, so...

I have made a list of the new things that I am going to focus on in the next year or so. And here it is:
What would be really nice if each of those were nicely contained - but they aren't. So, each of them is really the label on a fairly big bag of learning.

On the plus side, I have some actual progress on the beginning of my list. My origami website (that goes along with the Android app that I wrote) Origami Central was written taking advantage of the Foundation framework and should be reasonably workable both on the desk top and on mobile devices. There is still a fairly long way to go with it so it will be getting better over time. And, I have also been able to jam the framework into the work I am doing at my day job as well (sorry that is private so no peeking).

And of course there is a whole handful of other things clambering for my attention. Hopefully, this is the best list for me to focus on and I'll be able to hold off on expanding it until I have a decent understanding of these...

Where did that piece of paper go...

I am sure that you have been waiting with bated breath to find out if I would actually finish an app for Android.

Well, I did! Actually, I finished the first version of it months ago. And, it is even available in the Play store (https://play.google.com/store/apps/details?id=net.jnwd.origamiFinder).

I had hoped to make it completely amazing before I officially told anyone about it so that I would not attract too much attention before it was 'ready'.

Well, work and a thousand other things got in the way of making the improvements that I had hoped to do - so...Here is the official announcement. If you are interested in finding what publications contain the directions to fold a particular origami model without being attached to the internet - then this is the app for you.  I didn't even have a chance to set up advertising in it. So, it is free and free of advertising too!

If you take a look, please leave some sort of review. I really would like to make it better in a lot of ways. But, if I am out in left field about people wanting it - then it will probably languish while I direct my attention toward other things.