title: JSP - Only a type can be imported. Name.pacakge.class resolves to a package but the class is there
body: <p>I'm receiving this error while trying to deploy a webapp via tomcat 7.</p>
  
  <p>The jsp file name <code>analysis.jsp</code> and this is the error:</p>
  
  <pre><code>Apr 05, 2017 3:05:39 PM org.apache.catalina.core.StandardContext loadOnStartup
  SEVERE: Servlet [analyserServlet] in web application [/MWE] threw load() exception
  org.apache.jasper.JasperException: Unable to compile class for JSP: 
  
  An error occurred at line: [26] in the generated java file: [/usr/share/tomcat/work/Catalina/localhost/MWE/org/apache/jsp/analysis_jsp.java]
  Only a type can be imported. mila.HMM.MorphMult2TaggerFormat resolves to a package
  
  An error occurred at line: [27] in the generated java file: [/usr/share/tomcat/work/Catalina/localhost/MWE/org/apache/jsp/analysis_jsp.java]
  Only a type can be imported. mila.HMM.HMM2Morph resolves to a package
  
  An error occurred at line: [28] in the generated java file: [/usr/share/tomcat/work/Catalina/localhost/MWE/org/apache/jsp/analysis_jsp.java]
  Only a type can be imported. mila.mw.PostProcessor1 resolves to a package
  
  An error occurred at line: [29] in the generated java file: [/usr/share/tomcat/work/Catalina/localhost/MWE/org/apache/jsp/analysis_jsp.java]
  Only a type can be imported. mila.mw.MWXMLTokenizer resolves to a package
  
  An error occurred at line: 36 in the jsp file: /analysis.jsp
  mila.mw.MWXMLTokenizer cannot be resolved to a type
  33: String tokenizeAndAnalyze(String rawText) throws Exception {
  34:     StringWriter sw = new StringWriter();
  35:     try (InputStream ins = new ByteArrayInputStream(rawText.getBytes("UTF-8"))) {
  36:         new mila.mw.MWXMLTokenizer().tokenizeAndAnalyze(ins, new PrintWriter(sw));
  37:     }
  38:     StringWriter ppSW = new StringWriter();
  39:     try (InputStream ins = new ByteArrayInputStream(sw.toString().getBytes("UTF-8"))) {
  
  
  An error occurred at line: 40 in the jsp file: /analysis.jsp
  mila.mw.PostProcessor1 cannot be resolved to a type
  37:     }
  38:     StringWriter ppSW = new StringWriter();
  39:     try (InputStream ins = new ByteArrayInputStream(sw.toString().getBytes("UTF-8"))) {
  40:         new mila.mw.PostProcessor1().process(ins,  new PrintWriter(ppSW));
  41:     }
  42:     return ppSW.toString();
  43: }
  
  
  An error occurred at line: 46 in the jsp file: /analysis.jsp
  mila.HMM.MorphMult2TaggerFormat cannot be resolved to a type
  43: }
  44: 
  45: String runTagger(String xmlAnalyzed, String _tempDirectoryPath) throws Exception {
  46:     final String taggerFormat = new mila.HMM.MorphMult2TaggerFormat()
  47:                             .myWEBMorp2Tagger(xmlAnalyzed, _tempDirectoryPath);
  48:     final String roydir = "/data/tagger/royTagger/";
  49:     final String probabilityDir = "/data/tagger/taggerLearningOutputFile/";
  
  
  An error occurred at line: 60 in the jsp file: /analysis.jsp
  mila.HMM.HMM2Morph cannot be resolved to a type
  57:     
  58:     final String xmlTaggedFilename = _tempDirectoryPath + "/tagged.xml";
  59:     PrintWriter pw = new PrintWriter(xmlTaggedFilename);
  60:     new mila.HMM.HMM2Morph().process(xmlAnalyzed, taggedFilename, pw);
  61:     return xmlTaggedFilename;    
  62: }
  63: 
  
  
  Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:494)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:138)
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1282)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1195)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1085)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5318)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5610)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
      at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
      at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Here is the import part from the jsp:</p>
  
  <pre><code>&lt;%@ page language = "java"
      import = "java.lang.StringBuilder"
      import = "java.io.StringWriter"
      import = "java.io.PrintWriter"
      import = "java.io.ByteArrayInputStream"
      import = "java.io.IOException"
      import = "java.io.File"
      import = "java.io.BufferedReader"
      import = "java.io.InputStreamReader"
      import = "java.io.InputStream"
      import = "java.nio.file.Files"
      import = "java.nio.file.Paths"
      import = "java.nio.file.StandardCopyOption"
      import = "mila.HMM.MorphMult2TaggerFormat"
      import = "mila.HMM.HMM2Morph"
      import = "mila.mw.PostProcessor1"
      import = "mila.mw.MWXMLTokenizer"
  %&gt;
  </code></pre>
  
  <p>Under the <code>WEB-INF/lib</code> folder I have a JAR named <code>morphAnalyzer.jar</code> which is basically the project and it contains all the classes needed including the ones that cause this error.
  Here is a partial vim look into the JAR</p>
  
  <pre><code>mila/
  mila/HMM/
  mila/HMM/HMM2Morph.class
  mila/HMM/MorphMult2TaggerFormat.class
  ...
  mila/mw/MWXMLMorphAnalyzer.class
  mila/mw/MWXMLTokenizer.class
  mila/mw/PostProcessor1.class
  ...
  </code></pre>
  
  <p>As you can see the jar does include all the classes I need but for some reason the jsp file doesn't recognize them as classes.</p>
  
  <p>P.S there is no other package with classes named the same (i.e all classes names are unique throughout the whole project)</p>
  
  <p>What am I doing wrong? Please help.</p>