When the servlet container cannot determine a valid file path for the method, such as when the web application is on a remote file system not accesible locally, in an archive or in a database, it will return null. So if your web application is still in a war, you will probably get this problem. In a standalone Tomcat, it normally unpacks the war so you can manifest a file path. Not so with the integrated Tomcat.
Short version - you have no absolute file path when the application files do not manifest themselves in a real, physical way. Which is fine with the spec.
I know that doesn't help much. You could try using properties already set but I'm not sure what you are after - for example you could read the jboss.server.home.dir. Or you can set properties in your web.xml for servlet initialisation. The only problem is the dependency inherent in this.
Get real path only works with unpacked deployments.
It is part of the servlet spec.
You need to deploy your application using a directory
structure that looks like a war file.