nahojkap / jahspotify

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

Installation/Build on Mac OS X? #7

Closed SBejga closed 11 years ago

SBejga commented 11 years ago

Any plans or hints to support Mac OS X for your project jahspotify?

Tried with installed libspotify via homebrew but i got this:

[INFO] --- native-maven-plugin:1.0-alpha-7:compile (default-compile) @ libjahspotify ---
[INFO] /bin/sh -c cd /Users/basti/git/jahspotify/native && gcc -fPIC -O -I/Users/basti/git/jahspotify/native/src/main/native/inc -D_GNU_SOURCE -g3 -fno-inline -O0 -I/Users/basti/git/jahspotify/native/src/main/native/src -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../include -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../include/linux -o /Users/basti/git/jahspotify/native/target/objs/audio.o -c /Users/basti/git/jahspotify/native/src/main/native/src/audio.c
[INFO] /bin/sh -c cd /Users/basti/git/jahspotify/native && gcc -fPIC -O -I/Users/basti/git/jahspotify/native/src/main/native/inc -D_GNU_SOURCE -g3 -fno-inline -O0 -I/Users/basti/git/jahspotify/native/src/main/native/src -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../include -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../include/linux -o /Users/basti/git/jahspotify/native/target/objs/Callbacks.o -c /Users/basti/git/jahspotify/native/src/main/native/src/Callbacks.c
/Users/basti/git/jahspotify/native/src/main/native/src/Callbacks.c:2:17: error: jni.h: No such file or directory
In file included from /Users/basti/git/jahspotify/native/src/main/native/src/Callbacks.c:10:
/Users/basti/git/jahspotify/native/src/main/native/inc/JNIHelpers.h:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘createNativeString’

any tips?

nahojkap commented 11 years ago

Looks like the JNI headers are not included correctly, could you double check the include paths?

Other than this, I would hope it would compile at least. I would suspect you might get some issues at runtime (paths and such) - if so, please let me know. Or even better, provide a fix :)

Johan

nahojkap commented 11 years ago

In fact, try this before you run the build again?

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/

SBejga commented 11 years ago

export JAVA_HOME had no change, because the jni.h is under Mac OS X located in:

/System/Library/Frameworks/JavaVM.framework/Headers/

I got this working by adding include path in native/pom.xml

<compilerProvider>generic</compilerProvider>
                    <compilerStartOptions>
                        <compilerStartOption>-fPIC -O -I${basedir}/src/main/native/inc
                            -I/System/Library/Frameworks/JavaVM.framework/Headers
                            -D_GNU_SOURCE -g3 -fno-inline -O0 ${compilerparams}
                        </compilerStartOption>
                    </compilerStartOptions>

Then I had the problem it will not find the OpenAL framework. Therefore I linked OpenAL to XCode Framework of OpenAL and changed #include statements to OpenAL/ instead of AL/ in native/src/main/native/src/openal-audio.c

cd /Library/Frameworks/
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/OpenAL.framework OpenAL.framework
#include <OpenAL/al.h>
#include <OpenAL/alc.h>

OpenAL problem fixed as well, but now it hangs on:

[INFO] --- native-maven-plugin:1.0-alpha-7:link (default-link) @ libjahspotify ---
[INFO] /bin/sh -c cd /Users/basti/git/jahspotify/native && gcc -shared -z defs -o /Users/basti/git/jahspotify/native/target/libjahspotify.so target/objs/audio.o target/objs/Callbacks.o target/objs/JahSpotify.o target/objs/JNIHelpers.o target/objs/Logging.o target/objs/openal-audio.o target/objs/ThreadHelpers.o -lpthread -lspotify -lc -lopenal -ldl -lrt
i686-apple-darwin11-llvm-gcc-4.2: defs: No such file or directory

any further hints? What does 'defs' stays for?

nahojkap commented 11 years ago

looks like GCC does not like the "-z defs" linker options (defined in the lstartopts property). Could you clone the 'NonWindows' profile and make it run on OSX by default? Then override the property -z defs (empty or use --no-undefined which is supposedly the same).

SBejga commented 11 years ago

Alright! Removed -z defs and changed linkeropt of linking openAL with this new default active profile

<profile>
            <id>MacOSX</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <OS>mac</OS>
                <linkeropts>-lspotify -lc -ldl -framework OpenAL</linkeropts>
                <artifact>libjahspotify</artifact>
                <packaging>so</packaging>
                <compilerparams/>
            </properties>
        </profile>

it will build so far! :-) build output: https://dl.dropbox.com/u/28950/jahspotify_mvn_clean_install.txt

But then I will do not get it running. Deployed war files to tomcat will result with this error in contextlistener:

Dec 11, 2012 11:51:47 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Dec 11, 2012 11:51:48 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'echoNestSpotifyBridge': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.QueueManager jahspotify.services.echonest.EchoNestSpotifyBridge._queueManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'queueManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.MediaPlayer jahspotify.services.QueueManager._mediaPlayer; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaPlayer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1247)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:747)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:222)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:187)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.QueueManager jahspotify.services.echonest.EchoNestSpotifyBridge._queueManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'queueManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.MediaPlayer jahspotify.services.QueueManager._mediaPlayer; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaPlayer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 43 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'queueManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.MediaPlayer jahspotify.services.QueueManager._mediaPlayer; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaPlayer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.MediaPlayer jahspotify.services.QueueManager._mediaPlayer; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaPlayer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 56 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaPlayer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 58 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jahspotify.services.JahSpotifyService jahspotify.services.MediaPlayer._jahSpotifyService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 69 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jahSpotifyService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 71 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String jahspotify.services.JahSpotifyService._username; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
    ... 82 more
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'jahspotify.spotify.username'
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:255)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:748)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:717)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 84 more
Dec 11, 2012 11:51:48 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Dec 11, 2012 11:54:08 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()

starting executable will result in this

airbox:jahspotify basti [master] $ java -jar executable-war/target/jahspotify-executable-war-0.0.1-SNAPSHOT.jar 
Failed to load Main-Class manifest attribute from
executable-war/target/jahspotify-executable-war-0.0.1-SNAPSHOT.jar

and starting via

mvn jetty:run  ...

will result in

[INFO] Building jahspotify-root 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> jetty-maven-plugin:7.6.8.v20121106:run (default-cli) @ jahspotify-root >>>
[INFO] 
[INFO] <<< jetty-maven-plugin:7.6.8.v20121106:run (default-cli) @ jahspotify-root <<<
[INFO] 
[INFO] --- jetty-maven-plugin:7.6.8.v20121106:run (default-cli) @ jahspotify-root ---
[INFO] Configuring Jetty for project: jahspotify-root
[INFO] webAppSourceDirectory not set. Defaulting to /Users/basti/git/jahspotify/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /Users/basti/git/jahspotify/target/classes does not exist
[INFO] Context path = /
[INFO] Tmp directory = /Users/basti/git/jahspotify/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = null
[INFO] Webapp directory = /Users/basti/git/jahspotify/src/main/webapp
2012-12-12 00:02:40.057:INFO:oejs.Server:jetty-7.6.8.v20121106
2012-12-12 00:02:40.451:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2012-12-12 00:02:41.032:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebAppContext{/,file:/Users/basti/git/jahspotify/src/main/webapp},file:/Users/basti/git/jahspotify/src/main/webapp
2012-12-12 00:02:41.196:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

but if I open localhost:8080/jahspotify/ it will not find anything like, because displayed pathes are not existing like output says: "[INFO] webAppSourceDirectory not set. Defaulting to /Users/basti/git/jahspotify/src/main/webapp"

nahojkap commented 11 years ago

For you running inside Tomcat - you will need to configure the Spotify username and password - put these properties inside a file called jahspotify-override.properties and place it on Tomcat's classpath - depending on what version you run, I think this is either the conf or lib folder but you might want to double check this.

For running in Jetty, please make sure you are in the web folder when you run the command - from the above, I think you are running in root?

nahojkap commented 11 years ago

could you update your clone and try to build - have applied the profile you created - should hopefully work out of the box now

SBejga commented 11 years ago

thanks for updating. But still on issue if I start it with jetty:

/jahspotify/web $ mvn jetty:run -Djahspotify.spotify.username=<user> -Djahspotify.spotify.password=<pw>

output excerpt

[...]
00:52:59,806  INFO JNILibraryLoader:196 - Extraction Directory: /var/folders/y_/zv5k9qnx32x58zr35fn808dh0000gn/T/
00:52:59,808  INFO JNILibraryLoader:197 - Leave Extracted Resources: Enabled
00:52:59,810  INFO JNILibraryLoader:198 - Overwrite Existing Resources: Enabled
00:52:59,815 ERROR JNILibraryLoader:157 - Extraction failed: Could not find resource libjahspotify.jnilib on class-path
jahspotify.util.JNILibraryLoaderException: Could not find resource libjahspotify.jnilib on class-path
    at jahspotify.util.JNILibraryLoader.extractResource(JNILibraryLoader.java:108)
    at jahspotify.util.JNILibraryLoader.loadLibraryInternal(JNILibraryLoader.java:81)
    at jahspotify.util.JNILibraryLoader.loadLibrary(JNILibraryLoader.java:68)
    at jahspotify.util.JNILibraryLoader.loadLibrary(JNILibraryLoader.java:52)
    at jahspotify.JahSpotifyNativeLoader.loadJahSpotify(JahSpotifyNativeLoader.java:38)
[...]

seems it will not find the jnilib. Any idea how to add it to classpath?

nahojkap commented 11 years ago

It is getting more complicated now :)

The .so file is packaged up into a JAR file - this is done to make sure that JahSpotify can find its native binary without having to have the user install it on the classpath.

Unfortunately, the pom for packaging up the .so file is quite primitive as it stands - it will, for example, only store a single native binary in the jar.

So, to get this running, I would comment out the actual loading/extraction of the jar and before you run jetty, simply add the location of the native binary (native/target directory) to your LD_LIBRARY_PATH. I will think about a better solution in the mean time.

SBejga commented 11 years ago

One stop closer :-)

I commented out the code of function loadLibraryInternal and loaded the libjahspotify.so by absolute path in JNILibraryLoader.class:

System.load("/Users/basti/git/jahspotify/native/target/libjahspotify.so");

Then building and starting jetty. But we get a new error. But now it seems there is a problem with the c binary code.

23:28:57,191 DEBUG NativeLogger:48 - [jnihelpers::JNI_OnLoad] vm: 0x662d708 env: 0x148011d0
23:28:57,194 DEBUG NativeLogger:48 - [jahspotify::JNI_OnLoad] Exiting (result=0x10004)
23:28:57,196 DEBUG NativeLogger:48 - [jahspotify::registerNativeMediaLoadedListener] Registered media loaded listener: 0x14123458

23:28:57,198 DEBUG NativeLogger:48 - [jahspotify::registerNativeSearchCompleteListener] Registered search complete listener: 0x14123450

23:28:57,200 DEBUG NativeLogger:48 - [jahspotify::registerNativePlaybackListener] Registered playback listener: 0x14123448

23:28:57,204 DEBUG NativeLogger:48 - [jahspotify::registerNativeLibraryListener] Registered playlist listener: 0x14123440

23:28:57,207 DEBUG NativeLogger:48 - [jahspotify::registerNativeConnectionListener] Registered connection listener: 0x14123430

Invalid memory access of location 0x0 rip=0x10eb775c8
Segmentation fault: 11
nahojkap commented 11 years ago

Not sure what is going on - have you tried attaching a debugger to see where it crashes?

SBejga commented 11 years ago

I have no experience with debugging of C code. And I think debug of Java code will not go very deeply. But I will do a bit more research when there is more time in the new year.

But thanks for your responses so far!

hyperbad commented 11 years ago

I think I'm experiencing a similar issue. I get a hard crash right after jahspotify::registerNativeConnectionListener.

19:35:25,189 DEBUG NativeLogger:48 - [jahspotify::registerNativeConnectionListener] Registered connection listener: 0x70003208
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f9da48deb9e, pid=15034, tid=140315043235584
#
# JRE version: 6.0_24-b24
# Java VM: OpenJDK 64-Bit Server VM (20.0-b12 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.11.5
# Distribution: Ubuntu 12.04 LTS, package 6b24-1.11.5-0ubuntu1~12.04.1
# Problematic frame:
# C  [libspotify.so.12+0x19db9e]  sp_session_set_private_session+0x298
#
# An error report file with more information is saved as:
# /home/user/workspace/jahspotify/jahspotify-master/hs_err_pid15034.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)
crsharff commented 11 years ago

Was having the same exact problem as hyperbad. It turned out that I needed to create a couple directories:

/var/lib/jahspotify /var/lib/jahspotify/cache

I was not even attemtping this on Mac OS, I was building on Ubuntu 12.10 and using to Jetty to run. This answer proved helpful for more information: http://android-question.blogspot.com/2012/04/libspotifyso12151-segfaults-on-android.html

SBejga commented 11 years ago

Oh yeah! You are right. I just added this two folders and give them ownership of my user and there is no segfault. But after running jetty inside folder "web" and then opening "localhost:8080/jahspotify/" will just log the warning:

2:15:01,256 WARN PageNotFound:1080 - No mapping found for HTTP request with URI [/jahspotify/] in DispatcherServlet with name 'spring'

Update: Oh damn. You have a bad typo in the wiki. It is not index.html it is index.jsp

Finally: IT WORKS! :+1: