Multipart Configuration for JBoss Enterprise Application Platform/Application Server

Spring REST controller on Spring Boot (1.12) was not accepting multi-part requests for file upload on JBoss EAP/AS but working on Embedded Tomcat.

org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'file' is not present

I needed to add a multipart filter on my web xml configuration in Java

public class Application extends SpringBootServletInitializer {

 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
 return application.sources(Application.class);

 public void onStartup(ServletContext servletContext) throws ServletException {
 WebApplicationContext context = createRootApplicationContext(servletContext);
 ServletRegistration.Dynamic servletRegistration = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
 servletRegistration.addMapping("/*"); // required JBOSS EAP
 servletRegistration.setMultipartConfig(getMultiPartConfig()); // fixes multipart requests

 private MultipartConfigElement getMultiPartConfig() {
 String location = "";
 long maxFileSize = -1;
 long maxRequestSize = -1;
 int fileSizeThreshold = 0;
 return new MultipartConfigElement(

 public static void main(String[] args) {, args);

My Spring and web.xml is configured via Java annotations.

I found this post for this configuration:


CAS 3.3.1 to CAS 4.0.0 Upgrade/Migration

CAS 4.0.0 is in the process of being released, and the documentation is not comprehensive. Here are somethings I did to get from CAS 3.3.1 to CAS 4.0.0 in terms of the maven overlay project.  This was mainly to get the fix for CAS-1318.

Overlay pom dependencies

updated cas-server-webapp from 3.3.1 to 4.0.0
added cas-management-webapp 4.0.0
added cas-server-support-generic 4.0.0
added cas-server-support-x509 4.0.0
added cas-server-support-openid 4.0.0
cas-server-support-ldap 4.0.0
removed outdated dependencies from overlay/lib

Files copied over from github

src/main/webapp/WEB-INF/cas-servlet.xml (too many changes, added my changes after copying over)

Updated files

uncommented startAuthenticate, changed flow in serviceAuthorizationCheck to transition to startAuthenticate instead.  Note: my project was using x509check, so the commented out code seemed to run the x509check

added namespace util
modified auditTrailManager bean to point to new class
added healthCheckMonitor bean
added registeredServiceList, modified to fit our services
added monitorsList

xml schema upgrades in overlayed xml files
beans 2 -> beans 3
webflow 1 -> webflow 2

Changed Credentials.class references to Credential.class in custom code in extensions

Relevant Links!msg/jasig-cas-user/jS2GjedsMd4/o-MGC_Tpn7IJ!msg/jasig-cas-user/jS2GjedsMd4/o-MGC_Tpn7IJ

Each project is different, but I basically just fixed compilation errors and went through the runtime errors.  I didn’t write down the details of each change, but the relevant links should have more information on what the exact changes were.

Good luck!

RESTful Web Services Popular Standards

My two favorite resources for REST standards.  I think they cover most use cases, and their suggestions are thought out and used in practice.  I recommend that both backend and frontend developers read/watch both!

  1. Storm Path
  2. Vinay Sahni

To see other links that I liked, check out my page.

Apache Avro JSON Decoder for List/Array of Avro Objects

I couldn’t find a good example of decoding a JSON string that’s a list/array of Avro objects on the web. I just wanted to write a post to say that it works.

Here’s a few high level things that I remember

  • Create a JSON Decoder with Schema.createArray({avroObject}.getSchema())
  • When initializing the data reader, use List<{avroObject}> and also pass in an initialized instance of List<{avroObject}> along with the JSON Decoder created above.

It should work, but I had to use the debugger a few times to clear out some JSON issues.  I hope this helps – I spent a lot of unnecessary time checking whether something like this would work.  It looks like it’s supported out of the box.

Java Generics JSON Unmarshalling Using Jackson via Jersey Resource

Jackson seems to unmarshal properly for objects with a specific class type.  For types with generics, for example List<Element>, I could only specify the List.class, and the Element JSON was unmarshalled as LinkedHashMaps instead of the Element.class.

I found a way to work around it and applied it to the Jersey use case for my unit test.

ObjectMapper mapper = new ObjectMapper();
JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, Element.class);

String json = client().resource("/some/collection").get(String.class);
List<Element> elements = mapper.readValue(json, type);

Custom Headers on Preflight Request for HTTP Method OPTIONS

I spent a few hours on this, it looks like we can’t add custom headers on a preflight request.  We’re using JQuery/Backbone/Marionette, and some of the cross origin requests (HTTP POST and GET with custom headers) are causing a preflight request to happen.

Apparently the preflight requests are generated by the browser, and we can’t control the headers in that request.  The server needs to handle the HTTP OPTIONS request properly and return a 200 code in order for the request to continue.

In my case, the OPTIONS request was going to a resource requiring authentication, so I’m thinking that I need to allow OPTIONS requests to get a response without authentication.

Here’s the helpful resource that I ran across.

Sample Dropwizard Resource Test

I’m prototyping a dropwizard app, and it wasn’t clear in the docs how to write resource tests that handle authentication.  This example uses OAuth authentication.  I also found it annoying that there were no import statements in the documents.  Anyway, I hope this helps.  There are probably more efficient ways to do this, so I’ll update this post as I find out more.

package com.yourcompany.resource;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.LinkedList;
import java.util.List;


import org.eclipse.jetty.server.Authentication.User;
import org.junit.Before;
import org.junit.Test;

import com.yourcompany.dao.SampleDao;
import com.yourcompany.dto.SampleItem;
import com.yourcompany.dto.Sample;
import com.yourcompany.oauth.OAuthAuthenticator;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.filter.ClientFilter;
import com.yammer.dropwizard.auth.oauth.OAuthProvider;
import com.yammer.dropwizard.testing.ResourceTest;

public class SampleResourceTest extends ResourceTest {
 private final Sample sample = new Sample();
 private final SampleDao dao = mock(SampleDao.class);

 protected void setUpResources() {
 List<SampleItem> sampleItems = new LinkedList<SampleItem>();


 addResource(new SampleResource(dao));
 addProvider(new OAuthProvider<User>(new OAuthAuthenticator(), "CLIENT_SECRET"));

 public void testBefore() {
 client().addFilter(new ClientFilter() {
 private List<Object> authorizations;

 public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
 if (authorizations == null) {
 authorizations = new LinkedList<Object>();
 authorizations.add("Bearer {test token}");
 request.getHeaders().put("Authorization", authorizations);
 ClientResponse response = getNext().handle(request);

 return response;

 public void testFetchSample() throws Exception {
 Sample retrievedSample = client().resource(String.format("/sample-service/sample/id/", "id")).get(Sample.class);

 public void testPostSample() throws Exception {
 Sample retrievedSample = client().resource("/sample-service/sample").type(MediaType.APPLICATION_JSON_TYPE).post(Favorites.class, favorites);

 private void compareSample(Sample retrievedSample) {
 // other assertions

I created a TestOAuthAuthenticator that I pass into my test as a provider. This authenticator has pre-defined tokens and users for tests.