mvn eclipse:eclipse – Cant canonicalize system path: {0}

While restructuring a maven project I began getting this error when running mvn eclipse:eclipse.

[INFO] Final Memory: 19M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-eclipse-plugin:2.9:eclipse (default-cli) on project odlp-client:
Cant canonicalize system path: {0}: The filename, directory name, or volume label syntax is incorrect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

I searched for a resolution and the posts that I found having similar issues recommended removing ${project.basedir} from any paths and use a relative path instead.

<resources>
   <resource>
   <!-- Include handlechain.xml and others. -->
   <directory>${project.basedir}/src/main/resources</directory>
   <includes>
      <include>**/*.xml</include>
      <include>**/*.properties</include>
      <include>**/*.jks</include>
      <include>**/*.vm</include> 
   </includes>
   </resource>
</resources>

Unfortunately, this did not solve my problem. Only one project was getting this error.

I tried mvn eclipse:eclipse -X That did give me more info but not enough to point to the culprit. After some more digging I found this problem was with a cxf plugin.

<plugin>     
<groupId>org.apache.cxf</groupId>     
<artifactId>cxf-codegen-plugin</artifactId>     
<version>2.7.7</version>
...
</plugin>

Changing the version from 2.7.7 to 2.7.10 resolved the issue.

Ready for your next Java Interview?

Are you a java developer or java architect thinking about a move?  Are you ready for your java screening interview?  You might want to consider a quick refresher.  Here is a list of screening questions that you might be asked.

What are the java class access level modifiers?

  • Hint: There are four access levels and three access modifiers:
    public, private, protected
  • Note package is the default access level; package is not a modifier.
  • package ClassName {} // not valid

What is the difference between Integer vs int?

  • Hint: int is a primitive (like byte, char, double, etc).
    Integer is a immutable (can’t change) wrapper object.
    Wrapper objects are used to represent the primitives when an object is required.

Is Java “pass by value” or “pass by reference”?

  • Hint: It’s “Pass by Value”.
  • You have primitive variables and object variables.  But when used as an argument a “copy” of the variable “value” is used.  For primitives, this will be the actual value (i.e. for a variable holding an int the value may be 1,2,3,…).  However, objects variables are a bit different because they don’t contain the object they contain a “reference” to the object. Either way, remember it is a copy of variable that is used as an argument – either the primitive value or the reference object value.

Explain the difference between == vs .equals and which would you used to compare two strings?

  • The double equals compares variable values.  Remember, that variables can hold primitive values OR reference values (i.e. pointer to an object). “==” is used to determine if the variable values are the same (equal).
    • If you are comparing two char variables, then you are comparing the primitive char values.
    • If you are comparing two String variables with “==”, then you are comparing the reference values (i.e. are the two variable pointing to the same object (String).
  • If you use “==” on two object variables then your are testing if both variables contain the same object reference value.  The key point here is that the “==” should not be used to test equality on different objects. When different objects are expected then use .equals().
  • The implementation of .equals() will vary from object to object.  If you are creating a new class you must define what equality is by overriding the Object.equals().  If you don’t override .equals then the default “==” is used.
  • To determine if two different objects contain the same string use .equals.
  • Beware of the object interning caveat where it seems like you have two distinct objects but in actuality both objects are using cached objects.

What is the difference between String and StringBuffer?

  • In java, String is an immutable object. You can’t change it!  StringBuffer is not immutable.  When you concatenate two strings like  “A” + “B” you are actually creating new String objects.  In addition, you are also using StringBuffer to do this concatenation.

What is the replacement for StringBuffer?

  • Java 1.5 introduced StringBuilder as a replacement for StringBuffer where synchronization is not required.

Explain the difference between Override vs Overload Java Collections

  • Hint: Overloading will have different method signature.
    Overriding will have same signature.
  • Question: Is the return type part of the method signature?
    No, the return type is not considered as part of the method signature.

What are the Collection Interfaces?

  • Hint: Collection (base), Set, Sorted Set, List, Queue, Deque, Map, Sorted Map.

What are the Collection Implementations

  • Hint: HashSet, TreeSet, LinkedHashSet, ArrayList, LinkedList, ArrayDeque, LinkedList, HashMap, TreeMap, LinkedHashMap

What is .iterator?  – Why use .iterator over for loop?

  •  An  Iterator is an object that enables you to traverse through a collection and to remove elements from the collection selectively, if desired. You get an Iterator for a collection by calling its iterator method.

What is synchronization wrt Java?

  • Hint: Threads communicate primarily by sharing access to objects reference. This form of communication is extremely efficient, but makes two kinds of errors possible: thread interference and memory consistency errors. The tool needed to prevent these errors is synchronization.

What is lazy loading?

  • Hint: Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program’s operation if properly and appropriately used. The opposite of lazy loading is eager loading.

What is autoboxing?

  • Hint: Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes. For example, converting an int to an Integer, a double to a Double, and so on. If the conversion goes the other way, this is called unboxing.

Name one thing new in Java 7?

  • Hint:  Here are a two new things.
    • Strings in Switch Statements
    • Use of diamond <> to infer types.  List<String> myString = new ArrayList<>();

Discuss Java Memory?

  • Hint: JVM manages memory including Heap, Stack, Code, Stack
    • Heap is where your objects are maintained
    • Stack is where your methods, local, and reference variables are maintained
    • Code is your program byte code
    • Static is where your static data and methods are maintained

What is Encapsulation?

  • Hint: Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.
  • Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.
  • Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface.
  • The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.
  • In short, it’s a Java Bean that hides the data implementation and exposes data access via accessor methods.

Explain Abstraction

  • Hint: Abstraction refers to the ability to make a class abstract in OOP. An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.If a class is abstract and cannot be instantiated, the class does not have much use unless it is subclassed. This is typically how abstract classes come about during the design phase. A parent class contains the common functionality of a collection of child classes, but the parent class itself is too abstract to be used on its own.

Explain Inheritance:

  • Hint: Inheritance can be defined as the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.
  • When we talk about inheritance the most commonly used keyword would be extends and implements. These words would determine whether one object IS-A type of another. By using these keywords we can make one object acquire the properties of another object.
  • In Java, you have super class (i.e. base class) and a sub class (extended class).  The sub class inherits the data and behavior of the super class.  It can override (or change) the behavior for each exposed subclass method that is not marked final.

Explain Polymorphism:

  • Hint: Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
  • Any java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.
  • It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared the type of a reference variable cannot be changed.
  • The reference variable can be reassigned to other objects provided that it is not declared final. The type of the reference variable would determine the methods that it can invoke on the object.
  • A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface type.

What is a pattern?

  • Hint: Design Patterns are best practices how to solve common known problems.  In short, don’t recreate the wheel.  A patterns can be for common generic problems or patterns can also be specific for your organization.  The key is that the pattern is a solution template for an already know problem.
  • Design patterns are proven solutions approaches to specific problems. A design pattern is not a framework and is not directly deployed via code. Design Pattern have two main usages:
    • Common language for developers: They provide developers a  common language for certain problems. For example if a developer tells another developer that he is using a Singleton, the another developer (should) know exactly what this means.
    • Capture good practices: Design patterns capture solutions                        which have been successfully applied to problems.
  • Design pattern are based on the base principles of object orientated design.
    • Program to an interface not an implementation
    • Favor object composition over inheritance
  • Design Patterns can be divided into groups like:
    • Creational Patterns – i.e. Object Creation – Example Singleton Pattern
    • Structural Patterns – i.e. Define Object Relationships – Example Façade Pattern.
    • Behavioral Patterns – i.e. Define Object Communication – Strategy Pattern

What is Big O?

  • Hint – Be careful….
    The Big-O notation is used for describing algorithm performance, scalability, execution and complexity factors.

What is JSP?

  • Hint: Java Server Pages.  JSP is just a servlet but in text form that mixes html and JSP elements.  There are a number of implicit objects that can be accessed in the JSP “text” page.  These include:
    • request
      • This is the HttpServletRequest object associated with the request.
    • response
      • This is the HttpServletResponse object associated with the response to the client.
    • config
      • This is the ServletConfig object associated with the page.
    • pageContext
      • This encapsulates use of server-specific features like higher performance JspWriters.
    • session
      • This is the HttpSession object associated with the request.
    • application
      • This is the ServletContext object associated with application context.
    • out
      • This is the PrintWriter object used to send output to the client.
    • page
      • This is simply a synonym for this, and is used to call the methods defined by the translated servlet class.

What is a JSP Scriptlet?

  • Hint: Scriplets are just java code fragments embedded in a JSP text file that are added to servlet.  <% String title = “This is the Title Page”; %>

Explain the difference between forward and redirect

  • A Controller (in this context, an implementation of HttpServlet) may perform either a forward or a redirect operation at the end of processing a request. It’s important to understand the  difference between these two cases, in particular with respect to browser reloads  of web pages.
    • Forward
      • a forward is performed internally by the servlet
      • the browser is completely unaware that it has taken place, so its original URL remains intact
      • any browser reload of the resulting page will simple repeat the original request, with the original URL
    • Redirect
      • a redirect is a two step process, where the web application instructs the browser to fetch a second URL, which differs from the original
      • a browser reload of the second URL will not repeat the original request, but will rather fetch the second URL
      • redirect is marginally slower than a forward, since it requires two browser requests, not one
      • objects placed in the original request scope are not available to the second request
  • In general, a forward should be used if the operation can be safely repeated upon  a browser reload of the resulting web page; otherwise, redirect must be used.  Typically, if the operation performs an edit on the datastore, then a redirect, not a forward, is required. This is simply to avoid the possibility of inadvertently duplicating an edit to the database.

What is ORM?

  • Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages.
  • Consider the use of JDBC and the accompanying resultset.  ORM abstracts all of the mapping between the result set and the java objects (in the case of Java).  ORM allows java developers to work with data objects just like java objects.
  • JPA or Java Persistence API defines the java specification for ORM.
  • Hibernate and Toplink are ORM implementations.

WRT database, what is a statement, prepared statement, and callable statement?  

  • Use for general-purpose access to your database. Useful when you are using static SQL statements at runtime. The Statement interface cannot accept parameters.  These statements must be compiled (or “prepared”) each time they are used.
  • Use when you plan to use the SQL statements many times. The PreparedStatement interface accepts input parameters at runtime. A prepared statement is similar to a statement but is pre-compiled and therefore more efficient.
  • Use when you want to access database stored procedures. The CallableStatement interface can also accept runtime input parameters.

Other than performance, why use a prepared statement?

  • Prepared statements don’t allow the original statement to be modified by invalid or malicious attacks.
  • Consider a statement like:
    “Select * from names where nameID = ” + id + “/””
    Now what would happen if nameVar was set to:
    String nameVar = 1; drop table names;””Select * from names where nameID = ” + id + “1; drop table names;”

What is deadlock?

  • Hint: A deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does.

What is a mock object?

  • Hint: In a unit test, mock objects can simulate the behavior of complex, real (non-mock) objects and are therefore useful when a real object is impractical or impossible to incorporate into a unit test. If an object has any of the following characteristics, it may be useful to use a mock object in its place:

What is dependency injection?

  • Hint: Dependency injection is a software design pattern that allows the removal of hard-coded dependencies and makes it possible to change them, whether at run-time or compile-time.[1] This can be used, for example, as a simple way to load plugins dynamically or to choose stubs or mock objects in test environments vs. real objects in production environments. This software design pattern injects the depended-on element (object or value, etc.) to the destination automatically by knowing the requirement of the of the destination. Another pattern, called dependency lookup, is a regular process and reverse process to dependency injection.
  • Similar IOC – Inversion of Control – Spring.

What is Autowire?

  • You can allow Spring to resolve collaborators (other beans) automatically for your bean by inspecting the contents of the ApplicationContext.
  • Autowiring has the following advantages:
    • Autowiring can significantly reduce the need to specify properties or constructor arguments. (Other mechanisms such as a bean template discussed elsewhere in this chapter are also valuable in this regard.)
    • Autowiring can update a configuration as your objects evolve. For example, if you need to add a dependency to a class, that dependency can be satisfied automatically without you needing to modify the configuration. Thus autowiring can be especially useful during development, without negating the option of switching to explicit wiring when the code base becomes more stable.