Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not find or load main class sqlline.SqlLine #69

Closed
lucacerone opened this issue Oct 6, 2017 · 11 comments
Closed

Error: Could not find or load main class sqlline.SqlLine #69

lucacerone opened this issue Oct 6, 2017 · 11 comments

Comments

@lucacerone
Copy link

Hi, this is probably a mistake on my side but I couldn't understand how to install/run properly sqlline I fear.

I downloaded the source zip file for the 1.3.0 release. I unzipped it in a folder and from a terminal and within the sqlline folder I run:

mvn package

Some of the tests failed, but I can't understand why:

Running sqlline.SqlLineTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.245 sec - in sqlline.SqlLineTest
Running sqlline.SqlLineArgsTest
java.lang.IllegalArgumentException: No current connection
	at sqlline.SqlLine.getConnection(SqlLine.java:388)
	at sqlline.Commands.nativesql(Commands.java:350)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
	at sqlline.SqlLine.dispatch(SqlLine.java:791)
	at sqlline.SqlLine.runCommands(SqlLine.java:1706)
	at sqlline.SqlLineArgsTest.testNPE(SqlLineArgsTest.java:557)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.executeTestMethod(JUnit4TestRunnerDecorator.java:162)
	at mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.invokeExplosively(JUnit4TestRunnerDecorator.java:71)
	at mockit.integration.junit4.internal.MockFrameworkMethod.invokeExplosively(MockFrameworkMethod.java:37)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ][ Hit "enter" for more ("q" to exit) ]java.io.FileNotFoundException: /tmp/sqllinenegative7589320866135718635temp (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileInputStream.<init>(FileInputStream.java:93)
	at java.io.FileReader.<init>(FileReader.java:58)
	at sqlline.Commands.run(Commands.java:1267)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
	at sqlline.SqlLine.dispatch(SqlLine.java:791)
	at sqlline.SqlLine.initArgs(SqlLine.java:595)
	at sqlline.SqlLine.begin(SqlLine.java:643)
	at sqlline.SqlLineArgsTest.run(SqlLineArgsTest.java:78)
	at sqlline.SqlLineArgsTest.runScript(SqlLineArgsTest.java:102)
	at sqlline.SqlLineArgsTest.runScript(SqlLineArgsTest.java:85)
	at sqlline.SqlLineArgsTest.testNegativeScriptFile(SqlLineArgsTest.java:493)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.executeTestMethod(JUnit4TestRunnerDecorator.java:162)
	at mockit.integration.junit4.internal.JUnit4TestRunnerDecorator.invokeExplosively(JUnit4TestRunnerDecorator.java:71)
	at mockit.integration.junit4.internal.MockFrameworkMethod.invokeExplosively(MockFrameworkMethod.java:37)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Tests run: 22, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 3.02 sec - in sqlline.SqlLineArgsTest

Results :

Tests run: 25, Failures: 0, Errors: 0, Skipped: 1

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sqlline ---
[INFO] 
[INFO] --- maven-javadoc-plugin:2.9.1:jar (attach-javadocs) @ sqlline ---
[INFO] 

Despite the failure I tried to go in the bin directory and run

./sqlline

which produced the error

Error: Could not find or load main class sqlline.SqlLine

I also tried to not build the package and run the sqlline executable that comes in the bin folder.

Could you please help me to figure out what I am doing wrong? Could it be because there is no jdbc driver in the folder? if that's the problem, I have several JDBC drivers already installed in some directory, is there any way I can make them "visible" to sqlline regardless of the directory where I am running sqlline?

Thanks for the help and apologies for the silly questions.
Luca

@julianhyde
Copy link
Owner

Your tests were successful. I just downloaded the 1.3 tar file and did mvn package and got the same results. Note that it says Tests run: 25, Failures: 0, Errors: 0, Skipped: 1, that is, no test errors or failures.

Sorry the output looks a bit scary; we are executing negative tests, to make sure that sqlline does the right thing even if it can't connect to the database.

I get the same problem with the sqlline command. I edited it as follows:

BINPATH=$(dirname $0)
exec java -cp $BINPATH/../target/sqlline-1.3.0-jar-with-dependencies.jar sqlline.SqlLine "$@"

and it worked (except that it printed "??" as the version).

Most projects that use sqlline have a launcher script that pull in sqlline and other dependencies via maven; see e.g. https://github.com/apache/calcite/blob/master/sqlline.

@lucacerone
Copy link
Author

Thanks a lot for your answer Julian!

I understood the part regarding the tests, I am sorry not to have figured it myself.

About sqlline, if I understood correctly I have to modify the script then?
What about the drivers? Does sqlline always have to be in the same directory with the tars of a JDBC driver? or I can pass somehow the directory where they are stores? or should I make sure the CLASSPATH variables contains the directory where JDBC drivers are stored?

Thanks again for your help with this!

@julianhyde
Copy link
Owner

Yes, you need to modify the script. This is typical for Java programs. Put the drivers after the -cp argument in the command, separated by colons (or semi-colons on windows). Or you can put them in the CLASSPATH variable, but most people prefer the -cp argument these days.

@lucacerone
Copy link
Author

Many thanks @julianhyde !

@julianhyde
Copy link
Owner

Fixed in 2b403a6; thanks for the PR, @snuyanzin!

@elenac5
Copy link

elenac5 commented Jan 11, 2019

Your tests were successful. I just downloaded the 1.3 tar file and did mvn package and got the same results. Note that it says Tests run: 25, Failures: 0, Errors: 0, Skipped: 1, that is, no test errors or failures.

Sorry the output looks a bit scary; we are executing negative tests, to make sure that sqlline does the right thing even if it can't connect to the database.

I get the same problem with the sqlline command. I edited it as follows:

BINPATH=$(dirname $0)
exec java -cp $BINPATH/../target/sqlline-1.3.0-jar-with-dependencies.jar sqlline.SqlLine "$@"

and it worked (except that it printed "??" as the version).

Most projects that use sqlline have a launcher script that pull in sqlline and other dependencies via maven; see e.g. https://github.com/apache/calcite/blob/master/sqlline.

Where can I make these changes??

@snuyanzin
Copy link
Collaborator

if you use sqlline 1.5.0+ then all changes are already there and you can use scripts bin/sqlline, bin\sqlline.bat. Otherwise you could make changes in these scripts or in a script you use to run sqlline

@elenac5
Copy link

elenac5 commented Jan 11, 2019

Yes, I have these scripts. But should I simply add those 2 lines of code?

@snuyanzin
Copy link
Collaborator

you can just simply update them in a way it was done in PR #100 (direct link to file diff https://github.com/julianhyde/sqlline/pull/100/files).

@elenac5
Copy link

elenac5 commented Jan 12, 2019

Here is the code of sqlline.bat file: https://codeshare.io/5OoeBg
And here of sqlline file: https://codeshare.io/5QqdQW

I don't know where I can add those modifications.

@snuyanzin
Copy link
Collaborator

snuyanzin commented Jan 12, 2019

it looks like you use Drill's customizations of these files (https://github.com/apache/drill/blob/e9c7f51e8a6b4c4be95fc3aef05b89596414e98d/distribution/src/resources/sqlline).
It is better to ask people from Drill in that case.
Could you please raise an a question in Drill's jira https://issues.apache.org/jira/projects/DRILL ?

cc @arina-ielchiieva , @vvysotskyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants