diff --git a/src/main/java/org/olat/core/commons/modules/bc/commands/CmdServeResource.java b/src/main/java/org/olat/core/commons/modules/bc/commands/CmdServeResource.java
index 174355a11ed0ef53f50e9cd1e3c01f5638b3d036..2e9582644cd71cc1a9b249255fc2c1c8a201fa40 100644
--- a/src/main/java/org/olat/core/commons/modules/bc/commands/CmdServeResource.java
+++ b/src/main/java/org/olat/core/commons/modules/bc/commands/CmdServeResource.java
@@ -42,6 +42,7 @@ import org.olat.core.gui.translator.Translator;
 import org.olat.core.logging.activity.CoreLoggingResourceable;
 import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
 import org.olat.core.util.FileUtils;
+import org.olat.core.util.vfs.VFSItem;
 import org.olat.core.util.vfs.VFSLeaf;
 import org.olat.core.util.vfs.VFSManager;
 import org.olat.core.util.vfs.VFSMediaResource;
@@ -66,13 +67,14 @@ public class CmdServeResource implements FolderCommand {
 		// extract file
 		String path = ureq.getModuleURI();
 		MediaResource mr = null;
-		VFSLeaf vfsfile = (VFSLeaf)folderComponent.getRootContainer().resolve(path);
-		
-		
-		
-		if (vfsfile == null) {
+		VFSItem vfsitem = folderComponent.getRootContainer().resolve(path);
+
+		if (vfsitem == null) {
+			mr = new NotFoundMediaResource(path);
+		} else if(!(vfsitem instanceof VFSLeaf)) {
 			mr = new NotFoundMediaResource(path);
 		} else {
+			VFSLeaf vfsfile = (VFSLeaf)vfsitem;
 			if (path.toLowerCase().endsWith(".html") || path.toLowerCase().endsWith(".htm")) {
 				// setCurrentURI(path);
 				// set the http content-type and the encoding