Tuesday, July 21, 2015

Setting up IntelliJ IDEA to run Spring Applications with Jetty

- I needed Servlet 3.0 features (like config through ServletContainerInitializer interface), but unfortunately Gradle's Jetty plugin (as of v2.4) uses Jetty 6, so it doesn't support Servlet 3.0. So I'm not bothering.

- Instead, I used the third party plugin gretty:  http://akhikhl.github.io/gretty-doc/Getting-started.html

- Had problems using gretty with the IDEA's Default Gradle Wrapper (gradle 1.8):

Error:Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.
Possible causes for this unexpected error include:
  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
  • Stop Gradle build processes (requires restart)
    In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
    So instead I switched to using Local Gradle Distribution (2.4).

    Use gradle appStart to start the server.
    Use gradle appStop to stop the server.

    Monday, July 20, 2015

    IntelliJ 14 CE not updating Maven Repository Indices

    Was seeing errors when trying to update Maven repositories in IntelliJ 14 CE

    Preferences / Build, Execution, Deployment > Build Tools > Maven > Repositories

    All of the Remote Repositories where showing 'Error'.


    Hitting Update worked occasionally (like maybe 1/20 times)

    Saw this in the Event Log

    10:14:25 AM Unindexed remote maven repositories found. Disable...
                The following repositories used in your gradle projects were not indexed yet:
                http://download.java.net/maven/2
                http://maven.springframework.org/milestone
                http://maven.springframework.org/release
                If you want to use dependency completion for these repositories artifacts,
                Open Repositories List, select required repositories and press "Update" button (show balloon)

    Also saw Exceptions in idea.log (Help / Show Log in Finder)

    Tried alternative WI-FI and Ethernet connections, including the hotspot on my phone.  No change.

    On ths advice of these Threads:
    https://youtrack.jetbrains.com/issue/IDEA-102693
    https://youtrack.jetbrains.com/issue/IDEA-138029

    I removed the -Xmx512m Setting under Preferences / Build, Execution, Deployment > Build Tools > Maven > Importing > VM options for Importer

    Intially, this seemed to work ... but alas I think it was a coincidence.  It worked fine on the first attempt to update repo1.maven.org, but failed on the others...and ultimately failed when retrying repo1.maven.org.

    Then Tried changing the Maven Importing JRE:

    Build, Execution, Deployment > Build Tools > Maven > Importing > JDK for Importer

    from the Default (Use Internal JRE (1.6) ) to the JDK 1.8 I had installed.

    Again, this seemed to work initially....but failed on second attempt.

    Then I tried killing the RemoteMavenServer (java process found using ps aux | grep maven).  This also made the first download attempt work, but subsequent downloads failed.  I suspect changing the -Xmx and JRE in the above attempts was restarting Java ..... and triggering the same effect as killing the maven process.  The problem seems to be in the interaction between IDEA and the external maven process.

    For now, my solution is to kill any existing RemoteMavenServer process before clicking the 'Update' button.  An easy way to do this it to make some trivial change in VM Options for Importer .... which causes IDEA to restart the external maven process.

    This problem is well characterized here:
    https://youtrack.jetbrains.com/issue/IDEA-138029

    Hope JetBrains fixes this one soon.

    Monday, July 6, 2015

    IntelliJ Gradle not resolving dependencies

    Followed the typical process of setting up a simple Gradle project in IntelliJ  IDEA 14 ....but dependencies were not resolving.  Upon hitting the refresh button, each of the gradle dependencies were underlined red....no useful feedback in logs or console.

    I eventually figured out the problem:  Intellij was configured for Gradle offline mode.

    Preferences >> Build, Execution & Deployment > Build Tools > Gradle >> Offline Work

    Global Gradle Settings was set to 'Offline Work'.  I have no idea why, may have been due to a sketchy WI-FI connection I was using.

    After unchecking the box and refreshing the Gradle project, I'm back on track.

    I found it very useful to download and install Gradle for the command line (using gvm)  so I could test Gradle independent of IntelliJ.  I had no problems using command line gradle to download dependencies....telling me the problem was with IDEA.

    It was also helpful to run Gradle tasks (like compileJavaTest) directly using IntelliJ.  While, 'Refresh' produces no useful console output, running Gradle tasks do.... and in this case the error told me the problem was 'Offline Mode'.


    Friday, February 20, 2015

    Maven 3.2.5 not connecting to https:// repositories

    At work, Maven was failing to connect to https://repo1.maven.org/maven2.  I was getting a 'Connection Reset' error.  Don't know why.  Seemed to be a problem with https, proxy corp network?

    I fixed this link in updating my ~/.m2/settings.xml.  I changed all the urls to http.


    http://stackoverflow.com/questions/25911623/problems-using-maven-and-ssl-behind-proxy

    Why can't this stuff just work?


    -Matt


    Friday, November 21, 2014

    Connect to Beaglebone Black over Debug Serial Header / Windows 7

    1. Install BB Drivers
    2. Install FTDI Virtual Com port drivers (http://www.ftdichip.com/Drivers/VCP.htm)
    3. Connect the FTDI friend (http://www.adafruit.com/product/284) to the 6-pin debug serial header on the BB, chip facing out.
    4. Power BB
    5. Connect USB from FTDI Friend to PC.
    6. Use Device Manager to determine COM port.
    7. Use Putty to connect (COMX, Speed = 115200, Data Bits = 8, Stop Bits = 1, Parity = None, Flow Control = None)
    8. Hit return, look for login prompt.
    9. Connect Ethernet to network
    10. ifconfig to determine IP address
    11. SSH from PC to IP address....

    Friday, June 27, 2014

    Restore Reminder popup in Outlook 2010





    http://www.codingeverything.com/2013/05/making-sure-outlook-calendar-reminders.html#StepNumberFive


    Here's the formatted script

    'Declare Functions From User32 Library
    Private Declare PtrSafe Function FindWindowA Lib "user32" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
        ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
        ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
        ByVal cy As Long, ByVal wFlags As Long) As Long


    'Declare Constants
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOMOVE = &H2
    Private Const FLAGS As Long = SWP_NOMOVE Or SWP_NOSIZE
    Private Const HWND_TOPMOST = -1

    'Finds Reminder Window and Brings to TopMost position
    Private Sub Application_Reminder(ByVal Item As Object)
        Dim ReminderWindowHWnd As Variant
        Dim cnt As Long
        On Error Resume Next
        cnt = 1
        Do Until (cnt > 20 Or ReminderWindowHWnd <> 0)
            ReminderWindowHWnd = FindWindowA(vbNullString, cnt & " Reminder(s)")
            cnt = cnt + 1
        Loop
        'bring reminder window to front
        SetWindowPos ReminderWindowHWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
    End Sub

    Sunday, May 25, 2014

    Installing SSD

    Roughly following this guide:

    http://forums.crucial.com/t5/Solid-State-Drives-SSD-Knowledge/How-to-clone-your-old-hard-drive-to-your-SSD-Mac/ta-p/112072
     
    Created a bootable 'Install OSX' USB key.

    http://lifehacker.com/how-to-create-an-os-x-mavericks-usb-installation-drive-1450280026
    http://forums.macrumors.com/showpost.php?p=18081307&postcount=3


    Put the SSD in a USB enclusure and attach.
    Boot to the USB by selecting it in System Preferences >> Startup Disk , then restarting.

    http://forums.crucial.com/t5/Solid-State-Drives-SSD-Knowledge/How-to-clone-your-old-hard-drive-to-your-SSD-Mac/ta-p/112072

    From the startup USB, run Disk Utility

    - Create a single Partition on the SSD formatted as Mac OS Extended (Journaled)

    - Use the Restore function to copy the main partition from the HDD to the partition on the SSD.  (Took 10 hours!)  It was not possible to select an entire Disk as the source or Destination.  I'll have to verify the Recovery Partition was copied over later.

    Verify successful transfer of 'hidden' partitions (Including the Recovery Partition)
    http://macs.about.com/od/usingyourmac/qt/Enable-Disk-Utilitys-Debug-Menu.htm

    Yes, the EFI and Recovery Partitions are there. Strangely, I didn't need to enable the DEBUG menu to see them.

    Enable TRIM
    http://www.nick-p.info/enabling-trim-on-a-new-ssd-on-os-x-mavericks/

    About This Mac > More Info > System Report. Then, scroll to the SATA/SATA Express section, and select your SSD. You should see a section called TRIM  and the answer should be YES








    Installed DriveDX to check Disk Health.  Everything OK and Good, but why is my SSD Lifetime already at 99.0%?

    Checked Samsung for Firmware updates.  Compared revision to what I see in System Report.  It looks like I've got the latest: EXT0BB6Q

    http://www.samsung.com/global/business/semiconductor/samsungssd/downloads.html 

    Initial Observations:

    Startup is faster.  Seems to take just as much time until the Desktop appears ... but once the Desktop is there ... everything is functional....no more waiting for pinwheels.

    The Machine does seem more responsive.  So far so good.  Time to turn it over to QA for the Minecraft test.

    Useful links:
    http://osxdaily.com/2013/02/06/how-to-run-gui-apps-as-root-in-mac-os-x/

    Securely erase an SSD
    https://discussions.apple.com/docs/DOC-5521