Command line REPL does not set runtime classpath with DYNJS_OPTS #92

Closed
lance opened this Issue Jan 2, 2014 · 10 comments

Comments

Projects
None yet
2 participants
@lance
Member

lance commented Jan 2, 2014

https://gist.github.com/lance/c2c6bd79923684373ef8

This is the root cause for problems seen with ActiveMQConnectionFactory as reported on the mailing list. This issue supercedes and closes #91

@ghost ghost assigned lance Jan 2, 2014

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Jan 2, 2014

Member

This happens because ./bin/dynjs uses the -jar option when running the REPL. As noted in the java tool docs [1] this causes the JRE to ignore any other classpath settings.

[1] http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

Member

lance commented Jan 2, 2014

This happens because ./bin/dynjs uses the -jar option when running the REPL. As noted in the java tool docs [1] this causes the JRE to ignore any other classpath settings.

[1] http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 6, 2014

Member

for setting the classpath during runtime I've come up with this dirty API:

dynjs console.
Type exit and press ENTER to leave.
dynjs> dynjs.addClassPathEntry("/Users/qmx/dev/dynjs-0.2.2-SNAPSHOT/activemq-all-5.9.0.jar")
undefined
dynjs> org.apache.activemq.ActiveMQConnectionFactory.DEFAULT_BROKER_URL
failover://tcp://localhost:61616
dynjs>

this is living on 7c389f5 for the moment

@lance thoughts on this?

Member

qmx commented Mar 6, 2014

for setting the classpath during runtime I've come up with this dirty API:

dynjs console.
Type exit and press ENTER to leave.
dynjs> dynjs.addClassPathEntry("/Users/qmx/dev/dynjs-0.2.2-SNAPSHOT/activemq-all-5.9.0.jar")
undefined
dynjs> org.apache.activemq.ActiveMQConnectionFactory.DEFAULT_BROKER_URL
failover://tcp://localhost:61616
dynjs>

this is living on 7c389f5 for the moment

@lance thoughts on this?

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Mar 6, 2014

Member

Seems reasonable. Will we still be able to use command line flags? I think
that's important too.

Another, possibly an obscure option, would be to use the 'use' directive as
a quoted expression. E.g. "use dynjs.classpath /some/path/to/my.jar";

I like this because it's completely portable (in the sense that it won't
cause a type error in a non-DynJS environment). But I think it might
require a change in the parser, which is maybe non-optimal.

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

for setting the classpath during runtime I've come up with this dirty API:

dynjs console.Type exit and press ENTER to leave.dynjs> dynjs.addClassPathEntry("/Users/qmx/dev/dynjs-0.2.2-SNAPSHOT/activemq-all-5.9.0.jar")undefineddynjs> org.apache.activemq.ActiveMQConnectionFactory.DEFAULT_BROKER_URLfailover://tcp://localhost:61616dynjs>

this is living on 7c389f57c389f5 the moment

@lance https://github.com/lance thoughts on this?

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36824395
.

Lance Ball
http://lanceball.com

Member

lance commented Mar 6, 2014

Seems reasonable. Will we still be able to use command line flags? I think
that's important too.

Another, possibly an obscure option, would be to use the 'use' directive as
a quoted expression. E.g. "use dynjs.classpath /some/path/to/my.jar";

I like this because it's completely portable (in the sense that it won't
cause a type error in a non-DynJS environment). But I think it might
require a change in the parser, which is maybe non-optimal.

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

for setting the classpath during runtime I've come up with this dirty API:

dynjs console.Type exit and press ENTER to leave.dynjs> dynjs.addClassPathEntry("/Users/qmx/dev/dynjs-0.2.2-SNAPSHOT/activemq-all-5.9.0.jar")undefineddynjs> org.apache.activemq.ActiveMQConnectionFactory.DEFAULT_BROKER_URLfailover://tcp://localhost:61616dynjs>

this is living on 7c389f57c389f5 the moment

@lance https://github.com/lance thoughts on this?

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36824395
.

Lance Ball
http://lanceball.com

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 6, 2014

Member

fwiw, I'm not happy with the method names

Member

qmx commented Mar 6, 2014

fwiw, I'm not happy with the method names

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 6, 2014

Member

@lance I went this route just to avoid cmdline, tbh - it would end up with me doings lots of magic on the shell scripts - if you pass a second -cp it overwrites the former :(

another option would be using classworlds, which might make @bobmcwhirter super happy

Member

qmx commented Mar 6, 2014

@lance I went this route just to avoid cmdline, tbh - it would end up with me doings lots of magic on the shell scripts - if you pass a second -cp it overwrites the former :(

another option would be using classworlds, which might make @bobmcwhirter super happy

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Mar 6, 2014

Member

Remove "Entry"; I think it's redundant. :)

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

fwiw, I'm not happy with the method names

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36825045
.

Lance Ball
http://lanceball.com

Member

lance commented Mar 6, 2014

Remove "Entry"; I think it's redundant. :)

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

fwiw, I'm not happy with the method names

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36825045
.

Lance Ball
http://lanceball.com

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 6, 2014

Member

Ideally we would do like jruby and mimick an array, so dynjs.classpath.unshift("activemq-all-5.9.0.jar") would work fine - but at the same time I'm worried of making it appear as something "mutable", since that's not the case... at all

Member

qmx commented Mar 6, 2014

Ideally we would do like jruby and mimick an array, so dynjs.classpath.unshift("activemq-all-5.9.0.jar") would work fine - but at the same time I'm worried of making it appear as something "mutable", since that's not the case... at all

@lance

This comment has been minimized.

Show comment
Hide comment
@lance

lance Mar 6, 2014

Member

Yeah, I understand that. That ball of wax is why I deferred this issue for
so long. But if it can be done programmatically, as in your example, then
we can probably use something like system properties or environment
variables to make it settable from the command line, right? Or maybe I'm
just making this too complicated.

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

@lance https://github.com/lance I went this route just to avoid
cmdline, tbh - it would end up with me doings lots of magic on the shell
scripts - if you pass a second -cp it overwrites the former :(

another option would be using classworlds, which might make @bobmcwhirterhttps://github.com/bobmcwhirtersuper happy

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36825114
.

Lance Ball
http://lanceball.com

Member

lance commented Mar 6, 2014

Yeah, I understand that. That ball of wax is why I deferred this issue for
so long. But if it can be done programmatically, as in your example, then
we can probably use something like system properties or environment
variables to make it settable from the command line, right? Or maybe I'm
just making this too complicated.

On Wednesday, March 5, 2014, Douglas Campos notifications@github.com
wrote:

@lance https://github.com/lance I went this route just to avoid
cmdline, tbh - it would end up with me doings lots of magic on the shell
scripts - if you pass a second -cp it overwrites the former :(

another option would be using classworlds, which might make @bobmcwhirterhttps://github.com/bobmcwhirtersuper happy

Reply to this email directly or view it on GitHubhttps://github.com/dynjs/dynjs/issues/92#issuecomment-36825114
.

Lance Ball
http://lanceball.com

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 6, 2014

Member

hmm, we could cheat and use something like -Ddynjs.extra.classpath, then load it during the boot

Member

qmx commented Mar 6, 2014

hmm, we could cheat and use something like -Ddynjs.extra.classpath, then load it during the boot

@qmx

This comment has been minimized.

Show comment
Hide comment
@qmx

qmx Mar 26, 2014

Member

fixed at 4c68c1c

/V/v/g/dynjs git:master ❯❯❯ dynjs -cp target/fixtures/vraptor-authz-0.2.jar --console
dynjs console.
Type exit and press ENTER to leave.
dynjs> var me = Packages.me;
undefined
dynjs> typeof me.qmx.vraptor.authz.AuthzInfo
java.lang.Class
dynjs>
Member

qmx commented Mar 26, 2014

fixed at 4c68c1c

/V/v/g/dynjs git:master ❯❯❯ dynjs -cp target/fixtures/vraptor-authz-0.2.jar --console
dynjs console.
Type exit and press ENTER to leave.
dynjs> var me = Packages.me;
undefined
dynjs> typeof me.qmx.vraptor.authz.AuthzInfo
java.lang.Class
dynjs>

@qmx qmx closed this Mar 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment