Java no class def found error elasticsearch? - ruby-on-rails

I followed these steps on https://github.com/karmi/tire to install elasticsearch for use with ruby on rails
curl -k -L -o elasticsearch-0.17.6.tar.gz http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz
tar -zxvf elasticsearch-0.17.6.tar.gz
./elasticsearch-0.17.6/bin/elasticsearch -f
I am running this on MinGW on windows 7, and most of the process went
smoothly.
However, as I try to start the server with ./elasticsearch-0.17.6/bin/
elasticsearch -f I get a java no class def found error:
$ ./elasticsearch-0.17.6/bin/elasticsearch
Exception in thread "main" java.lang.NoClassDefFoundError: org/
elasticsearch/bootstrap/ElasticSearch
Caused by: java.lang.ClassNotFoundException:
org.elasticsearch.bootstrap.ElasticSearch
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class:
org.elasticsearch.bootstrap.ElasticSearch. Program will exit.
What gives?

Mingw translates paths and environment variables into UNIX equivalents. It's designed to work with its own tools, and running something foreign to it, like java.exe, doesn't always work out as you'd expect. In particular, that script builds a Java classpath in the variable ES_CLASSPATH and then passes it to Java using the -cp switch, and I bet it's passing Java a path it simply doesn't understand.
What I would do is find the line that executes java.exe in that script, and make a copy of the line prepended with "echo" so that you can see the command line that's being executed. Then adjust the script to provide a proper Java classpath.

Related

Trying to run curl from Jira

While trying to run CURL command from JIRA i am getting below error:
2017-04-04 18:18:37,351 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-04-04 18:18:37,351 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: JI-1, actionId: 21, file:
java.io.IOException: Cannot run program "curl": CreateProcess error=2, The system cannot find the file specified
at Script147.run(Script147.groovy:47)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
... 1 more
The error suggests that you will need to specify the full path to the curl executable, such as below:
"c:\temp\curl.exe -1 -k ..."
If the curl executable is in a directory that contains spaces, you will either need to add the appropriate quoting to the string or else move the curl executable somewhere that does not have that problem.

swagger-codegen custom generator ClassNotFound

I'm writing a custom generator for swagger-codegen. When I attempt to run the generator with
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i path/to/swagger.json -l com.my.company.codegen.MyGenerator -o outputlocation
it fails with
Can't load config class with name com.my.company.codegen.MyGenerator
... list of built-in generators...
at io.swagger.codegen.CodegenConfigLoader.forName(CodegenConfigLoader.java:31)
at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:286)
at io.swagger.codegen.cmd.Generate.run(Generate.java:186)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.ClassNotFoundException: com.my.company.codegen.MyGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at io.swagger.codegen.CodegenConfigLoader.forName(CodegenConfigLoader.java:29)
... 3 more
I'm not having trouble with any of the built-in generators.
What I did to get here (following the readme):
cloned the project
mvn package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta -o output/myLibrary -n myGenerator -p com.my.company.codegen
and then the above code
I also tried running mvn package again after making my custom generator (which did not make a .jar file anywhere I could find), and tried creating the .jar file myself. Got the same error.
Also FYI, my confusion was definitely increased by some apparent documentation inconsistencies: expected location for my module differs between here and the classname expected here (end of that section). Also, the command for making your own module specifies modules/swagger-codegen-distribution... when I believe it should specify modules/swagger-codegen-cli.... And the guidance in the project readme doesn't seem very congruent with the custom module readme that is generated here.
I don't normally work with Java, so apologies if I'm just missing something super obvious. Thanks in advance for any help!
After trying a bunch of things / internetting, here is what worked:
java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -i path/to/swagger.json -l com.my.company.codegen.MyCustomCodegenGenerator -o outputlocation
Here are the steps I had to take start to finish to create a custom generator:
git clone from source
cd swagger-codegen
mvn package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta -o output/myLibrary -n myCustomCodegen -p com.my.company.codegen. This will create output/myLibrary and subdirectories, where you should find myCustomCodegenGenerator.java ("Generator" is appended to the class name you specify in the command). You should also be able to find the mustache templates within the resources subdirectory.
Make whatever changes you want to myCustomCodegenGenerator.java and the templates.
cd output/myLibrary
mvn package
cd ../..
Now generate your custom library: java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -i path/to/swagger.json -l com.my.company.codegen.MyCustomCodegenGenerator -o outputlocation (building in step 7 should have generated target/myCustomCodegen-swagger-codegen-1.0.0.jar for you)
Notes:
Obviously the cding is based on where I put things, just wanted to be clear on relatively where I was when running commands
If you are just using the default generated base class for your generator (instead of subclassing an existing language), you will get an exception FileNotFound for myCustomCodegen/myFile.mustache -- it's from this optional block which you can just comment out of your custom generator class.
Remember to mvn package your custom module when you make changes
You'll need to include your custom library in the java command. For example:
java -cp path/to/your/jar.com:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
-jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
{args}
Note that if you are attempting to create a generator in Windows and run it from PowerShell, I had to modify #baylee's steps as follows:
mvn install
and
java -cp 'output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar;modules/swagger-codegen-cli/target/swagger-codegen-cli.jar' io.swagger.codegen.Codegen -i path/to/swagger.json -l my-language -o outputlocation

Install grails on ubuntu 13.10 amd64

I am new to use grails and i use amd64's ubuntu 13.10 . When i use gvm to install grails 2.3.2 successfully then type grails create-app test in my bash, it will appear to be some errors as follow:
Loading Grails 2.3.2
Error Error executing script sun.reflect.GeneratedConstructorAccessor1 cannot access
its superclass sun.reflect.ConstructorAccessorImpl
(Use --stacktrace to see the full trace)
When I just type grails,it will appears so errors:
Loading Grails 2.3.2
| Error java.lang.reflect.InvocationTargetException
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:606)
| Error at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:235)
| Error at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:263)
| Error Caused by: java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor1 cannot access its superclass sun.reflect.ConstructorAccessorImpl
| Error at sun.misc.Unsafe.defineClass(Native Method)
| Error at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
| Error at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:399)
| Error at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:396)
| Error at java.security.AccessController.doPrivileged(Native Method)
| Error at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395)
| Error at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:94)
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:48)
| Error at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
| Error at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
...
I also use gvm to install groovy, but when i type groovy, it also has errors.
what's wrong about it ?
Please execute and allow Permission to the entire Grails folder like this one
Make grails executable have the right permission by just typing
`sudo chmod u+x /grailsdirectory/./grails`
`sudo chmod u+x grails-2.3.4 `
`chmod -R 777 /Your/folder/path/`
If you just want to make the files read and write assign permission to 766 instead.
Dude please re-install grails as follow :
sudo add-apt-repository ppa:groovy-dev/grails
sudo apt-get update
sudo apt-get install grails-ppa
to add grails 2.3.0 //in my case
sudo apt-get install grails 2.3.0
Then Don't forget to set permission to grails folder and executable also and Add the nessary environemnt varibles :
your JAVA_HOME directory setting
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.xx
#your GRAILS_HOME directory setting
export GRAILS_HOME=~/grails-1.0-RC2
#your PATH setting to append the Grails bin directory
export PATH=$PATH:$GRAILS_HOME/bin
And , groovy and grails zip package can also be downloaded and extracted to a folder that you want , thens setpermission and then Open or Insatll STS configure grails and groovy thier and ENVIRONEMNTVARIABLES to run grails from Command Line then That is all pretty simple trust me!
Usefull links :
Usefull Links:

OutOfMemoryError creating clover-snapshot in Ant running from QuickBuild

I have a QuickBuild server (5.0.14). This is running a build step using ant.
The Ant target looks like this:
<target name="clover-snapshot" depends="with-clover">
<clover-snapshot file="${clover.snapshot.file}"/>
</target>
We are using Clover Version 3.1.5.
This step is failing with the following stacktrace:-
java.lang.OutOfMemoryError: Java heap space
at com.cenqua.clover.util.CloverBitSet.read(CloverBitSet.java:71)
at com.cenqua.clover.PerTestRecordingTranscript.read(PerTestRecordingTranscript.java:45)
at com.cenqua.clover.RecordingTranscripts.readSliceFromDisk(RecordingTranscripts.java:124)
at com.cenqua.clover.RecordingTranscripts$FileRef.read(RecordingTranscripts.java:354)
at com.cenqua.clover.CoverageDataCollator.collatePerTestRecordings(CoverageDataCollator.java:156)
at com.cenqua.clover.CoverageDataCollator.loadCoverageData(CoverageDataCollator.java:68)
at com.cenqua.clover.CloverDatabase.loadCoverageData(CloverDatabase.java:164)
at com.cenqua.clover.CloverDatabase.loadCoverageData(CloverDatabase.java:159)
at com.cenqua.clover.CloverDatabase.loadWithCoverage(CloverDatabase.java:283)
at com.cenqua.clover.tasks.CloverSnapshotTask.cloverExecute(CloverSnapshotTask.java:51)
at com.cenqua.clover.tasks.AbstractCloverTask.execute(AbstractCloverTask.java:55)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
I take it from the call to invoke() in the above that Clover is being called reflectively within the JVM used by Ant.
As such, I have attempted to allocate more heap space to the Ant JVM. I did this by editing the build step in QuickBuild and specifying the following environment variable:-
ANT_OPTS is set to -Xmx1024m -Xms512m
This has not solved the issue. (I plucked these numbers out of the air, the max size was not calculated in any sort of way.)
My question is, how can I allocate additional heap space to Clover to allow it to execute without running out of memory. Or alternatively, what can I do to confirm these settings are being used?
It looks like you did everything correctly. ANT_OPTS is the right way to solve this problem. I've used pretty much the same approach to solve similar problem. Did you use 64-bit JVM? Did you see that space has been actually allocated?
Anyway, there is a good instruction:
I would also suggest to use VisualVM in order to verify JVM has been created properly and identify the actual cause.
There are two way to increase memory size for ant:
Setting the value of ANT_OPTS property in environment var. For example:
set ANT_OPTS=-Xms256m -Xmx1024m -XX:MaxPermSize=120m
Specifying maxmeory attribute in in ant Java target.
For example:
<target name="MergingHugeJars">
<echo message="Merging jars ${InputJars} into ${OutputJar}"/>
<java jvm="${JVM}" classname="com.krishna.test.MergeHugeJars" fork="true" failonerror="true" maxmemory="512m" >
<arg line="${OutputJar} ${InputJars}"/>
</java>
</target>
You can fiddle with the maxmemory="512m" section of the third line.
You can use jstat to attach to a running java process and see if your settings are being used:
$ jstat -gccapacity 19726
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC
42560.0 681984.0 42560.0 5312.0 5312.0 31936.0 85248.0 1363968.0 85248.0 85248.0 21248.0 169984.0 21248.0 21248.0 0 0
Xmx is the combination of NGCMX and OGCMX. In english, the maximum heap size you specify via -Xmx is split between the Old generation and New generation.
A quick little script to format this information nicely:
jcmd | grep -v JCmd | while read pid name; do echo -n "Xmx for $name "; jstat -gccapacity $pid | sed '1d' | awk '{ print $2 + $8 " MB" }'; done
Xmx for org.example.MyClass 2045952 MB

Ant: exec executable:error code 99

We are building our app on Linux using Ant and compilation is fine and during deploy on websphere (deploy-build.xml) we are using below code
<exec executable="${shell.cmd}" failonerror="true">
<arg line="${wsadmin.cmd} -conntype ${wsadmin.conntype} -profileName ${was.profile} ${security.options} -lang jython -f ${scripts.dir}/app-server/jy/install-app.jy ${archive.location}"/>
</exec>
<echo message="${app.name} (${archive.location} deployed." />
from logs we can see install-app.jy execution is successful. But still we are facing below error:
BUILD FAILED
/home/EBbuild/env-build/b4b/env-build.xml:50: The following error occurred while executing this line:
/home/EBbuild/env-build/deploy-build.xml:185: exec returned: 99
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: /home/EBbuild/env-build/deploy-build.xml:185: exec returned: 99
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:636)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:662)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:487)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
in above error message line 185 is exec code pasted above
We are using bash shell (linux)
RC=99 originates from your Jython script, look at the source.
Use either ant -d env-build.xml (as David already mentioned) or :
<echoxml>
<exec executable="${shell.cmd}" failonerror="true">
<arg line="${wsadmin.cmd} -conntype ${wsadmin.conntype} -profileName ${was.profile} ${security.options} -lang jython -f ${scripts.dir}/app-server/jy/install-app.jy ${archive.location}"/>
</exec>
</echoxml>
to see how your properties are resolved / how your Jython script is actually executed.
Afterwards start your Jython script standalone in bash (as David already mentioned) for further investigations.Don't know Jython, but maybe it has a commandline parameter to increase it's noiselevel !?
Is this the Windows cmd.exe you're executing as ${shell.cmd}?
If so, you may need to add /c as the first argument to your command line.
You may also want to try using ant -d (capture the output, it will produce quite a bit) to show you more details what is going on.
This will show you the actual command line being executed, and it might help you find errors. At least you can then run the commend directly from the command line.
There's no special meaning assigned to an exit code of 99. It maybe that your command is executing, hitting an issue and returning an exit code of 99.
It's really hard to say right now without the information from ant -d.

Resources