- JSR 356 (part of Java EE7)
- Spring Boot
- Apache Spark microservices framework
29 November 2018
Websocket examples
Websocket examples using
27 November 2018
GDPR compliance of dominant IT consumer platforms

24 November 2018
Refactoring 2nd Edition released
After 19 years the second edition of Martin Fowler's refactoring book sees print.
Here's an overview of the changes.
Here's an overview of the changes.
IntelliJ multiline TODO comments
After 8 years and +300 votes this feature has been implemented in the 2018.3 edition of JetBrains IntelliJ
21 November 2018
Java & XML resources (updated)
- Tutorialspoint
- XML Schema Definition (xsd)
- Netbeans
- Schema Editor plugin
- XPath plugin
- start from Window>XPath
- Notepad++ XML tools plugin
- validation
- XSL
- XPath
- More XML tools
- JAXP project
- JAXP 1.3 (Java 5) validator package javadoc
16 November 2018
Spring Data Release train names
The spring data release trains are named after famous computer scientists, some of them living! The release train is a bundle of recent compatibe Spring Data subprojects (JPA, Redis, MongoDB, Solr, REST...). Basically they all refer to the same Spring Data Commons version. The names are ordered alphabetically, clearly inspired by Android's alphabetically ordered releases named after candy, Here's the list up to this day:
2013-02: Arora
2014-02: Babbage
2014-03: Codd
2014-05: Dijkstra
2014-09: Evans
2015-03: Fowler
2015-09: Gosling
2016-04: Hopper
2017-01: Ingalls
2017-10: Kay
2018-09: Lovelace
2019-10 : Moore
: Neumann
2013-02: Arora
2014-02: Babbage
2014-03: Codd
2014-05: Dijkstra
2014-09: Evans
2015-03: Fowler
2015-09: Gosling
2016-04: Hopper
2017-01: Ingalls
2017-10: Kay
2018-09: Lovelace
2019-10 : Moore
: Neumann
9 November 2018
WSDL 1.1 <definitions> and Java mapping (updated)
- All wsdl:xxx elements are direct children of <wsdl:definitions>.
- Composition indicates XML child elements
- Attributes indicate XML attributes
- Relations are attributes referring to the name of other elements
7 November 2018
MS Office and Google Drive File Stream: Safe to edit
Google drive file stream is now adding an real-time presence to your Microsoft Office documents.
In the bottom right corner of your documents you see a Safe to edit message to indicate no one else is working in the file.
You will also see who is editing and be able to merge after simultaneous editing.
You need to have the Drive File Stream Client installed for this feature to be active. Google is doing this without any Office plugin. When you launch the office document from your synced drive the Drive Client monitors it and displays the messages on top. Nice work Google!
In the bottom right corner of your documents you see a Safe to edit message to indicate no one else is working in the file.
You will also see who is editing and be able to merge after simultaneous editing.
You need to have the Drive File Stream Client installed for this feature to be active. Google is doing this without any Office plugin. When you launch the office document from your synced drive the Drive Client monitors it and displays the messages on top. Nice work Google!
5 November 2018
Spring Web Flow and Spring Boot DevTools problem: SpelEvaluationException: EL1004E: Method call:cannot be found
When calling a method with arguments using the <evaluate> tag in a spring webflow XML definition I get the error SpelEvaluationException: EL1004E: Method call: xxx cannot be found.
I am using Spring Boot Devtools for automatic server restart upon changes.
The embedded LiveReload server uses two classloaders, and thinks the the classes of the parameters supplied by spel in the XML are different from the (same) classes in your Java code.
Hence the method is not found, and an exception is thrown.
Possible Solutions:
I am using Spring Boot Devtools for automatic server restart upon changes.
The embedded LiveReload server uses two classloaders, and thinks the the classes of the parameters supplied by spel in the XML are different from the (same) classes in your Java code.
Hence the method is not found, and an exception is thrown.
Possible Solutions:
- Do not use Spring Boot Devtools for Spring Web Flow projects
- Follow the guidance in the description of the bug
3 November 2018
25 October 2018
Powerpoint zoom notes text
Sometimes I work in a powerpoint where the text in the notes view is too small or too big.
Setting the font size does nothing.
Moving the zoom slider does nothing (I wish Microsoft would fix this).
The solution: while positioning your cursor in the notes pane, you have to select the View > Zoom menu, that one works.
Setting the font size does nothing.
Moving the zoom slider does nothing (I wish Microsoft would fix this).
The solution: while positioning your cursor in the notes pane, you have to select the View > Zoom menu, that one works.
23 October 2018
8 September 2018
Saving powerpoint as PDF loses image transparency (solved)
When you save a powerpoint as PDF, transparent parts of images (e.g. png) appear as black regions in the PDF.
The solution?
The solution?
- When in the Save as... diaglog you select Browse, an explorer window pops up
- Choose Save as type: PDF (*.pdf)
- An Options... button appears. Click this button.
- At the bottom of the window uncheck PDF/A compliant
7 September 2018
Using MS Word master / sub documents feature
There are two kinds of Master
Documents: Those that are corrupt and those that will be corrupt
soon.
John McGie
John McGie
youronlinechoices.com: an industry funded joke
With GDPR in operation, a lot of sites refer to youronlinechoices.com to manage your advertising cookies. On the homepage of the site you can select your country and language and then go to your advertising preferences. Sometimes you are directed to the preferences page directly.
The site lists (for me) 116 advertising sites, with for each company an on/off status. The site is a self-regulating, industry funded site.
Only... it does not work. For the 116 sites, only 14 show a response, the rest time out.
The site allows you to switch advertising on/off for individual companies. As it is not practical to click 116 buttons, there is a handy option to switch them all on or off.
Only... it does not work. Just like you could expect, the operation times out.
Most companies have an edaa certified label. You can click on the label to see the certification the advertising company received.
Only... it does not work. This is what you get:
At the bottom of the page there is a feedback mail adress. I signaled the problems to them.
Only... it does not work. After more then a month i did not even get a mail confirming the receipt of my message.
So much for industry self regulation.
I'll start listing companies using this bogus site to manage your privacy here:
- rabobank.be
The site lists (for me) 116 advertising sites, with for each company an on/off status. The site is a self-regulating, industry funded site.
Only... it does not work. For the 116 sites, only 14 show a response, the rest time out.
The site allows you to switch advertising on/off for individual companies. As it is not practical to click 116 buttons, there is a handy option to switch them all on or off.
Only... it does not work. Just like you could expect, the operation times out.
Most companies have an edaa certified label. You can click on the label to see the certification the advertising company received.
Only... it does not work. This is what you get:
Sorry, the page you are looking for either doesn't exist or something has gone wrong. Please go back to the home page and try again. Thank you.
Only... it does not work. After more then a month i did not even get a mail confirming the receipt of my message.
So much for industry self regulation.
I'll start listing companies using this bogus site to manage your privacy here:
- rabobank.be
RD EE6 webservices module 9: alternate lab instructions
- Create a new web project Publisher
- Create a new java bean class domain.Address with properties street, number, postalCode, City
- Create a new java bean class domain.Publisher with properties id, name, address
- Make sure JAXB can convert this bean from/to XML
- Create a new Soap WebService service.PublisherService. Do not wrap the service in a SessionBean (it will work as a servlet)
- We will not save the data to a database. To store the publishers in memory, add this attribute to PublisherService
- Add a webservice method create(String name,Address address) to the PublisherService
- In the method create a new Publisher. For the id, take the size of the publisherDao + 1.
-
Add the Publisher to the publisherDao map. Use its id as the key in the map.
-
Add a webservice method querySingle(int id). It should return the publisher with this id.
-
Add a webservice method QueryAll. It should return all publishers
-
Test and correct any errors
- Make sure a SOAP Fault is returned when creating a publisher with invalid parameters
-
Advanced (Optional)
- Customize the Fault to add a detail child element with one
or more reasons explaining why the creation failed.
<detail> <canNotCreatePublisher > <reason>No address</reason> <reason>No name</reason> <canNotCreatePublisher> </detail>
Note: the canNotCreatePublisher element may contain some extra namespace information.
- Make an ErrorInfo bean class that contains a list of reasons. Make sure objects of the class can be transferred from/to XML using JAXB
- Make a CreateException class that inherits from Exception. The class should have an attribute
private ErrorInfo faultInfo; - Add accessor methods for the attribute and a constructor with the attribute as an argument
- Add an @WebFault annotation to the CreateException class
- In the create webservice check for the validity of the parameters. If there are invalid parameters throw a CreateException with an error message for each invalid parameter.
- Customize the Fault to add a detail child element with one
or more reasons explaining why the creation failed.
private static Map<Integer,Publisher> publisherDao = new HashMap<Integer,Publisher>();
RD EE6 webservices module 10: lab cookbook
- Start from the BookOrderWSService.wsdl in the lab directory
- OR (Alternative):
- start from the order.wsdl you created in module 3
- modify the order ComplexType to match the exercise instruction
- modify the orderId SimpleType to String
- Generate java classes from the WSDL
- Create a src and class directory
- run wsimport in the location where you have created these folders. wsimport should
- generate all classes in the service package
- put generated .class files in the class directory
- put generated .java files in the src directory
- Create a new Java Web Application project called bookOrder
- Copy the wsimport files to your project
- copy the src/service directory to the src directory of your project
- Move the bookOrder class to a newly created package domain
- Make a new directory wsdl in the WEB-INF directory (WEB-INF is under Web Pages) and copy the WSDL you obtained in step 1 here.
- Add constructors to domain.Orders
- add a constructor that takes all attributes as parameters
- add a constructor without parameters
- Implement the BookOrderService interface in a class BookOderWS
- Add these extra attributes
- endpointInterface
- wsdlLocation = "WEB-INF/wsdl/BookOrderWSService.wsdl"
- serviceName
- portName
- targetNamespace
- Add a static Map to BookOrderWS , which will act as a datastore:
-
private static Map<String,Order> orderDao = new HashMap<String,Order>();
- add a static block to the class in which you add some test data to orderDao. Use the orderID from the Order also as a key in the Map.
- Implement the orderBook method.
- Test and correct until everything works
6 September 2018
RD EE6 Web Services module 12 alternate lab: Logging Handler
Make a copy of the project you made in module08 and work in that copy.
Add a SOAPHandler that logs every message to System.out for the BookWS webservice.
-D
Add a SOAPHandler that logs every message to System.out for the BookWS webservice.
- Write a class handler.LoggingHandler that implements SOAPHandler. For each message
- Log if it is a REQUEST or a RESPONSE
- Log the SOAP message using
context.getMessage().writeTo(System.out);
- catch any Exceptions and return true
- Annotate the BookService with @HandlerChain, and refer to the "../../handlers.xml" file
- Write the handlers.xml file and put it in the WEB-INF directory
- Test and correct until it works
-D
com.sun.xml.ws.transport.http.HttpAdapter.dump=true
1 September 2018
RD EE6 Web Services module 21 lab using JAX-RS 2
Create a JAX-RS 2 REST client application for your createAuthor and findAuthorById service.
- Make a REST client prject
- Make a new rsClient java application project in Netbeans
- Make sure your Author webservice server project is open as well
- Add a new webservice client to the client project (File > new > Webservices > RESTful Java client)
- Select the REST resource, browse for your server project and select the Author REST service
- Finish
- This creates you a project with the JAX-RS libraries and client sample code.
- You can use the sample code for your inspiration, but write your own client code
- Copy the domain classes of your server project + the JAXB adapters to the client project
- Call the createAuthor service
- In the main method of your client project create a javax.ws.rs.client.Client object
- Create a request that expects an XML or JSON reply
- Create a new Author object, without an id
- POST the author object in the body as a XML or JSON Entity. Example of the creation of a JSON entity: javax.ws.rs.client.Entity.json(author)
- Call the findAuthorById service to retrieve the Author you just created from the server
- If the createAuthor service is well written, the Location header in the javax.ws.rs.core.Response should contain the URL of the newly created Author (including the generated author id). Retrieve the URL from the Location header in the Response.
- Use the URL to retrieve the author, converted by the Client to an Author object
- Print the Author object to the console
JAX-RS 2.0 client example: Client class
public class MyClient { public static void main(String[] args) { System.out.println("What's the name of this author?: "); String authorId = new Scanner(System.in).next(); Client client = ClientBuilder.newClient(); WebTarget resource = client.target("http://localhost:8080/myrest/webresources"); Response response = resource .path("author") .path(authorId) .request(MediaType.APPLICATION_JSON) .get(); // historically getStatus returns an int, not a Response.Status if (response.getStatus() == Response.Status.OK.getStatusCode()) { Author author = response.readEntity(Author.class); System.out.println("Found author: " + author.getFirstName() + " " + author.getLastName()); }else{ String body = response.readEntity(String.class); System.out.println("Not correct (" + response.getStatusInfo().getReasonPhrase() + ")\n " +body); } } }
31 August 2018
JAXB custom conversion using @XmlJavaTypeAdapter
To provide your own conversion implementation of a JAXB property, annotate the property in your JAXB class with javax.xml.bind.annotation.adapters.@XmlJavaTypeAdapter:
@XmlJavaTypeAdapter(MyAdapter.class)
public void setFrom(LocalDate from) {
this.from = from;
}
Then write your Adapter marshalling your LocalDate attribute to an XML value String and unmarshalling it:
public class MyDateAdapter extends XmlAdapter<String, LocalDate> {
public LocalDate unmarshal(String myString) throws Exception {
return LocalDate.parse(myString);
}
public String marshal(LocalDate myDate) throws Exception {
return myDate.toString();
}
}
@XmlJavaTypeAdapter(MyAdapter.class)
public void setFrom(LocalDate from) {
this.from = from;
}
Then write your Adapter marshalling your LocalDate attribute to an XML value String and unmarshalling it:
public class MyDateAdapter extends XmlAdapter<String, LocalDate> {
public LocalDate unmarshal(String myString) throws Exception {
return LocalDate.parse(myString);
}
public String marshal(LocalDate myDate) throws Exception {
return myDate.toString();
}
}
30 August 2018
Glassfish console log timestamps
By default glassfish does not add timestamps to console logging messages and that allways leaves me wondering wether I'm looking at an old message or a new one.
To add timestamps edit $GLASSFISH_INSTALL/glassfish/domains/domain1/config/logging.properties
Replace domain1 with the domain your domainin the above, if you are not using the default domain.
change:
to:
The default format is fine for me, but you can customize the format using:
The javadoc contains some format string examples.
Then (re)start the server.
To add timestamps edit $GLASSFISH_INSTALL/glassfish/domains/domain1/config/logging.properties
Replace domain1 with the domain your domainin the above, if you are not using the default domain.
change:
java.util.logging.ConsoleHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
to:
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
The default format is fine for me, but you can customize the format using:
java.util.logging.SimpleFormatter.format="your %format string"
The javadoc contains some format string examples.
Then (re)start the server.
23 August 2018
Java EE component versions overview (updated)
The table below lists the components in latest versions of the Java Enterprise Edition.
Many of the Java EE projects live on github.
After Java EE8, Java EE is moving to the EE4J project (Eclipse Enterprise For Java) aka Jakarta.
Many of the Java EE projects live on github.
After Java EE8, Java EE is moving to the EE4J project (Eclipse Enterprise For Java) aka Jakarta.
- I put the most important changes in red.
- Components with a [version number] between brackets are proposed for removal in a future release.
- An x indicates a technology is removed from the specification
- JSR's are shown as hyperlinked numbers.
- SE indicates that an API was moved to the standard edition
- eventually followed with the version number
- Java SE version history is in a separate post
- These API's will be removed from Java SE again with Java 11
- Web technologies are in a separate post
- EJB history is in a separate post
- I added some application servers at the bottom of the table.
Technologies | 151 J2EE 1.4 2003 |
244 Java EE5 2006 | 316 Java EE6 2009 | 342 Java EE7 4/2013 | 366 Java EE8 |
Java SE | 59 1.4 | 176 5 | 270 6 | 336 7 | 337 8 |
EJB | 153 2.1 | 220 3.0 | 318 3.1 | 345 3.2 | |
Servlet/JSP | 2.4 | 2.5 | 3.0 | 3.1 | 4.0 |
EE Management | 77 1.0 | ||||
JMS | 914 1.1 | 343 2.0 | 368 2.1 | ||
JTA 907 | 1.0 | 1.1 | 1.2 | ||
JavaMail 919 | 1.3 | 1.4 | 1.5 | 1.6 | |
Connector (JCA) | 112 1.5 | 1.5 | 322 1.6 | 1.7 | |
Java Activation Framework (JAF) 925 | 1.0 | 1.1 | SE:1.1.1 | ||
Web Services 109 | 1.1 | 1.2 | 1.3 | 1.4 | |
Web Services Metadata 181 | 2.0 | SE | SE:2.1 | ||
JAX-WS (SOAP) | 101 JAX-RPC 1.1 | 224 2.0 | SE:2.0 | SE:2.2 | |
JAX-RS (REST) | 311 1.1 | 339 2.0 | 370 2.1 | ||
JAXB 222 | 2.0 | SE:2.2 | |||
JSON-P | 353 1.0 | 3741.1 | |||
JSON-B 367 | 1.0 | ||||
JAXR (UDDI Registry) | 1.0 | [1.0] | x | ||
SOAP w attachments (SAAJ) 67 | 1.2 | 1.3 | SE | ||
StAX 173 | 1.0 | SE | |||
JMX | 1.2 | SE | SE | ||
container authorisation (JACC) 115 | 1.0 | 1.1 | 1.4 | 1.5 | |
container authentication (JASPIC) 196 | 1.0 | 1.1 | |||
Security 375 | 1.0 | ||||
Common annotations 250 | 1.0 | 1.1 | 1.2 | 1.3 | |
Java Persistence (JPA) | 1.0 | 317 2.0 | 338 2.1 | 2.2 | |
Bean Validation | 303 1.0 | 349 1.1 | 380 2.0 | ||
Managed Beans | 1.0 | ||||
Interceptors | 1.0 | 1.1 | 1.2 | ||
CDI for Java EE | 299 1.0 | 346 1.1 | 365 2.0 | ||
DI for Java 330 | 1.0 | ||||
Concurrency utilities 236 | 1.0 | ||||
State management 350 | 1.0 | ||||
Batch 352 | 1.0 | 1.1 | |||
Servers | |||||
Sun JSAS | 8 | 9.1 | |||
Glassfish | 2 | 3 (12/09) | 4 (5/13) | 5 (9/17) | |
JBoss / WildFly | 4 | 5 | 7 (7/11) | 8 (2/14) | 12 (2/18) |
IBM Websphere | 6 | 7 | 8 (6/11) | 9 (10/17) | |
Oracle Weblogic | 9 | 10 | 12.1.1 (12/11) | 12.2.1 (11/15) | |
Apache Geronimo | 1 | 2 | 3 (7/12) | - | |
Apache Tommee+ | 1.5 (9/12) | 7 (3/16) |
- J2EE 1.3(2001) introduced
- Message Driven Beans
- Local interfaces
- Profiles are a subset of the spec.
- Java EE Web profile (only profile currently defined)
- contents
- java SE
- web technologies, JTA, common annotations, JPA, validation, managed beans, interceptors, CDI, DI
- EJB Lite
- Stateless, Stateful, and Singleton session beans
- asynchronous session beans (EJB 3.2)
- only local EJB interfaces or no interfaces
- interceptors
- security
- transactions
- non persistent timer only (EJB 3.2)
- No Message Driven beans and remote invocation.
- JAX-RS (Java EE7)
- implemented by
- Resin 4
- Apache TomEE
20 August 2018
19 August 2018
Securely opening tabs to other sites from your webpage
You can use a link on your webpage to open a page from another site in another tab, using
To prevent this, break the opener and referer links the foreign page has to your webpage by using
<a ref="https://othersite/otherpage.html" target="_blank"> to other page </a>Your browser typically opens the other page in a new tab, but this page retains a relation with your webpage and can do some priviliged actions like redirecting the tab of your webpage to another URL.
To prevent this, break the opener and referer links the foreign page has to your webpage by using
<a ref="https://othersite/otherpage.html" target="_blank" rel ="noopener noreferer"> to other page </a>more...
7 June 2018
Java EE web technology version history (updated)
JSR numbers are included as links.
Servers are webcontainers.Take care, web containers do not include JSF. You have to add it yourself or use an enterprise application server. Enterprise application servers are included in the
complete Java EE version overview.
Java EE | servlet | JSP | EL | JSTL | JSF | WebSocket | MVC | Server | What’s new |
2.1
|
1.0
| iPlanet jetty 1 |
ServletContext, RequestDispatcher
| ||||||
1.2
|
2.2
|
1.1
| tomcat 3.3 jetty 3 |
war
| |||||
1.3
|
53 2.3
|
53 1.2
| tomcat 4.1 jetty 4 |
filters
| |||||
1.4
|
154 2.4
|
152 2.0
|
1.0
|
52 1.1
| tomcat 5.5 jetty 5 | ||||
5
|
2.5
|
245 2.1
|
2.1
|
1.2
| 127 1.2 | tomcat 6 jetty 6 |
annotations
| ||
6
|
315 3.0
|
2.2
|
2.2
| 314 2.0 | tomcat 7 jetty 8 |
asynchronous servlets, EL method calls, more...
| |||
7
| 340 3.1 | 344 2.2 |
356 1.0
| tomcat 8 jetty 9.1 | HTML 5, non blocking (Listener) servlet IO | ||||
8
| 369 4.0 | 372 2.3 | 371 1.0 | tomcat 9 | HTTP/2 |
3 May 2018
windows 10 logon/logoff tracking by filtering system events
When I'm late filling in my timesheets, it always is a headache to remember which hours I spent working. My windows event viewer (eventvwr.msc) can be a help but the logs are too crowded.
The events related to logon/logoff are polluted with plenty of events from system services.
So I ventured to create a filter only showing the events relating to my user. This requires XML filtering based on XPATH.
The events related to logon/logoff are polluted with plenty of events from system services.
So I ventured to create a filter only showing the events relating to my user. This requires XML filtering based on XPATH.
- Create a new custom event view
- right click the security category and select Create Custom View...
- enter the event ID's you want to filter. For logon/logoff these are 4624, 4634 and 4647
- You can get the id's by examining your events or from this MSDN page.
- Modify the base filter.
- There is a field for filtering on the user name in the filter definition form, but that did not work. By clicking the XML tab we can edit the XML filter definition. Take care: you will not be able to edit the filter using the graphical user interface anymore after that.
- I added user filtering in the XML. This is my filter
- I saved the filter and provided a name for the new custom filter.
- We're done
<QueryList> <Query Id="0" Path="Security"> <Select Path="Security"> *[System[( EventID=4624 or EventID=4634 or EventID=4647)] and EventData[Data[@Name='TargetUsername']='jan']] </Select> </Query> </QueryList>
- In eventviewer, pick a logon event of logon type 2. More info on logon events...
- Select the event and in the bottom half of the window you see the details
- Select the Details Tab, then the XML view button. This shows you the name/value pairs on which you can filter. I want to filter on my user, so I'll need the SubjectUserName field.