Jim W
Jim W

Reputation: 5016

Stubborn/irrational java.lang.ClassNotFoundException in weblogic ADF, class in JAR

I'm new to ADF/JDeveloper and am struggling with the typical 'class not found' - hopefully there's a trick to this?

Using: JDeveloper 12c and the integrated web logic server.

Situation: A Servlet is registered in web.xml, but the class is in a JAR

<servlet>
    <description>..</description>
    <servlet-name>ABCHandlerServlet</servlet-name>
    <servlet-class>com.mine.ControlServlet</servlet-class>
    <init-param>
    <param-name>licenseKey</param-name>
    <param-value>123</param-value>
    </init-param>
</servlet>
...
<servlet-mapping>
    <servlet-name>ABCHandlerServlet</servlet-name>
    <url-pattern>/servlet/GaugeServlet/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ABCHandlerServlet</servlet-name>
    <url-pattern>/mapproxy/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/bi/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>ABCHandlerServlet</servlet-name>
    <url-pattern>*.ABC</url-pattern>
</servlet-mapping>  

com.mine.ControlServlet, which it reports at deployment cannot be found, is in a JAR file.

The JAR file is under

ViewController/Application Sources/META-INF/lib/myjar.jar

I've triple checked that the class is inside that JAR.

I've also tried adding that JAR to the project classpath, although that doesn't seem necessary (didn't make a difference anyway).

FWIW the JAR/Servlet has been used many times in a non ADF environment, so I doubt that the problem is within the JAR.

Upvotes: 1

Views: 1368

Answers (2)

Jim W
Jim W

Reputation: 5016

Removing the JAR from Project Properties->Libraries and Classpath and then readding it fixed the problem.

Time, wasted.

Thanks though to florinmarcus, 1up.

Upvotes: 2

Florin Marcus
Florin Marcus

Reputation: 1657

The library might not be packaged in your WAR. Adding the library to ViewControler libraries is half of the story. You may want to check if your WAR deployment profile packages the library too:

Right-Click on ViewController -> Project Properties -> Deployment -> Select the existing Web module in the right -> Edit (icon) -> WEB-INF/lib -> Contributors -> Make sure the library is is checked as part of the deployment.

You can double-check the WAR contents by Right-Click View Controller > Project Properties -> Select the Web Module -> Deploy to WAR.

Upvotes: 1

Related Questions