Check out our Angular Book Series.

How do I tell Jasmine to ignore a test?

Today I learned you can tell Jasmine to ignore a unit test. A normal unit test would be something like this:

it("True is True", () =>

When running a unit test file with this inside the test will run., You could comment it out if you wish, but that can get confusing for larger unit tests with embedded oomments. Instead you can use xit() instead of it():

xit("True is True", () =>

Now when you run your unit test, this test will be marked as viewed as pending and will not be run.

You can use the same thing to disable a full suite with describe():

xdescribe("Some Test Suite"()=>
it("True is True", () =>{

This is pretty handy, but something I overlooked when learning all about unit testing.

How to I make my Angular Component Styles global?

An awesome thing about building Angular components is that the styles you specify are 'local' to the component.

In normal HTML development, any style on the page can affect any other style. For example. If I add a style like this:

div {
border:1px solid red;

Every div in the site / application will have a solid red border. Check out a sample here.

If you build an Angular, component, and that style is only included in the application as part of the component, then only that component's div will given a solid color red border.

The reason for this is because Angular creates something they call a Shadow DOM. Under the hood it is some coding magic to conditionally apply styles only to the component in question, not to other components.

However, Angular allows us to change this behavior using something called ViewEncapsulation.

A default Angular component is like this:

selector: 'my-comp',
templateUrl: 'my-comp.component.html',
styles: [`my-comp.component.css`],
encapsulation: ViewEncapsulation.Emulated

The Emulated value means that Angular will simulate a Shadow DOM. This is considered safest because not all browsers support their own shadow DOM trees.

In most cases, I use this approach and leave out the encapsulation attribute. I like to have my styles encapsulated to a single component. But that is not required. There are two other options:

selector: 'my-comp',
templateUrl: 'my-comp.component.html',
styles: [`my-comp.component.css`],
encapsulation: ViewEncapsulation.Native

The Native property tells Angular to use the browsers Shadow DOM. In this case, styles are encapsulated just like they would be in the emulated approach. So, any styles in the my-com-componment.css file will affect all HTML elements globally.

To turn off style encapsulation complete, use the None value from the ViewEncapsulationclass:

selector: 'my-comp',
templateUrl: 'my-comp.component.html',
styles: [`my-comp.component.css`],
encapsulation: ViewEncapsulation.None

I'm working on my second super really big Angular application for a client, and it is giving me the opportunity to touch on areas I normally wouldn't.

Setting up Java and Jersey with IntelliJ

I put this video together about setting up Java and Jersey using IntelliJ. This demonstrates the project structure I used when writing the Learn With books on Java.

What is the difference between Boolean class and boolean primitive type in Java?

I was recently working on the Java code for the LearnWith series. The application behind the book is a Task Manager application and one of the features is the ability to filter tasks based on their completed state. The database field is a bit field, because a task can either be completed or not completed.

However, from a filtering perspective I need to accommodate for three different states: Completed, not Completed, and All Tasks. How do I handle that in Java?

A database bit column usually turns into a Boolean value in a programming language, and for that it works great. With Java the boolean primitive type is perfect for this. It can support values of true or false. However, boolean does not have an undefined or null state. It must always have a value.

To handle the UI filtering I had to use an instance of the Boolean class. Since it is a class it can be undefined or null. The final code was something like this:

if(BooleanVariable != null){
// do something to handle value
} else {
// do something to handle the null value

This stuff should be old hat if you have a lot of Java experience, but from someone who focuses on UI code over server side code, it made me pause for 10 seconds to figure it out.

How do I run ES6 JavaScript code on the console?

I've been following a tutorial on using Redux and the code in the sample is ES6 code. The tutorial ran the code in the debugger of Visual Studio Code, but me being an IntelliJ user could not find an parallel way to run the code.

I created an Index.html file that loaded the JS file, but nothing happened. I assume because the ES6 syntax used in the sample as not yet universal in the browser JS engines.

So, what next? I looked for a way to run the code at the console, and found one. With NodeJS installed:

node filename

That ran the code, and gave the same results that the tutorial got in the Visual Studio Code window. After doing that, I realized I could run the same thing in IntelliJ's terminal Window.

I'm not used to running advanced JS or TypeScript code w/o transpiling it with a tool like TypeScript, Webkit or the Angular CLI. This project started simpler, but I'm good to go now.

I hope this helps you!

Why can't IntelliJ find java.time with JDK 9?

I've been working on a a few projects that use the JDK 9 with IntelliJ. My latest started getting an error like this:

java package java.time does not exists
java cannot find symbol
symbol: class LocalDate

The LocalDate class was added to the JDK 8, so this error makes sense if you are building using an earlier version of JDK. But, I should not be seeing it when using JDK 9.

Googling on similar errors seems to bring me back to the same thing I already knew. You're using the wrong version of the JDK, be sure to upgrade to JDK 8 or later.

But, I am already using JDK 9, so should not be having this problem.

I spent an hour pouring over IntelliJ settings before stumbling onto this screen:

The Java Compiler target bytecode version of my project was set to 1.7 instead of 9. I already fixed that in the screenshot above. It made my errors go away immediately.

The most confusing thing is that I didn't have errors on any of the other projects.

What is Apache Royale?

A friend reached out to me to ask what I thought of Apache Royale and I thought it would make a good blog post.

What is Apache Royale?

Apache Royale is a rebrand of Apache Flex's FlexJS project. Royale would allow you to create HTML(5) applications with MXML and ActionScript. It is independent and separate from Adobe's Flash Platform.

There are a lot of 'legacy' Flex apps out there, so from that perspective it makes a lot of sense to allow a Flex Developer to repurpose their AS3 and MXML skills in order to build HTML5 applications with no reliance on the Flash Player or Adobe AIR. That is great.

Where do I fit in?

While I am still a PMC member of the Apache Flex project, I am not involved with Royale in any way. I haven't followed Apache Royale very closely, and am even less so since it was promoted to a top level Apache project, separate from Flex.

You can take my opinion and understanding with a grain of salt.

What do I think about Royale?

Despite the impressiveness of the technology, Royale does not allow you to convert a Flex application to an HTML5 application. It is expected you will create a new application from scratch. And since you're doing that regardless, why not use a technology that is more 'native' to HTML(5) development? Such technologies might be AngularJS or React.

I fear the target market of Royale--Flex Devs who want to build HTML5 applications--moved on many years ago.

The flip side of that is that HTML5 devs change their mind on the framework of choice every few years. They have embraced ActionScript-like things such as TypeScript and frameworks built with it such as Angular. These are clearly not as HTML5 'native' like AngularJS or React are.

Could the tide of interest swing back to ActionScript and MXML? I don't know.

Final Thoughts

While Apache Royale is a really cool project, I fear it is too little too late. I don't have any problems building HTML5 applications that would be solved by moving to a MXML / ActionScript solution. There are already other frameworks and tools for converting from ActionScript to JavaScript, but they have not gained a lot of traction. I see no reason why Royale would change that.

I do wish the team luck, they have some of the smartest people I had the privilege of knowing. For now I'm content building Angular applications to solve client problems.

How do I copy files with Maven?

Last week, I wrote about running a Gulp Script from Maven. The Gulp Script was located in a directory outside of the Java project.

This week I'll show you how to copy the file from the external directory into the Java project.

We're going to use the maven-resources-plugin to make this work.

First, set it up as a plugin in the Maven POM file:


This adds the artifactId--AKA the plugin name--and the version number. For each set of files we want to copy, we'll need to add an execution block, so start there:


This specifies the id of the copy, which is just a unique name for the process. It is done on the validation phase. And the goal is to copy-resources.

Before we end the execution block, we need to add the configuration. this will tell us what we are copying and where we are copying it too.


The outputDirectory specifies the location of the copied files. I made them relative tot he $(basedir), which is the root of the Java project. In the Angular 5 files in the A5 directory of the Java Project's webapp.

The source directory is listed under resources, resource.

Finally close off the open tags, which is the execution tag, the executions tag, and the plugin tag:


I'm using this approach to copy the results of an external Gulp script into the final WAR, so that the files will be surfable via the Tomcat instance.

It has been working great for me.

How do I run a Gulp Script in a different directory from Maven?

If you want to run a Gulp Script from Maven, you use the frontend plugin, right? Unfortunately, that seems to assume that the Gulp script is part of the Java project.

I'm creating a Java Backend to the LearnWith series and am sharing UI code between multiple backend technologies. As such, my directory structure is different and the UI code is not in the web root. I want to run a gulp script in a different directory, and then copy the results into the project's webapp directory. How do you do it?

I was able to do it with the exec Maven Plugin.

First, set up the plugin in the plugins portion of Maven POM:


The groupId, arftifactId, and version are specified. For each script you want to run you'll need an execution statement:

<id>Build Angular 5</id>

The id is a unique name for the build script. The phase is validate, because it is. The goal should be set to exec. The configuration is where the real magic happens. We tell it to execute the gulp command with the argument 'build', so this will run:

gulp build

We want to make sure that the script runs in the proper directory and that is specified with the workingDirectory tag. Presumably this directory will be outside the current directory structure.

Finally, close the plugin tag:


That's all you need to do to run an external Gulp Script from a Maven project. This assumes, of course, you have Gulp installed. Next week I'm going to write about copying the processed files into the Java project.

Why won't Jersey work on JDK 9?

I've been experimenting with writing REST Services in Java. A ton of clients have used Java to power their backend's over the years, but I never created a REST Service environment from scratch myself. I decided to tackle it during the holiday time and educate myself. I try to focus on front end programming technologies, but knowing about the backend is beneficial.

I decided to use Jersey to build out REST Services in Java and the road has been rocky.

I have a Maven project setup to use Tomcat 8.5 and Java 9.01. Unfortunately, I kept seeing a lot of errors like this in the Java console:

java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
    at org.jvnet.hk2.internal.SystemDescriptor.reify(
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor

etc.. etc..

or this:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.getAllMethods(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.getPreDestroyMethod(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.access$400(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl$2.compute(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl$2.compute(
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$
    at java.base/
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(

They went on and on. Basically, some libraries that are required by Jersey are no longer included as part of the Java 9 SDK. They were there in Java 8, but were removed. These errors exist because the libraries cannot be found.

The trick to remove these errors is to load these libraries using Maven. Find the pom.xml that builds your project and find the dependencies section. It will probably look something like this:

<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
<!-- uncomment this to get JSON support


We need to add back in the missing dependencies. There are two libraries that were required:


Relaunch your Tomcat instance and you are good to go. No errors and your Jersey services should work without issue.

More Entries

All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version