Hi
I have a webapp in Java SEAM2 running on JBOSS.
In my application I am trying to create directories on the fly / runtime.
Well what happens is that these directories get created, but when I try to write a file into them it throws a null pointer exception. So restarted my server and all works well then, why is it ?
if(ClassName.class.getClassLoader().getResource("roles/" + role ) == null)
{
//create directory with role name
String rolePath = ClassName.class.getClassLoader().getResource("roles").getPath();
rolePath = rolePath.substring(1, rolePath.length());
rolePath = rolePath.replace("/", "\\");
rolePath = rolePath + "\\" + role;
if( !(new File(rolePath).mkdir()))
{
this.addMessage(FacesMessage.SEVERITY_ERROR, "Error Creating Role Directory");
return;
}
}
if(ClassName.class.getClassLoader().getResource("roles/" + role + "/" + app ) == null)
{
String appPath = ClassName.class.getClassLoader().getResource("roles/" + role).getPath();
appPath = appPath.substring(1, appPath.length());
appPath = appPath.replace("/", "\\");
appPath = appPath + "\\" + app;
File appFolder = new File(appPath);
if( !(appFolder.mkdir()))
{
this.addMessage(FacesMessage.SEVERITY_ERROR, "Error Creating Role Directory");
return;
}
}
My guess is that since I am using getClassLoader it is not getting updated with the new files created