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

Exception causes error string to be interpreted as dependency during resolution #1892

Closed
HaraldKorneliussen opened this Issue Feb 14, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@HaraldKorneliussen

HaraldKorneliussen commented Feb 14, 2017

I have a minimal project based on the integration testing example in the maven bnd tutorial here:

https://github.com/vintermann/mvn-bnd-issue

When I try to build this, I get this error message:

...
[INFO] Matching glob *
[DEBUG] Running file /home/harald/minor-github-work/minimized/integrationtest/itest.bndrun
[DEBUG] Trying pre-plugin aQute.bnd.repository.maven.pom.provider.BndPomRepository
[DEBUG] Found extensions {}
[DEBUG] init
[DEBUG] Line is empty, args=/home/harald/.bnd/default-ws/cnf/cache/3.4.0/bnd-cache
[DEBUG] Trying pre-plugin aQute.bnd.repository.maven.pom.provider.BndPomRepository
[DEBUG] loading augments from file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] cached file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] Unlocking url cache file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] loading augments from file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] cached file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] Unlocking url cache file:/home/harald/.m2/repository/org/osgi/osgi.enroute.pom.distro/2.0.0/osgi.enroute.pom.distro-2.0.0.jar
[DEBUG] org.osgi:osgi.enroute.equinox.log.adapter:2.0.0: get osgi.enroute.equinox.log.adapter;2.0.0.201610141744: starting
[DEBUG] org.osgi:osgi.enroute.equinox.log.adapter:2.0.0: get osgi.enroute.equinox.log.adapter;2.0.0.201610141744: success
[DEBUG] successfully downloaded /home/harald/.m2/repository/org/osgi/osgi.enroute.equinox.log.adapter/2.0.0/osgi.enroute.equinox.log.adapter-2.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.935 s
[INFO] Finished at: 2017-02-14T14:25:59+01:00
[INFO] Final Memory: 14M/202M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-testing-maven-plugin:3.4.0-SNAPSHOT:testing (default) on project org.example.minimized.integrationtest: Unable to resolve <<INITIAL>> version=null: missing requirement java.lang.StringIndexOutOfBoundsException: String index out of range: 42 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal biz.aQute.bnd:bnd-testing-maven-plugin:3.4.0-SNAPSHOT:testing (default) on project org.example.minimized.integrationtest: Unable to resolve <<INITIAL>> version=null: missing requirement java.lang.StringIndexOutOfBoundsException: String index out of range: 42
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to resolve <<INITIAL>> version=null: missing requirement java.lang.StringIndexOutOfBoundsException: String index out of range: 42
	at aQute.bnd.maven.testing.plugin.TestingMojo.execute(TestingMojo.java:87)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 20 more
Caused by: org.osgi.service.resolver.ResolutionException: Unable to resolve <<INITIAL>> version=null: missing requirement java.lang.StringIndexOutOfBoundsException: String index out of range: 42
	at biz.aQute.resolve.ResolveProcess.augment(ResolveProcess.java:228)
	at biz.aQute.resolve.ResolveProcess.augment(ResolveProcess.java:204)
	at biz.aQute.resolve.ResolveProcess.resolveRequired(ResolveProcess.java:77)
	at biz.aQute.resolve.ProjectResolver.resolve(ProjectResolver.java:109)
	at biz.aQute.resolve.ProjectResolver.getRunBundles(ProjectResolver.java:126)
	at aQute.bnd.maven.testing.plugin.TestingMojo.resolve(TestingMojo.java:158)
	at aQute.bnd.maven.testing.plugin.TestingMojo.testing(TestingMojo.java:111)
	at aQute.bnd.maven.testing.plugin.TestingMojo.execute(TestingMojo.java:81)
	... 22 more


It seems at some point a StringIndexOutOfBoundsException is interpreted as a dependency that can't be found. I haven't managed to find out exactly where the exception happens, but it is during resolution some time.

If this compiles for you, I have a hunch that the culprit may be an obnoxious internet filter which gives back a html page when maven asks for a jar, because it thought it saw a virus or a swear word in it or something. Still, it would be nice is the maven plugin was robust enough to give a message about which file couldn't be properly downloaded in such circumstances.

@gamerson

This comment has been minimized.

Show comment
Hide comment
@gamerson

gamerson Feb 14, 2017

Contributor
Contributor

gamerson commented Feb 14, 2017

@HaraldKorneliussen

This comment has been minimized.

Show comment
Hide comment
@HaraldKorneliussen

HaraldKorneliussen Feb 14, 2017

Thanks! it's good to know I don't have to take another round with our zealous guardians at work ;)

I used jdb and found that the error happens at:

Exception occurred: java.lang.StringIndexOutOfBoundsException (to be caught at: aQute.bnd.osgi.resource.RequirementImpl.toString(), line=22 bci=26)"thread=main", java.lang.String.charAt(), line=658 bci=21

HaraldKorneliussen commented Feb 14, 2017

Thanks! it's good to know I don't have to take another round with our zealous guardians at work ;)

I used jdb and found that the error happens at:

Exception occurred: java.lang.StringIndexOutOfBoundsException (to be caught at: aQute.bnd.osgi.resource.RequirementImpl.toString(), line=22 bci=26)"thread=main", java.lang.String.charAt(), line=658 bci=21

@HaraldKorneliussen

This comment has been minimized.

Show comment
Hide comment
@HaraldKorneliussen

HaraldKorneliussen Feb 14, 2017

With the help of the debugger, I found the reason:

-runrequires: \
    osgi.identity;filter:='osgi.identity=org.example.example.provider',\
    osgi.identity;filter:='osgi.identity=org.example.example.test'

should be


-runrequires: \
    osgi.identity;filter:='(osgi.identity=org.example.example.provider)',\
    osgi.identity;filter:='(osgi.identity=org.example.example.test)'

Problem solved for my part, but I still think a nicer error message (vs. interpreting a low-level exception string as a constraint) would be a good thing.

HaraldKorneliussen commented Feb 14, 2017

With the help of the debugger, I found the reason:

-runrequires: \
    osgi.identity;filter:='osgi.identity=org.example.example.provider',\
    osgi.identity;filter:='osgi.identity=org.example.example.test'

should be


-runrequires: \
    osgi.identity;filter:='(osgi.identity=org.example.example.provider)',\
    osgi.identity;filter:='(osgi.identity=org.example.example.test)'

Problem solved for my part, but I still think a nicer error message (vs. interpreting a low-level exception string as a constraint) would be a good thing.

@bjhargrave

This comment has been minimized.

Show comment
Hide comment
@bjhargrave

bjhargrave Feb 14, 2017

Member

I'll try and improve the message.

Member

bjhargrave commented Feb 14, 2017

I'll try and improve the message.

@bjhargrave bjhargrave self-assigned this Feb 14, 2017

@bjhargrave bjhargrave added this to the 3.4 milestone Feb 14, 2017

@gamerson

This comment has been minimized.

Show comment
Hide comment
@gamerson

gamerson Feb 14, 2017

Contributor
Contributor

gamerson commented Feb 14, 2017

bjhargrave added a commit to bjhargrave/bnd that referenced this issue Feb 14, 2017

resource: Better message when parsing invalid filter expression
Fixes bndtools#1892

Signed-off-by: BJ Hargrave <bj@bjhargrave.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment