Could not locate myapp/server__init.class or myapp/server.clj on classpath.

149 views
Skip to first unread message

moji...@gmail.com

unread,
May 31, 2016, 12:31:20 AM5/31/16
to pedestal-users
so I am trying to deploy my clojure pedestal app .war on EC2 following the following doc to create the war

https://github.com/pedestal/docs/blob/master/documentation/service-war-deployment.md

The server runs fine but checking the localhost.log I found

May 31, 2016 4:10:49 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet PedestalServlet
java.io.FileNotFoundException: Could not locate myapp/server__init.class or myapp/server.clj on classpath.
at clojure.lang.RT.load(RT.java:449)
at clojure.lang.RT.load(RT.java:412)
at clojure.core$load$fn__5448.invoke(core.clj:5866)
at clojure.core$load.doInvoke(core.clj:5865)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5671)
at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
at clojure.core$load_lib.doInvoke(core.clj:5710)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:632)
at clojure.core$load_libs.doInvoke(core.clj:5749)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:632)
at clojure.core$require.doInvoke(core.clj:5832)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:379)
at io.pedestal.servlet.ClojureVarServlet.getVar(ClojureVarServlet.java:109)
at io.pedestal.servlet.ClojureVarServlet.init(ClojureVarServlet.java:67)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
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.allocate(StandardWrapper.java:866)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

And in my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<description>Pedestal HTTP Servlet</description>
<display-name>Pedestal HTTP Servlet</display-name>
<servlet>
<servlet-name>PedestalServlet</servlet-name>
<servlet-class>io.pedestal.servlet.ClojureVarServlet</servlet-class>
<init-param>
<param-name>init</param-name>
<param-value>myapp.server/servlet-init</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>myapp.server/servlet-service</param-value>
</init-param>
<init-param>
<param-name>destroy</param-name>
<param-value>myapp.server/servlet-destroy</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>PedestalServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

Is this happening because my url-pattern above is wrong? should I be using ` <url-pattern>/myapp/*</url-pattern>` instead? Because when it's deployed on EC2 the it renames whatever I upload to `ROOT.war`

Paul deGrandis

unread,
May 31, 2016, 9:15:41 AM5/31/16
to pedestal-users, moji...@gmail.com
Hi,

Thanks for using Pedestal and thanks for reaching out on the mailing list!
Sorry no one has gotten to this message yet - I assume that's largely due to the holiday weekend in the United States.

Just to clarify - The server totally runs fine and returns responses as you expect, but you're seeing this message in the log and you'd like to dive in to ensure there aren't any other issues?

As per the WAR docs, if you have a url pattern of /myapp/*, the container is usually expecting that WAR is named `myapp.war` and all of your Pedestal routes would start with `/myapp`.

The error that is appearing makes it seem like you configured your application (and WAR) to look for `myapp/server.clj`.  Does that file (and namespace) exist?

Cheers,
Paul

moji...@gmail.com

unread,
May 31, 2016, 2:07:34 PM5/31/16
to pedestal-users
Hey Paul, appreciate it.

The server does not return a valid response instead 404s

The pedestal server is in src/myapp/server.clj

Should I use /src/myapp/* instead?

moji...@gmail.com

unread,
May 31, 2016, 7:56:39 PM5/31/16
to pedestal-users, moji...@gmail.com
the thing is when you generate a war file I looked at the contents of WEB-INF/classes and it basically moved the src/myapp/server.clj (ns myapp.server)
into /myapp/server.clj, so maybe this is what it's complaining about?

In that case what changes must be made on my code end? It seems like there's a discrepancy between my original source code structure and the war file structure that gets generated.

Paul deGrandis

unread,
May 31, 2016, 7:58:14 PM5/31/16
to pedestal-users, moji...@gmail.com
Hi,

Have you confirmed that the application works as expected using the embedded Jetty server, locally on your machine?
Is it possible for you to push the code (or a reproduction of the error) to a public repository?  We're close to getting 0.5.0 released, and if this is a subtle bug, I'd like to patch it before the release.

Cheers,
Paul

moji...@gmail.com

unread,
May 31, 2016, 7:59:15 PM5/31/16
to pedestal-users, moji...@gmail.com
yes that exists in fact inside the generated war file, the structure is

target/WEB-INF/classes/myapp/server.clj

and server.clj has (ns myapp.server) where it differs from my original source code for server.clj which is located in /home/projects/myapp/src/myapp/server.clj

moji...@gmail.com

unread,
May 31, 2016, 8:19:26 PM5/31/16
to pedestal-users, moji...@gmail.com
Hey Paul,

Yes, it worked locally on my machine.

Well this is happening with the default hello world example here which I am using

https://github.com/pedestal/pedestal/blob/master/guides/documentation/hello-world-service.md

so it does look like this is a pedestal issue. exact same error I ran it on repl just fine but when I package it to WAR file using the pedestal lein plugin and attempt to deploy it on tomcat 7

javax.servlet.ServletException: Failed to load namespace 'helloworld.server'


Is there any date on when that might be released or perhaps a work around because I'm pressed for time and unfortunately lost quite a bit of time trying to get my pedestal working on tomcat 7

moji...@gmail.com

unread,
May 31, 2016, 8:46:10 PM5/31/16
to pedestal-users, moji...@gmail.com
Paul,

I create an issue on pedestal-lein plugin

I tried to deploy the war generated on the hello world example.

https://github.com/ohpauleez/lein-pedestal/issues/6

which throws a completely different error?

Anyways, I'm throwing a lot of stuff at you but I'm pretty confused and lost as to what to do next. Hopefully I've provided enough information on the difficulties I'm facing while attempting to deploy Pedestal on Tomcat 7.

Just for references, I was able to deploy a Ring war file on tomcat 7 without issues, and the structure of the war files are pretty similar.

All in all I think this is an important issue especially because following the documentation on pedestal did not yield a successful deployment, and leaves a particularly painful first impression and more importantly I question whether I have chosen the right framework at all and raises further doubts about the future of Pedestal, seeing how inactive this mailing list is and relative difficulty I had in finding ways to resolve it other than cross post on github and this mailinglist and reddit like a maniac. I shudder to imagine what would happen if this was on production and we ran into an issue that couldn't be resolved.

I don't know, I took your word for how great pedestal was on reddit but now I'm having serious doubts. Hopefully I'm completely wrong and I respect the work you do but the fact that I didn't run into this much difficulty with other clojure frameworks is sort of making me question my own decision at this moment. Maybe others can chime in and prove me wrong but so far this has been my initial impression of pedestal: Not good due to outdated documentation, low community activity, and I'm relying on you alone to resolve all my issues. I really cannot afford to repeat this little panic episode when I'm in production so I hope you will see it from my point of view and I hate being snarky but at the same time I have to practice due dilligence.


On Tuesday, May 31, 2016 at 4:58:14 PM UTC-7, Paul deGrandis wrote:

Paul deGrandis

unread,
Jun 1, 2016, 9:02:54 AM6/1/16
to pedestal-users, moji...@gmail.com
Sorry to hear you keep getting caught on snags while trying to deploy the WAR.

I've thrown together a working WAR sample in the Pedestal project, which I'll continue to improve as the new tooling gets released.

A few things to note:
 * Pedestal requires Servlet 3.1.  According to the Tomcat Version Matrix, the minimum supported version would be Tomcat 8.x.
 * Pedestal compiles for Java 1.7, but future changes in javax.servlet will require Java 8.  This also means that Pedestal (more or less) requires Java 1.8.

I don't think there are any doubts about the future of Pedestal, the roadmaps are clear about the direction, and the communal and commercial support are both in place.  The documentation is most certainly an issue and is being actively worked on now that the next version (0.5.0) is mostly stable and staged for release.
It's also important to keep in mind that your original messages were posted on a holiday weekend in the US, when many people step away from the computer to spend time with their family and friends.  When community members see cross-posting in short time frames, it can often scare them away from jumping in to help out.
It may have also been the case that many people have successfully deployed Pedestal services as WARs before, so no one could relate to the issues you were reporting.  As a first measure to any issue, the Pedestal team creates a reproduction-case to work from, which often gets refined into a Sample application or a test within the test suite.

The cycle for issues here on the mailing list and on Pedestal's Github page is about 24 hours -- I and others typically work on Pedestal in the morning (5-8am ET), in the evening (7-9pm ET), or on Fridays (8am-5pm).

If you or your company take Pedestal into production and would like commercial help or support, reach out directly to me or anyone else at Cognitect.  We're more than happy to help out!

Let me know if this helps!

Cheers,
Paul

Reply all
Reply to author
Forward
0 new messages