2

I am having an issue resulting in the "Unresolved compilation problems" error. I have looked at this SO question, as well as this one of the same nature and finally this one again describing the same error.

All three of those describe dealing with compilation errors, but when I compile my project's class files, either using Maven from inside eclipse, Maven from the command line, or just the javac command, no errors are reported.

We have a custom class, JmxTools, which uses import org.apache.commons.modeler.Registry; Now the source file does not complain about a missing import. enter image description here

An answer to a similar question suggests looking at the "Problems" view in eclipse. This shows no errors

enter image description here

So, everything compiles fine, the commons-modeler jar is in my Maven dependencies. Yet when I run my web app and call the page using the JmxTools class I receive the following error stack:

    org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.Error: Unresolved compilation problems: 

    The import org.apache.commons.modeler cannot be resolved
    Registry cannot be resolved to a type
    Registry cannot be resolved to a type
    Registry cannot be resolved
    Registry cannot be resolved
    Registry cannot be resolved to a type
    Registry cannot be resolved to a type
    at 

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:561)
        at 

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:462)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.gy.filters.AccessControlFilter.doFilter(AccessControlFilter.java:150)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

    Caused by: javax.servlet.ServletException: java.lang.Error: Unresolved compilation problems: 
    The import org.apache.commons.modeler cannot be resolved
    Registry cannot be resolved to a type
    Registry cannot be resolved to a type
    Registry cannot be resolved
    Registry cannot be resolved
    Registry cannot be resolved to a type
    Registry cannot be resolved to a type

    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
    at org.apache.jsp.contextlist_jsp._jspService(contextlist_jsp.java:148)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
    ... 26 more

    Caused by: java.lang.Error: Unresolved compilation problems: 
        The import org.apache.commons.modeler cannot be resolved
        Registry cannot be resolved to a type
        Registry cannot be resolved to a type
        Registry cannot be resolved
        Registry cannot be resolved
        Registry cannot be resolved to a type
        Registry cannot be resolved to a type

        at com.gy.admin.JmxTools.<init>(JmxTools.java:18)
        at org.apache.jsp.contextlist_jsp._jspService(contextlist_jsp.java:100)
        ... 29 more

How do I get around this? This is something I have not run into before and the answers to similar questions do not appear to apply to this situation

EDIT

Following Kayaman's advice:

  1. Checked the war file and the commons-modeler jar file is present in WEB-INF/lib
  2. Moved the commons-modeler jar from from the war to my tomcat's lib/ folder
  3. did a fresh clean, then compile, the package from the command line

Unfortunately, none of these helped the situation. I am still receiving the error.

Paul Stoner
  • 1,359
  • 21
  • 44

1 Answers1

1

I wish to thank Kayaman. My issue was resolved by doing numerous maven clean then compile then package steps, outside of eclipse.

I also had to do several cleans and republish of tomcat inside of eclipse.

I also removed the errant dependency altogether built and packaged the project, then added the dependency back in.

I'm not exactly sure which of these steps solved my issue. I was in the middle of trying/testing various solutions when it started working.

Paul Stoner
  • 1,359
  • 21
  • 44