nahojkap / jahspotify

Jah'Spotify is a set of Java bindings over the Spotify native library (libspotify).
58 stars 14 forks source link

Jetty server returning 404 error #9

Closed thegofar closed 11 years ago

thegofar commented 11 years ago

Hi Johan,

I have successfully built the spotify libraries under linux and tested the examples. I have also built the JahSpotify library successfully.

When I run - mvn jetty:run -Djahspotify.spotify.username= -Djahspotify.spotify.password= with the appropriate username and password I get the following error:

"No plugin found for prefix 'jetty' in the current project and in the plugin groups"

So I added the following to the POM:

org.eclipse.jetty jetty-maven-plugin 9.0.6.v20130930

Now mvn jetty:run ........ gets further, producing the following output:

[INFO] Configuring Jetty for project: jahspotify-root [INFO] webAppSourceDirectory not set. Trying src/main/webapp [INFO] webAppSourceDirectory /home/craig/jahspotify/src/main/webapp does not exist. Trying /home/craig/jahspotify/target/webapp-tmp [INFO] Reload Mechanic: automatic [INFO] Classes directory /home/craig/jahspotify/target/classes does not exist [INFO] Context path = / [INFO] Tmp directory = /home/craig/jahspotify/target/tmp [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml [INFO] Web overrides = none [INFO] web.xml file = null [INFO] Webapp directory = /home/craig/jahspotify/target/webapp-tmp 2013-10-26 14:18:51.722:INFO:oejs.Server:main: jetty-9.0.6.v20130930 2013-10-26 14:18:53.551:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@136e74a{/,file:/home/craig/jahspotify/target/webapp-tmp/,AVAILABLE}{file:/home/craig/jahspotify/target/webapp-tmp/} 2013-10-26 14:18:53.552:WARN:oejsh.RequestLogHandler:main: !RequestLog 2013-10-26 14:18:53.613:INFO:oejs.ServerConnector:main: Started ServerConnector@1d9a7a7{HTTP/1.1}{0.0.0.0:8080} [INFO] Started Jetty Server

and the Jetty server appears to launch. I am able to connect to it on localhost:8080, it returns the expected: "Directory /"

If I try to go to say: 'http://localhost:8080/jahspotify/index.html' I get a 404 error, since the [INFO] above states that it can't find the folder for the webAppSourceDirectory I manually found it and created a copy in the location it looks, now I get a 503 error - service unavailable.

Following more fiddling....

I have set the root POM to include a plugin for jetty as follows:

org.mortbay.jetty jetty-maven-plugin 7.4.0.RC0 ${basedir}/web/src/main/webapp ${basedir}/web//target/classes

launching in the root directory ./jahspotify mvn jetty:run.... causes the following output:

[INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for jahspotify:jahspotify-web:war:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. @ line 46, column 21 [WARNING] [WARNING] Some problems were encountered while building the effective model for jahspotify:libjahspotify:so:0.0.1-SNAPSHOT [WARNING] 'artifactId' contains an expression but should be a constant. @ jahspotify:${artifact}:0.0.1-SNAPSHOT, /home/craig/jahspotify/native/pom.xml, line 18, column 17 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] jahspotify-root [INFO] jahspotify-libjahspotify [INFO] jahspotify-native-jar [INFO] jahspotify-api [INFO] jahspotify-storage [INFO] jahspotify-web-common [INFO] jahspotify-services [INFO] jahspotify-web [INFO] jahspotify-client [INFO] jahspotify-executable-war [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building jahspotify-root 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> jetty-maven-plugin:7.4.0.RC0:run (default-cli) @ jahspotify-root >>> [INFO] [INFO] <<< jetty-maven-plugin:7.4.0.RC0:run (default-cli) @ jahspotify-root <<< [INFO] [INFO] --- jetty-maven-plugin:7.4.0.RC0:run (default-cli) @ jahspotify-root --- [INFO] Configuring Jetty for project: jahspotify-root [INFO] Webapp source directory = /home/craig/jahspotify/web/src/main/webapp [INFO] Reload Mechanic: automatic [INFO] Classes = /home/craig/jahspotify/web/target/classes [INFO] Context path = / [INFO] Tmp directory = /home/craig/jahspotify/target/tmp [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml [INFO] Web overrides = none [INFO] web.xml file = file:/home/craig/jahspotify/web/src/main/webapp/WEB-INF/web.xml [INFO] Webapp directory = /home/craig/jahspotify/web/src/main/webapp [INFO] Starting jetty 7.4.0.RC0 ... 2013-10-27 21:42:57.850:INFO::jetty-7.4.0.RC0 2013-10-27 21:42:58.127:INFO::No Transaction manager found - if your webapp requires one, please configure one. 2013-10-27 21:42:58.234:WARN::Could not instantiate listener org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)

Googling seems to suggest that the listener class that won't instantiate is packaged in spring-web-3.1.1.RELEASE.jar which lives locally @ ./web/target/jahspotify-web-001-SNAPSHOT/WEB-INF/lib as a .jar

So what is going on, this must be fairly simple but I have no idea!

mvn -version Apache Maven 3.0.4 Maven home: /usr/share/maven Java version: 1.7.0_25, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-i386/jre Default locale: en_GB, platform encoding: UTF-8 OS name: "linux", version: "3.5.0-34-generic", arch: "i386", family: "unix"

Many Thanks

Craig

thegofar commented 11 years ago

I realised that I need to execute the jetty server from within ~/jahspotify/web

I then ran into linker issues and added the path to my libspotify.so.12 library with the following: http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux

Thanks for the wrapper, its now working... until next time :)