You can check the @Jasper de Vries comment, otherwise you can verify if the file is present using a bean method like this:
MyBean.java
public String findFileURL() {
String fileName = "myDoc.pdf";
String relativeWebPath = "/resources/media/" + fileName;
FacesContext facesContext = FacesContext.getCurrentInstance();
String absoluteDiskPath = ((ServletContext) facesContext.getExternalContext().getContext())
.getRealPath(relativeWebPath);
File file = new File(absoluteDiskPath);
if (file.isFile()) {
return relativeWebPath;
} else {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "File: " + fileName + " not found.", "");
facesContext.addMessage(null, message);
return "";
}
}
MyPage.xhtml
<p:media value="#{myBean.findFileURL()}" width="100%" height="800px" zoom="100" player="pdf" cache="false"/>