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

Missing Import-package MANIFEST.MF headers for postgresql #1033

Closed
aegyed opened this issue Jun 16, 2015 · 2 comments
Closed

Missing Import-package MANIFEST.MF headers for postgresql #1033

aegyed opened this issue Jun 16, 2015 · 2 comments
Labels
Milestone

Comments

@aegyed
Copy link
Contributor

@aegyed aegyed commented Jun 16, 2015

In the rare cases when someone tries to use PostgreSQL COPY FROM STDIN statements in OSGi environment, one will come to receive strange ClassNotFoundExceptions as follows:

[2015-06-16 15:47:40.146] DEBUG region-dm-13 org.flywaydb.core.internal.dbsupport.SqlScript Executing SQL: COPY addresses (id, version, city, country, postal_code, street, tenant_id, address_type) FROM stdin;
sdfgsdfgf 0 sgsdfgd HU 1117 Ott 031448de-5d3b-11e1-a2f6-842b2b8ba9fe 1
[2015-06-16 15:47:40.228] ERROR region-dm-13 org.eclipse.virgo.medic.eventlog.default AG0000E Application context creation failure for bundle 'ths-med-server-plan2.plan-1.8.0.SNAPSHOT-ths-server-api' version '1.8.0.SNAPSHOT'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'coreSchemaMigrator' defined in URL [bundleentry://213.fwk1355906755/META-INF/spring/module-context.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/postgresql/copy/CopyManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/postgresql/copy/CopyManager
at org.flywaydb.core.internal.dbsupport.postgresql.PostgreSQLDbSupport.executePgCopy(PostgreSQLDbSupport.java:110)
at org.flywaydb.core.internal.dbsupport.SqlScript.execute(SqlScript.java:112)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:71)
at org.flywaydb.core.internal.command.DbMigrate$5.doInTransaction(DbMigrate.java:287)
at org.flywaydb.core.internal.command.DbMigrate$5.doInTransaction(DbMigrate.java:285)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
at org.flywaydb.core.internal.command.DbMigrate.applyMigration(DbMigrate.java:285)
at org.flywaydb.core.internal.command.DbMigrate.access$800(DbMigrate.java:46)
at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:207)
at org.flywaydb.core.internal.command.DbMigrate$2.doInTransaction(DbMigrate.java:156)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:72)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:156)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:972)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:919)
at org.flywaydb.core.Flyway.execute(Flyway.java:1320)
at org.flywaydb.core.Flyway.migrate(Flyway.java:919)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 19 common frames omitted
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.postgresql.copy.CopyManager in KernelBundleClassLoader: [bundle=org.flywaydb.core_3.1.0]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 42 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.postgresql.copy.CopyManager
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:146)
... 43 common frames omitted

This could be avoided if we could have correctly filled MANIFEST.MF with the flyway-core package.

I guess it would be easy to add to the pom.xml the following lines (with appropriately set versions) in the section of maven-bundle-plugin configuration:

org.postgresql.copy;version="[9.3.1102,10.0)";resolution:=optional,
org.postgresql.core;version="[9.3.1102,10.0)";resolution:=optional,

I did not check, but there may be some other missing optional imports that should be added so OSGi users can use this tool with full functionality.

I would also recommend revising the LOG.debug("Executing SQL: " + sql); line in SqlScript.java
at least in cases when isPgCopy() is true, as this will copy the whole one million inserted records to the log when debug is enabled.

@axelfontaine axelfontaine added this to the Flyway 4.0 milestone Jun 17, 2015
@aegyed
Copy link
Contributor Author

@aegyed aegyed commented Jun 22, 2015

As far as I could check these are the remaining missing optional imports:

android.content;version="[4.0.1.2,5)";resolution:=optional,
android.content.pm;version="[4.0.1.2,5)";resolution:=optional,
android.content.res;version="[4.0.1.2,5)";resolution:=optional,
android.util;version="[4.0.1.2,5)";resolution:=optional,
dalvik.system;version="[4.0.1.2,5)";resolution:=optional,
org.jboss.vfs;version="[3.1.0,4)";resolution:=optional,

axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Oct 28, 2015
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Oct 28, 2015

Thank for researching this! Truly appreciated!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.