I am trying to run my job using SpringBatch-CommandLineJobRunner on Linux, I have the below jars in classpath.
Can anyone please take a look and see If I am missing any jars and tell me the missing jars. In our project they dont want to use any tools like Maven or STS, we are just using eclipse, our jobs run well from eclipse. On Linux we get the below errors.. we are using below command
java -cp org.springframework.batch.core.launch.support.CommandLineJobRunner springbatch/config/applicationBatchContextPlan.xml crossRefAllPlansJob
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/batch/core/launch/support/CommandLineJobRunner
Jars in Classpath on linux :
springbatch/lib/aopalliance-1.0.jar
springbatch/lib/commons-collections-3.2.1.jar
springbatch/lib/commons-lang3-3.3.2.jar
springbatch/lib/commons-lang3-3.3.2-javadoc.jar
springbatch/lib/commons-logging-1.2.jar
springbatch/lib/javax.batch-api-1.0.jar
springbatch/lib/log4j-1.2.17.jar
springbatch/lib/ojdbc6.jar
springbatch/lib/spring-aop-4.1.7.RELEASE.jar
springbatch/lib/spring-aspects-4.1.7.RELEASE.jar
springbatch/lib/spring-batch-core-3.0.4.RELEASE.jar
springbatch/lib/spring-batch-infrastructure-3.0.4.RELEASE.jar
springbatch/lib/spring-beans-4.1.7.RELEASE.jar
springbatch/lib/spring-context-4.1.7.RELEASE.jar
springbatch/lib/spring-core-4.1.7.RELEASE.jar
springbatch/lib/spring-expression-4.1.7.RELEASE.jar
springbatch/lib/spring-jdbc-4.1.7.RELEASE.jar
springbatch/lib/spring-retry-1.1.2.RELEASE.jar
springbatch/lib/spring-tx-4.1.7.RELEASE.jar
Also, I want to know if there is any other way we can run spring batch jobs on linux without using the CommandLineJobRunner.
Based looking at this post and this post, you need to manually include all the jars on your classpath.
So basically:
java -cp ... org.springframework.batch.core.launch.support.CommandLineJobRunner springbatch/config/applicationBatchContextPlan.xml crossRefAllPlansJob
The first post has a handy shell script to help with this.
In terms of other deployment options, you can deploy a spring batch application anywhere you can deploy spring (e.g. servlet container). Generally though, if it is the principal thing going on in the app, a plain old jar is probably the simplest option.
The problem is resolved since a couple of days. The jars in the classpath were not getting picked up properly.After a couple of retries, it did and its working as expected now
Thanks to everyone for helping.
Thanks
Lakshmi
Related
I have been struggling for many hours on trying to deploy a simple HelloWorld webservice written in java on a windows 7 (later ill need on linux) pc.
Most of the examples I found (from general places, and others questetions on stackoverflow) didn't work or used deprecated versions of jersey and other librarys.
My goal, is to write a webservice in java, where coding it should be easy and so does deploying it. It doesn't need to suuport anything special regarding the amount of request running and performance (my requirements are minimum)
Frommy research, I have come to believe the use of jersey with embeded netty web service should anser what I was looking for (if someone knows better, I would also like to hear about it, tough it isn't my main problem in this questetion but might just be an alternative solution)
I have came across this eaxmple:
jersey2-jetty-example
It gives you a working project with the dependencies needed from maven to run jersey and jetty embedded server (which can be run as a standalone jar which is exactly the kind of easy deploy im looking for)
I cloned the example and got everything running. I had problems importing it to eclipse, so I used the following command on the example folder:
mvn -DoutputDirectory=./lib dependency:copy-dependencies
which will give you a copy of the lib folder of the deps from maven needed,
then I created a java project with this lib folder in the build path and same source code as the sample, and all worked good.
The problem occurs when I try to take this java project and export it as an runnable jar (with the source files included option !).
I can then use java -jar to run the service, but when I try to access it from the browser (same as used in when I run it from eclipse), it never works, im always getting error 404 for the same routes that worked a second ago when running from eclipse. I couldn't figure out whats the source of the problem or what eclipse does differently that makes it behave in a different fashion.
I have found the reason the jar didn't work while in eclipse it did work, it was because of a duplicate jar that I was importing the caused the problem. The jars I got from maven in the git sample had 2 duplicate jars called hamcrest-all and hamcrest-core. removing one of them from the project build path fixed the problem.
If someone can answer the other open ended questetion that I asked, which is if using jersey and jetty like this is the best solution for my requirments I will be happy to hear about it
I know this question might have already been answered but i havn't found a proper answer.
I am using hadoop mapreduce on eclipse and i want to create an executable jar to put it on a linux server where there is my hdfs cluster. The problem when i run the jar on my hdfs cluster and eclipse, there is exception appearing caused by java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory. So I added an external jar common-logging but when i run it again and another NoClassDefFoundError appeared but this time with log4j-level and so on. I wondered how many external jar i had to add but i don't think that it's the best solution. Does anyone have the same problem and how did you solve it ?
Thank you very much.
Usually, this error occurs when a previous exception occurred during logging initialisation.
Hadoop is quite fickle about dependencies, you should either make sure that your third party libs are part of your hadoop classpath or create a shaded jar with all dependencies in your job jar. You should use maven or assembly to create that jar.
I'm trying to deploy a few bundles I implemented along all the required bundles from Eclipse in order to run my own. Let's say, include the Equinox container also with my bundles so it is like an executable old-school JAR.
That said, when I try to run
java -jar org.eclipse.osgi_3.8.1.v20120830-144521.jar
Nothing happens...it just stays there doing nothing...even if I copy just that bundle to some other place and try the same, nothing happens...is this usual? I mean, I have done this successfully with older versions of this bundle (3.6) and it worked flawlessly.
Alas, I tried -debug flag to see if I could get some output, but only a complain about mission .options file is happening, nothing else.
Thanks,
Alex
Just in case someone has the same problem...having checked this link: http://docs.codehaus.org/spaces/flyingpdf/pdfpageexport.action?pageId=82903240, I created the configuration folder, a config.ini in it with the following contents:
osgi.bundles=org.eclipse.equinox.common#start, org.eclipse.update.configurator#start,
org.eclipse.core.runtime#start, org.eclipse.core.jobs#start,
org.eclipse.equinox.registry#start, org.eclipse.equinox.preferences#start,
org.eclipse.core.contenttype#start, org.apache.felix.gogo.runtime#start,
org.apache.felix.gogo.shell#start,
org.eclipse.equinox.app#start,org.eclipse.equinox.console#start,
eclipse.ignoreApp=true
osgi.noShutdown=true
This seems to work. I believe this is the minimum set of bundles required to run the Equinox OSGi container...from there, you can use the osgi shell to play with your bundles
You havent included -console option, that is the one that will open up the console view right?
I want to be able to easily debug an OSGi bundle running in Apache Karaf from Eclipse. The easiest way I've identified so far is to create a Java Application launcher that starts Karaf. If the bundle was previously installed then I can set breakpoints, even in the activator, and all is good.
The issue is that when a change is made to the code, mvn install invoked, and then the Eclipse Karaf launcher invoked, I am running the old cached version of the bundle. I have played with running Karaf from the command line, installing my bundle with a Maven URL, and using dev:watch with success. But I have found that the dev:watch URLs are not persisted. Thus, when starting Karaf from Eclipse, there are no watched URLs (the previous ones were lost when Karaf was shutdown) and new versions of the bundle are not installed.
Is there a way to get the dev:watch URLs to be persistent? I looked for either properties that might hold the URLs or even Karaf command line options that could be used to specify the URLs with no luck. I even tried to add the dev:watch command to etc/shell.init.script but I get this message at Karaf startup “Error in initialization script: Command not found: dev:watch.” I assume this means the command was run too early in the Karaf startup sequence (dev feature not yet started?).
Any help would be appreciated, even alternate ways I haven’t considered to easily debug bundles running in Karaf from Eclipse. The goal is to avoid needing to use manual commands such as osgi:install every time the code changes.
The Karaf team is now also working on a better integration with EIK, but at the current time it's not yet as deeply integrated as it would be needed.
Therefore your provided way is basically the best way in doing debugging.
Build your application with maven, do a dev:watch when your karaf is up and running.
Since dev:watch is a "Development-Time" command it's not intended to be persistent. But you still have the history to choose from and of course you're able to provide multiple bundle IDs to the command.
I am developing a server with Jetty (servlet container). I am successfully running the server within Eclipse with an osgi-framework run configuration. Everything fine.
What is the best way to export this run configuration so that I have a valid config.ini and all plugins (the workspace bundles and the ones from my target platform) and am able to run the osgi-framework without Eclipse IDE running.
I tried to make a product to get the config.ini and all the bundles but I cannot run the framework with java -jar org.eclipse.osgi_3.6.2.R36x_v20110210.jar.
It is not finding the bundles in the plugin folder, because obviously the names do not match exactly (e.g.: com.mine.at-3.3.-3234234.jar instead of com.mine.at.jar)
There are about 150 bundles and I do not want to edit the config.ini manually.
What did I miss?
What worked pretty well for me was to make a new product, based on the (working) run configuration, and export the product. That project should then be 'runnable', or at least pretty close.
Did you try that?
Hope it helps, Frank