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

Could not find or load main class org.apache.ibatis.migration.Migrator #58

Open
svscorp opened this issue Oct 25, 2016 · 10 comments
Open

Comments

@svscorp
Copy link

svscorp commented Oct 25, 2016

Hi @harawata @kazuki43zoo @hazendaz,

I am trying to use the tool (MyBatis Migrations) 3.2.1 to automate DB changes for my Oracle instance. Almost done that (99% of the DB initiation) and Friday ran into the issue that is (what I think) is described here: #46

CREATE OR REPLACE EDITIONABLE TRIGGER "TST_TRGR"
BEFORE INSERT ON sometable 
FOR EACH ROW

BEGIN
  SELECT runid.NEXTVAL
  INTO    :new.runid
  FROM   dual;
END;

ALTER TRIGGER "TST_TRGR" ENABLE; 

Then I went to #46 and there it was mentioned to use -- @DELIMITER. It is available in 3.3.0 but I haven't found any downloadable 3.3.0-SNAPSHOT archive that I can use to proceed further.

If I use something that is in master right now (builded it with maven) - I am getting the below error just trying to run migrate info:

Could not find or load main class org.apache.ibatis.migration.Migrator

Can you support/check on this?

@svscorp
Copy link
Author

svscorp commented Oct 25, 2016

I can't use "send_full_script=true" because it doesn't work.
I can't use another "delimiter=GO" because than I'll have to replace it in 10k lines of SQL code + people who works with me will have to keep it in mind always when adding new migrations -> human errors chance is big.

@harawata
Copy link
Member

harawata commented Oct 25, 2016

I am not sure if I understand your problem, but the error message implies that the mybatis-migrations.jar is not found in the classpath.

Here is how to use mybatis-migrations 3.3.0-SNAPSHOT.

  1. Download and extract the latest bundle.zip from the snapshot repository.
  2. Follow the installation instruction.

This should allow you to use the -- @Delimiter ; syntax in migration scripts.

@svscorp
Copy link
Author

svscorp commented Oct 25, 2016

Hi @harawata,

Thanks for your quick reply. Well, what I have done:

  1. built latest master
  2. unzipped the bundle.zip into My work folder
  3. followed installation instructions you mentioned
  4. tried to run "migrate info"

Same way works with 3.2.1.

@harawata
Copy link
Member

harawata commented Oct 25, 2016

Have you tried the bundle.zip downloaded from the snapshot repository instead of the one that you built?
I just downloaded and verified the contents of the mybatis-migrations-3.3.0-20161010.132840-10-bundle.zip and it's working correctly.

I am using Mac OS X 10.12.1 / Java 1.8.0_111

@svscorp
Copy link
Author

svscorp commented Oct 25, 2016

Hi @harawata

I've just done it.

here is the screenshot: mybatis-cli-envvars

mybatis-cli-run

(Windows 7, Java 1.8.0_111, GitBash, If I use 3.2.1 archive from the website - it works)

Can it be an issue in Win + 3.3.0-SNAPSHOT?

I'll check on a linux VM (no doubts it is working on your machine, need to find out why 3.3.0-SNAPSHOT doesn't work on mine, while 3.2.1 does).

@harawata
Copy link
Member

harawata commented Oct 25, 2016

If you are on Windows, it could be an issue with the migrate.cmd file.
Could you check the content and see if anything is wrong?

@harawata
Copy link
Member

harawata commented Oct 25, 2016

You are using MinGW, so migrate.cmd is not related, I guess.

What happens if you execute the java command directly in the lib directory?

$ cd /c/tmp/mybatis-mygrations-3.3.0-SNAPSHOT/lib
$ java -classpath mybatis-migrations-3.3.0-SNAPSHOT.jar:mybatis-3.4.1.jar org.apache.ibatis.migration.Migrator info

@svscorp
Copy link
Author

svscorp commented Oct 25, 2016

That's what I found:

migrate

In version 3.2 bin/migrate contains ENDORSED_DIR= while 3.3. ENDORSED_DIR=lib. If I remove lib it works.

@svscorp
Copy link
Author

svscorp commented Oct 25, 2016

I can remove <endorsedDir>lib</endorsedDir> from pom.xml and make a PR (it is committed in 1f13528 ). But maybe it was done on purpose.

Though, I am not sure why is it lib there (shouldn't it be lib/endorsed?). Share your vision :)

@harawata
Copy link
Member

harawata commented Oct 27, 2016

The endorsedDir was added to load 3rd party JSR-223 libraries.
See the last section of the doc.

As the script (bin/migrate) is generated by appassembler-maven-plugin, if adding endorsedDir breaks the launcher script, it may be the plugin's bug.
Reading the script, there are some classpath fix for cygwin, so similar workaround might be necessary for MinGW.

If there is an alternative way to allow users to add 3rd party JARs to the classpath, I would consider adopting it, of course.

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

2 participants