5 December 2016

Amazon Go: shops without checkout

Amazon Go is Amazon's new concept of a brick and mortar shop.
Here's the manual:

  1. walk in
  2. pick your stuff
  3. walk out

26 November 2016

IntelliJ IDEA 2016.3 released

Some highlights in the 2016.3 IntelliJ IDEA release:

  • When looking at source code the editor now adds hints that show all parameter names in method calls for literals and null being passed in.
  • The debugger now allows you to examine the heap
  • The Resource Bundle editor now shows you which properties are unused in the project. Handy if you have tons of properties!
  • Refactoring to ES6 constructs (let, class...)

16 November 2016

Android phones made in China come with spyware

China made android phones have been found to contain spyware that sends your data to the Chinese government.
The malware is part of pre-installed apps made by Shanghai Adups Technolog, supplying software to ZTE and Huawei. It was found on the low budget phones made by these companies for the USA BLU phone brand.

9 November 2016

Oracle and ANSI SQL

ISO SQL is a rather weak standard.
First you can not get it unless you pay for it, which is not a good thing if you want your standard to be succesful. You can find draft versions of the latest SQL 2011 on the web however.
Second there is no official independent compliance verification.

Appendix B of the Oracle Database SQL language reference gives a detailed overview of Oracle standard compliance.

In oracle you can set the FLAGGER variable, to verify whether your command complies with the standard. It only checks compliance with the ISO SQL/92 standard though:


Finally, here's a neat overview of compatibility of SQL statements for the most popular databases.

22 September 2016

Excel: sort text as a date

You'd think that setting the format of an excel cell to date is sufficient to have excel treat it as such, but alas that's not the case.
The easiest way to do this (better than the microsoft support tips) is on superuser: abuse data>text to columns, to let excel parse and store as a date.

18 August 2016

Cygwin ssh: Could not create directory '/home/myuser/.ssh'.

When first running ssh from cygwin 2.5.2, the .ssh directory to store trusted host keys could not be created.
ssh still works OK, but each time it prompts you to accept the host you are connecting to:

Could not create directory '/home/myuser/.ssh'.
The authenticity of host 'myserver (168.250.1.174)' can't be established.
ECDSA key fingerprint is SHA256:eSpqYAq2c7k843RfqpbpvK9F118XsKCArBdBheRN8c0.
Are you sure you want to continue connecting (yes/no)?
Reason is that ssh does not find your home directory. Easiest solution is to point it to your windows home directory. To do this, add this line to your_cygwin_install_dir\etc\nsswitch.conf file:

db_home: /%H

16 August 2016

Oracle Virtual box extensions install fails with VERR_ACCESS_DENIED due to McAfee

Installing Virtual Box 5.1.2 extensions on windows 10 failed with this error:

VBoxExtPackHelperApp.exe: error: Failed to rename the temporary directory to the final one: VERR_ACCESS_DENIED ('D:\Program Files\Oracle\VirtualBox\ExtensionPacks\Oracle_VM_VirtualBox_Extension_Pack-_-inst-4288' -> 'D:\Program Files\Oracle\VirtualBox\ExtensionPacks\Oracle_VM_VirtualBox_Extension_Pack')
After seeing several people on the net pointing to the antivirus, I disabled the McAfee real time virus scanning that came for 1 year with my Dell PC:
  1. Right click System Tray McAffee LiveSafeIcon
  2. Change Settings > Real Time Scanning
  3. Turn off
    1. Leave In 15 minutes
Then I reran the extensions installer and all went well.

12 August 2016

Oracle SQLDeveloper connection fails / TNS listener not starting

I had a problem today connecting to my Oracle express database from SQL Developer on Windows 10 with the error: The network adapter could not establish the connection.
Connection did work from SQL*PLUS (Run SQL Command line).
The OracleXETNSListener service was stopped in my services and restarting it did not work.
Turns out the problem was that I changed my computer name yesterday and the service does not use localhost, but the computername.
To solve this I changed the hostname in these files:
%ORACLE_HOME%\app\oracle\product\11.2.0\server\network\ADMIN\listener.ora
%ORACLE_HOME%\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora
Stopped/started the database and everything's fine.

Saw these alternate solutions (did not test):
solution 1: Add the old hostname to C:\Windows\System32\drivers\etc\hosts
solution 2:

SQL> alter system set LOCAL_LISTENER='(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' scope=both;
SQL> alter system register;


4 August 2016

SAP Hybris 6.1 released

Highlights:

  • Customer lists in assisted service module
    • Pick-Up In-Store Customers:
    • Current In-Store Customers:
    • My Recent Customer Session
  • B2C Accelerator: Save multiple carts for later 
  • Backoffice Solr search supported 
  • YAAS cloud: SAP hybris customer profiling
    • google analytics like events
    • order, account, session, product... events
    • API for mining the collected data

10 May 2016

JPA links (updated)

Reference implementation.

Official documentation:

Others:
Providers often have good JPA documentation as well. Might include extensions (and JDO stuff) though:

Specific topics:
Background:

    5 May 2016

    Callable ManagedTaskListener

      class Japavapa implements Callable, ManagedTask, ManagedTaskListener {
    
        String word;
        LocalTime submit;
    
        public Japavapa(String word) {
          this.word = word;
        }
    
        public String toString() {
          return ":P " + word;
        }
    
        @Override
        public String call() throws Exception {
          Random rand = new Random();
          Thread.currentThread().sleep(rand.nextInt(1000));
          Matcher match = Pattern.compile("([AEIOUYaeiouy]+)").matcher(word);
          return match.find() ? match.replaceAll(match.group(1) + "p" + match.group(1)) : word;
        }
    
        @Override
        public ManagedTaskListener getManagedTaskListener() {
          return this;
        }
    
        @Override
        public Map<String, String> getExecutionProperties() {
          return null;
        }
    
        @Override
        public void taskSubmitted(Future<?> future, ManagedExecutorService executor, Object task) {
          submit = LocalTime.now();
          logger.info("SUBMIT " + task
            + " AT " + submit 
            + " ON " + executor);
        }
    
        @Override
        public void taskAborted(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
          logger.info("ABORTED " + task
            + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis()
            + "ms ON " + Thread.currentThread().getName());
        }
    
        @Override
        public void taskDone(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
          logger.info("DONE " + task
            + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis() + "ms");
        }
    
        @Override
        public void taskStarting(Future<?> future, ManagedExecutorService executor, Object task) {
          logger.info("STARTING " + task
            + " AFTER " + Duration.between(submit, LocalTime.now()).toMillis()
            + "ms ON " + Thread.currentThread().getName());
        }
    
      }
    

    27 April 2016

    NetBeans hints (edit)

    Your first NetBeans project
    1. On the start page click the Learn & Discover tab
    2. Under Demo's and Tutorials select Java SE applications
    3. Start the Java Quick Start Tutorial 
    NetBeans 7.4 Developer Guide
    If you're searching how to do someting in netbeans just type it in the ... search box, it will not only search in your project,  but also in the online help.
    Keyboard shortcuts
    • view, search & change shortcuts: tools => options => keymap
      • You can set the keymap to a profile from another IDE (Eclipse, IntelliJ...) here as well.
    • help => keyboard shortcuts card. The pdf that is shown, lives in
      netbeansInstallDir
      /nb/shortcuts.pdf. 
    • Some additional useful shortcuts:
      • Go to
        • to definition: CTRL click
          • to implementation: CTRL ALT click
      • Edit
        • Code completion
          • autocomplete popup (+ javadoc): CTRL SPACE
          • javadoc inline popup: CTRL SHIFT SPACE
            • ALT F1 to see in browse
            • Netbeans bundles plenty of javadoc you can browse supplied javadoc for your project libraries from help>Javadoc references
          • complete to recently typed word: CTRL k
        • Add semicolon at end of line:  CTRL ;
        • Add new line below + go there: SHIFT ENTER
      • View
        • fold/unfold code: CTRL –/+
        • members/herarchy of current selection: CTRL/ALT SHIFT F12
        • zoom: ALT + mousewheel up/down 
        • editor only: CTRL SHIFT ENTER (>= 7.4)
    Running code
    • After you ran a program, and corrected some errors Rerun using the >> buttons.

    • The lighter double arrows below allow you to rerun with different parameters. You can change the arguments you run with in the Ant properties window.
     
    • Similar options are available for (individual) tests.
      • You can also launch an individual test by  positioning the cursor in the method and selecting "Run focused test" from the right click menu. 


    Samples
    Netbeans comes with plenty of sample projects for you to explore

    HTTP Monitor

    The server side monitor is enabled by default for Tomcat and can be enabled in the properties of GlassFish. You may have to undeploy/redeploy your webapp for the monitor to show up.
    When the server receives an HTTP request, NetBeans will show a window with all request details. It extracts all parameters and stuff for you, but does not show the raw bodies of POST requests. It does not show responses either.
    There is also a client monitor. If you use the internal browser (or the NetBeans Chrome plugin) you can use Window > Web > Network Monitor (NetBeans >= 7.4). It does not show all client side traffic but is targeted at in-page initiated traffic (AJAX, websockets) and failed requests.

    19 April 2016

    Java EE Patterns (edit)


    • Numbers on the arrows indicate a possible call sequence in a request.
    • patterns
      • Front Controller: initial point of contact for handling all related requests. The Front Controller centralizes control logic that might otherwise be duplicated, and manages the key request handling activities.
      • Transfer Object: carries multiple data elements across a tier
      • Transfer Object Assembler:  builds an application model as a composite Transfer Object. The Transfer Object Assembler aggregates multiple Transfer Objects from various business components and services, and returns it to the client. 
      • Persistent Domain Object: Rich domain object, ie. having rich behavior/bus.logic and persistent 
      • Web Service Broker: exposes and brokers one or more services using XML and web protocols.
        • The Web Service Broker can be generalised to a Protocol Broker.
      • Service Facade: encapsulates business-tier components and exposes a coarse-grained service to remote clients. Clients access a Service Façade instead of accessing business components directly. 
      • Service: Fine-grained, reusable logic in an EJB with local access only, product of decomposition
      • Data Access Object: abstracts and encapsulates all access to the persistent store. The Data Access Object manages the connection with the data source to obtain and store data. 
      • Asynchronous Resource Integrator: Invocation of a Service from a Message-Driven Bean (invoked by a messaging system via JMS)
      • Payload extractor: factor out the (reusable) type checking and error handling for a MDB message into a reusable interceptor; poison messages moved by the interceptor to a “dead letter queue” via a stateless EJB using the JMS API
      • Resource Binder: put a custom resource into JNDI using a @Singleton with @Startup and the JNDI API (Context.(re)bind()).

    10 March 2016

    SoapUI XPath assert needs namespaces

    If you are testing XML documents without namesapces, and you assert them with XPath expressions without namespaces, your XPath expressions (e.g. '//my-stuff') will not match.

    An easy trick to make this work, is to add  '*:' (wildcard) namespace in front of your elements (e.g. '*://my-stuff')

    SoapUI C:\WINDOWS\system32\config\systemprofile\soapui-settings.xml (Access is denied)

    I installed SoapUI open source 5.2.1 on windows10 from the (default) windows 64 bit installer.

    This installation considers C:\WINDOWS\system32\config\systemprofile as the home directory and insists on keeping his config there. Probably because it asks system administrators priviliges while installing and then derives the home directory from the system administor settings. When running SoapUI as your humble self afterwards and try to change any preferences you get

    java.io.FileNotFoundException: C:\WINDOWS\system32\config\systemprofile\soapui-settings.xml (Access is denied)
     Uninstall and reinstall from the zip installer (from alternate platforms downloads). That one works from your user home directory as it should.

    23 February 2016

    OU Webservices Practice 5.1 alternative

    To use the Glassfish JAXB RI instead of the default Eclipse MOXy implementation in Weblogic 12.1.1 add this to the beginning of your %DOMAIN_HOME%\bin\setDomainEnv.cmd. %MW_HOME% is set to the installation location of WebLogic.

    if NOT "%PRE_CLASSPATH%"=="" (set PRE_CLASSPATH=;%PRE_CLASSPATH%)
    set PRE_CLASSPATH=%MW_HOME%\modules\databinding.override_1.0.0.0.jar%PRE_CLASSPATH%


    On Weblogic 12.2.1 you should use WL_HOME (=%MW_HOME%\wlserver) instead of MW_HOME.

    21 February 2016

    Link Blogger to Google Drive

    Blogger supports including images from Picassa, but when you include an image as a share link from Google drive, this seems to work initially, but the converted link does not work anymore after a while. So, you end up, saving your images twice in google storage.
    Here's a post on converting a Google Drive link for usage with Blogger.

    20 February 2016

    OU Webservices Excercises Module 13: JAX-WS only

     Exercise 13-1

    1. Generate SSL artefacts
      • Edit certgen.bat (do not double click). Adapt the paths at the top of the file to reflect the correct paths on your machine.
        • The individual steps that are executed by the script are explained in Practice A-2
      • Run the script from the command line
    2. Configure WebLogic for WS-Security
      • Edit sslconfig.bat (do not double click). Adapt the paths at the top of the file to reflect the correct paths on your machine.
      • Edit sslconfig.py.  Adapt the paths at the top of the file to reflect the correct paths on your machine.
        • The script uses the WebLogic Scripting Tool (WLST). The  same procedure using the administration Console is explained in Practice A-3. 
      • If WebLogic is not running, start it.
      • run sslconfig.bat from the command line 
      • The script stops WebLogic. Start it again afterwards.
      • Connect to the WebLogic Admin Console over SSL, using URL https://localhost:7002/console
        • The browser warns you because it does not know the certificate authority
          •  Verify the certificate
          • Approve the connection
    3. Open theCardDecksWS project
    4. If you did not enable JAX-WS HTTP dumping in Excercise 5-7, do it now.
    5. Add a new library to NetBeans using Tools> Ant Libraries
      • Create a new library
        • Name: WebLogic Web Services API
        • Type:  Server Libraries
      • Press Add JAR/Folder, browse to the WebLogic folder and add modules/ws.api_2.0.0.0.jar
      • Click OK   
    6. Add the "WebLogic Web Services API" library to the CardDecksWS project
    7. View the policy file you will use
      • Expand Libraries> Oracle WebLogic Server> weblogic.jar> weblogic.wsee.policy.runtime
      • Double click Wssp1.2-2007-Wss1.1-UsernameToken-Plain-X509-Basic256.xml 
      • Examine the file
      • Close the file
    8. Open ejbs.CardDeckSessionBean.java
    9. Annotate the class with @Policy to 
      • use the policy you have just viewed 
      • add it to the WSDL
    10. Using the @Policies and   @Policy annotation on every method indicate that
      • webservice calls should be signed
      • webservice calls should be encrypted
      •  this should be added to the WSDL
    11. Correct any errors and save
    12. View the WSDL at http://localhost:7001/CardDeckSessionBean/CardDeckSessionBeanService?wsdl
      •  Notice the wsp1_2:Policy elements that have been added
    13. Open the GenericCardGameWS project in NetBeans
    14. Open games.CardGameService
    15. After the creation of the port in the createCardGame method, add code to use WS-Security, as shown in slides 13-17 to 13-19
    16. Refresh the JAX-WS artefacts and cached WSDL
      • In the Web Service References Node, right click the CardDeckSessionBeanService and choose Refresh
      • Select the checkbox to also replace the WSDL
      • Click Yes
    17. Correct any errors and save
      •  Clear the WebLogic Server Output window (right click>clear)
    18. Open the Weblogic Test Client at http://localhost:7001/wls_utc
    19. Enter WSDL http://localhost:7001/GenericCardGameWS/CardGameService?wsdl
      • Create a cardGame with 1 deck and 2 jokers
      • Inspect the SOAP messages
        • View the Oracle WebLogic Server output window in NetBeans
        • Compare the calls to Try to see the difference between the calls to 
          • CardGameService
          • CardDeckSessionBeanService

     Exercise 13-2

    1. Check the time between the first and last message in a call in the previous exercise
    2. In the CardGameService class, modify the usage of the CarDeckSessionBeanService. Apply the same kind of optimisations on the service as in step 2 in the activity guide.
    3. Apply the same kind of optimisations on the CarDeckSessionBean port as in step 3 in the activity guide
    4. Correct errors and save. 
    5. Check the time again between the calls when creating a card game.

    19 February 2016

    WebLogic 12.1.2 zip install: terminalio to read the password securely is not found


    My WebLogic 12.1.2 install from the zip distribution aborted after asking for the domain admin user with the error message:

    Native Library(terminalio) to read the password securely from commandline is not found
    It appears that this is a different symptom of the same error I had working with Weblogic 12.1.1: the native libraries delivered with WebLogic are not in the PATH. My system is a 64 bit windows system, so i need to add the libraries for this platform to avoid this error.
    I added one line to %WL_HOME%\wlserver\server\bin\setWLSEnv.cmd
    set WL_HOME=C:\wl12120
    @REM added the next line
    set PATH=%WL_HOME%\server\native\win\x64;%PATH%
    If you do this, the installation and the configuration of a default domain run smoothly. As explained in my previous post, after the domain creation, also add this line to the domain envionment setup file %domain_dir\bin\setDomainEnv.cmd. If you don't you'll get warnings about Weblogic reverting to less efficient file reading libraries etc.

    13 February 2016

    Oracle SQL info

    • Oracle 11g SQL reference
    • SQL developer keboard shortcuts
      •  Tools>preferences>shortcut keys
      • CTRL+SHIFT+D: copy current line down
    • Changing the password
      •  change it in the database
    alter user user_name identified by "new_password" replace "old_password"

    8 February 2016

    JPA CriteriaQuery call structure

    The sequence of calls and the objects involved in a CriteriaQuery is complex at first. 
    CriteriaQuery uses a fluid builder patters which mimics the structure of a JPQL/SQL query. I highlighted the creation of the parameters and the calls in which they are used.
    The parameters are not exactly those in the API, i oversimplified to give an idea of the general structure of a criteria query.


    UMLet UML drawing & scripting (edit)

    UMLet is a basic free and open source drawing tool for UML diagrams. It is witten in java and comes in a standalone version, an eclipse plugin and a web hosted edition (UMLetino). In the market of UML tools (cfr. an earlier blog on Astah) it has a unique take on modelling.

    First it is a drawing tool. Real UML tools try to have one model for which each diagram gives a different, but consistent perspective. UMLet just lets you draw and link UML components. But it does not assist you in UML syntax or consistency. Neither does it have any code or documentation generation features as the higher end tools have.
    The advantage is that UMLet does not have the overhead of defining the model behind the diagram. Also it does never get in the way when you want to do something that is not supported by UML or your tool.

    Second where you expect a drawing tool to be targeted on a strong, intuitive, graphic and interactive user interface, each element in UMLet is backed by a notepad like text specification. You draw your diagrams, elements and connections using a point and click interface. Modifiying elements, changing style and appearance, adding details is done in one associated text box. The text language is compact and simple.  This makes UMLet a very geeky tool. Sometimes you have to compose elements, like sequence diagram lifelines, from several subparts. On the other hand, you never have to wade through a hierarhy of interactions dialogues to fill in all characteristic of an element you have definied.

    Once you get the knack of it, the speed of working with UMLet is matched by few other tools.It is a good fit for taking agile modeling  beyond the whiteboard. You can easily extend the toolboxes with elements or create your own. The tool is best used on small modeling efforts, as, being a drawing tool, different diagrams representing the same element will not automatically remain in sync.

    The default toolboxes do not have all UML elements and are are a bit sloppy in UML syntax. As you can easliy modify and expand the toolboxes, this can be amended, but there is a risk that UML newbies pick up bad UML manners from the tool:

    • uses <<includes>>, <<extends>> instead of <<include>>, <<extend>>
    • synchronous messages  in sequence diagrams do not have a filled arrow head
    • return arrows in sequence diagrams do not have a dashed line
    • no found message in sequence diagram 
    • no * cardinality as in the UML standard 
    There is a set of "all in one" diagrams that present entire diagrams as one element that you can configure by editing the properties. I did not find any way to interact with them graphically. You are really scripting your diagram in text, like in the LaTeX days of text processors.

    Here's a nice intro video.

    2 February 2016

    Java plugin deprecated in Java9

    With Java9 the java web plugin will be discontinued. Browsers like Microsoft Edge are removing plugin support, so this is a logical step.
    Java's origins are in embedded execution, running applets in the browser, using the plugin.
    Oracle has a whitepaper with migration options.

    23 January 2016

    Installing webLogic 12.2.1 (12cR2)

    I installed WebLogic 12c on windows 10 last week and it was pretty smooth.
    I went to the download page and downloaded the generic distribution.
    There's a link to an install manual right below the download.
    I downloaded the zip an unpacked it to a jar of the same size :-/
    Some points of attention now

    • start  a cmd window as administrator
    • make sure to use java from the JDK. If Java from JRE is in your path first this does not work
    • Start the Oracle Universal Installer GUI as in the documentation, it will first check if your platform meets the requirements:
    > java -jar fmw_12.2.1.0.0_wls.jar

    Checking if CPU speed is above 300 MHz.   ...Passed

    Checking monitor: must be configured to display at least 256 colors.   ...Passed

    Checking swap space: must be greater than 512 MB    ...Passed

    Checking if this platform requires a 64-bit JVM.   Actual 32    Passed (64-bit not required)
    During the install you can choose to install WebLogic, Coherence or both.
    Just answered the basic questions and clicked finish when installation was done.
    In the log file after install (C:\Program Files\Oracle\Inventory\logs) I find a few throwables from patch installations, but nothing worrying.
    Maybe you have to explicitly click the "installation complete" menu item, because after I clicked finished the cofiguration wizardfor setting up a domain did not fire. In my cmd tool I went to %WL_HOME%\oracle_common\common\bin (in earlier releases this is %WL_HOME%\wlserver\common\bin) and ran
    > config.cmd
    This launches the domain create/update GUI, another easy sequence of steps.
    You can always return here, if after the installation you want to add additional templates to your installation:

    At the end you get a link to the admin console at http://localhost:7001/console.

    These days WebLogic by default starts DerbyDB, and I already have that from my Java EE installation, so I disabled that by editing my_domain\bin\setDomainEnv.cmd. Look for the DERBY_FLAG in this file and set it to false:

    @REM Set DERBY_FLAG, if derby is available.

    if "%DERBY_FLAG%"=="" (
        if exist %WL_HOME%\common\derby\lib\derby.jar (
            set DERBY_FLAG=true
        )
    )




    20 January 2016

    windows 10: easy PATH editing

    In windows 10 Microsoft has finally provided an update for the PATH setting mechanism that must have been around since the earliest versions of windows I remember (windows 3?).
    In those versions you had a one line input box of about 30 characters for setting a path that could be hundreds of characters long. Now they have provided an easier tool, although it is harder to find :).
    From the start menu, go to:

    Settings > System > About > Advanced System Settings > Environment Variables

    Alternatively, use the search in the task bar:


    When editing the Path System variable, you get a list editor for the entries (instead of the semicolon separated list inherited from Unix). For editing an entry you have an optional directory browser.


    8 January 2016

    Flaws in OAuth protocol

    A formal scientific analysis of the principles and mechanisms underlying OAuth 2.0 has been published. Two weaknesses have been identified. The rest of the protocol has been formally recognised as sound and secure. The weaknesses are

    • allowing HTTP Temporary redirect (status 307), which can cause a browser to disclose sensitive information to a malicious Resource Server
    • an attack on the Resource Server, tricking it to rely on a malicious Identity Provider (possibly using OpenId)
     
    No exploits on these weaknesses are currently known to exist in the wild and the authors have proposed solutions for the vulnerabilities, which are being adopted by the working groups for OAuth and OpenID Connect.