How does JRuby resolve gem paths in a jar file? - jruby

I've packaged a custom gem into a jar file which is being referenced by a JRuby script.
I'm getting the following error:
org.jruby.rack.RackInitializationException: JAR entry gems/sinatra-linkedin-auth-0.0.1-java/lib/sinatra/linkedin-auth.rb not found in /Users/bhaidri/code/nextgen-ui/dist/darwin-war/exploded-war/WEB-INF/lib/linkedin-gems-0.0.1.jar
When I inspect my jar file, the linkedin-auth.rb script is indeed there in the correct location. Why is it not being correctly loaded?
Thanks,
Baq

If anybody runs into this situation, please try restarting Tomcat. That resolved the problem for me.

Related

Created jar from JRuby file using warbler. Application exit/goes in a blink when run

I have created a JRuby desktop application. Now I need to create installation file for different platforms(Windows, Linux, Mac).
I have created .jar file using warbler. But when I try to run the .jar, application starts and exit in a blink. It seems application is not crashing as the log says got via java -jar MyApp.jar > log.txt.
Why the application exit, doesn't just stay. Can somebody help me on what I am missing. How I can track the issue?
This answer will help for the issue: JRuby script with Rubeus and Swing exiting once packaged into jar using warble
The workaround described is to put below code in your App's main file
event_thread = nil
SwingUtilities.invokeAndWait { event_thread = java.lang.Thread.currentThread }
event_thread.join

class <cucumber> cannot be resolved to a type - also not able to import cucumber.junit.api.Cucumber

Attached screenshot shows the project setup and jars included. Can somebody please help me what is that I would have done wrong.
Cucumber class is present in cucumber-junit-1.2.5.jar file.
Try to use this dependency: https://mvnrepository.com/artifact/info.cukes/cucumber-junit/1.2.5 in maven.
I tried many ways to resolve this issue, finally I downloaded
this jar file cucumber-junit-1.2.5.jar and then I highlighted my project, then
clicked on Project > Properties> Java Build Path> Libraries>
Maven Dependencies > Add External Jar file .....and opened my downloaded file and
added it to Maven dependencies and error disappeared.

fatal error : sys/syslimits.h No Such file or Directory

I am finding error in compiling my android project containing a sample scoreloop integration in cocos2dx.
Thanks
I faced a similar situation. I figured out it was due to too long directory path. Try to put IDE somewhere else having shorter path.
I had your very same problem. syslimit.h is shipped within the NDK.
Reinstall the NDK and it will work. It worked for me.

Tomcat ServeletException NoClassDefFoundError

I have a webapp I'll call "App1" I am using to create some webplots. I have the .jar files in webapps/App1/lib/ and when I visit the server, I find that I am able to launch some webapps, but others I get funny exceptions. One, being
java.lang.NoClassDefFoundError: Could not initialize class com.jrefinery.chart.JFreeChartConstants
Then, when I add the jfreechart jar to the classpath, I get a different error:
java.lang.NoClassDefFoundError: com/jrefinery/util/ObjectUtils
tomcat version: 7.0.19
OS: ubuntu 12.04
I've tried it on a windows installation and it seems to work just fine. So I'm guessing it's a classpath error? I've tried adding the jfreechart-*.jar to the catalina classpath but it doesn't seem to fix anything. I've also tried to copy the webapp/App1/lib/ jar files to the top level/lib folder and this doesn't fix anything either.
Any ideas here?
Thanks.
You are missing the correct jar file in your project.
The jfreechart project has been repackaged. If you include the old jfreechart-0.9.3.jar, it will fix your compiler errors.
jfreechart-0.9.3.jar
download : http://mirrors.ibiblio.org/pub/mirrors/maven2/jfreechart/jfreechart/0.9.3/jfreechart-0.9.3.jar

How should jruby-jars and jruby-rack be added to the classpath using warbler?

I've been reading through the warbler source code, and I can't figure out how the jruby-jars and jruby-rack jars are meant to end up on the servlet classpath?
It seems warbler is copying them into web-inf/gems/gems/<gemname>/lib/<jarname>.jar but they are not on the classpath.
I'm guessing that if I put them in my ruby apps lib/ folder they would be copied to web-inf/lib and all would be well, however, it seems odd to have 2 copies of the jar in the war file, is that what I am meant to do?
Ben
They should be copied into WEB-INF/lib/.jar. The code for locating the jars is here:
http://github.com/nicksieger/warbler/blob/master/lib/warbler/config.rb#L216-220
And the code that copies them into WEB-INF/lib is here:
http://github.com/nicksieger/warbler/blob/master/lib/warbler/war.rb#L68-70
If you're seeing something else, then it's a bug. Also, you shouldn't have to explicitly state dependencies on the JRuby jar file gems.