Issues trying to build/use relproxy

111 views
Skip to first unread message

Javier Neira Sanchez

unread,
Jan 16, 2014, 7:29:25 AM1/16/14
to relp...@googlegroups.com
Hi, i've downloaded relproxy project from github and i am trying to build/use it in a windows env.
Some thoughts/questions:
* would be possible to build it (including packaging) using only one build tool?
* why does the maven build results in a war?
* would be possible add windows support for console usage ?(i can try to do it)
* is neccesary the itsnat dependency (actually in pom.xml)?

I got the build done running mvn compile before ant -f build_RelProxy.xml (setting maven_folder to target and creating boot folder in it) although the ant build throws a exception in the maven goal:

<pre>
[artifact:mvn] Caused by: java.lang.ClassNotFoundException: org.codehaus.classwo
rlds.Launcher
[artifact:mvn] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[artifact:mvn] at java.security.AccessController.doPrivileged(Native Method)
[artifact:mvn] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[artifact:mvn] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[artifact:mvn] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

[artifact:mvn] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[artifact:mvn] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

[artifact:mvn] Could not find the main class: org.codehaus.classworlds.Launcher.
Program will exit.
[artifact:mvn] Exception in thread "main"
[artifact:mvn] Java Result: 1
[artifact:mvn] java.lang.NoClassDefFoundError: org/codehaus/classworlds/Launcher

[artifact:mvn] Caused by: java.lang.ClassNotFoundException: org.codehaus.classwo
rlds.Launcher
[artifact:mvn] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[artifact:mvn] at java.security.AccessController.doPrivileged(Native Method)
[artifact:mvn] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[artifact:mvn] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[artifact:mvn] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

[artifact:mvn] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[artifact:mvn] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

[artifact:mvn] Could not find the main class: org.codehaus.classworlds.Launcher.
Program will exit.
</pre>

The ant task generates the jar and zip files

If i try to build with ant directly (without previous mvn) it fails due to the same exception.

* Respecting the usage i got a exception trying to run JProxyShell (using built classes or the distributed jar from github):
<pre>
> java -cp target/classes com.innowhere.relproxy.jproxy.JProxyShell ""

Exception in thread "main" java.lang.NullPointerException
at com.innowhere.relproxy.impl.jproxy.clsmgr.comp.JProxyCompilerInMemory
.createJProxyCompilerContext(JProxyCompilerInMemory.java:46)
at com.innowhere.relproxy.impl.jproxy.clsmgr.JProxyEngine.detectChangesI
nSources(JProxyEngine.java:266)
at com.innowhere.relproxy.impl.jproxy.clsmgr.JProxyEngine.init(JProxyEng
ine.java:43)
at com.innowhere.relproxy.impl.jproxy.JProxyImpl.init(JProxyImpl.java:36
)
at com.innowhere.relproxy.impl.jproxy.JProxyShellImpl.init(JProxyShellIm
pl.java:112)
at com.innowhere.relproxy.impl.jproxy.JProxyShellImpl.main(JProxyShellIm
pl.java:26)
at com.innowhere.relproxy.jproxy.JProxyShell.main(JProxyShell.java:13)
</pre>

* Reading the code i think the npe is caused by javax.tools.ToolProvider.getSystemJavaCompiler() returning null, maybe it is due to being a jre the default java installation
* Possible solutions:
** REinstall a jdk without external jre
** Setting the java.home property to a jdk

Javier Neira Sanchez

unread,
Jan 16, 2014, 7:56:03 AM1/16/14
to relp...@googlegroups.com
With
>java -Djava.home="C:\Archivos de pr
ograma\Java\jdk1.6.0_22" -cp target/classes com.innowhere.relproxy.jproxy.JProxy
Shell "System.out.println(\"hola\");"

The "hola" message is rinted

What should be the behaviour with com.innowhere.relproxy.jproxy.JProxy
Shell ""? it doesnt lanch a interactive shell...

Jose Maria Arranz Santamaria

unread,
Jan 16, 2014, 2:40:12 PM1/16/14
to relp...@googlegroups.com

Hi Javier

Come on:

* would be possible to build it (including packaging) using only one build tool?

I agree but I can't with my requirements.

I need a web project to test RelProxy because ItsNat web framework is being used as a proof of concept, I'm using NetBeans for this project (just taste, I use Eclipse in my job), I would like to use Gradle because is a more developer friendly tool and I'm sure the packaging task could be coded in the same file, but Gradle plugin still doesn't support web projects :(

This is why I use Maven for dependencies and compiling (NetBeans works very well with Maven and web projects) and I use Ant to create the distribution file, doing the distribution file with Maven is terrific, with Ant is fairly easy. Ant calls Maven pom.xml to compiling before packaging.

* why does the maven build results in a war?

Because I need a web project for testing and coding examples. The Ant file copies the appropriated files created by Maven to generate the final jar of RelProxy.

I recognize with more work I could create a multi module POM, one to generate the jar, another a web project for testing and examples, but it increases the complexity of the project with no very much gain for me (end users don't care how it was developed).

* would be possible add windows support for console usage ?(i can try to do it)

Use MinGW and optionally (but very recommended) mintty, this is the environment I use at home, ask me if you need more info to setup a Linux-like environment in Windows.
  
* is neccesary the itsnat dependency (actually in pom.xml)?

No, just for testing, RelProxy has NO dependency, just Java 1.6 SDK, if you use Groovy of course you need Groovy "all" jar, but Groovy is no needed when used only with Java. 

* I got the build done running mvn compile before ant -f build_RelProxy.xml

You're using an old version, update to the latest, the file is named distribution.xml now.

I use NetBeans to execute Maven and Ant, your problem of ClassNotFoundException may has to do with Windows environment problems or maybe an environment var is missing or bad defined (Google for " java.lang.ClassNotFoundException: org.codehaus.classworlds.Launcher").

* Reading the code i think the npe is caused by javax.tools.ToolProvider.getSystemJavaCompiler() returning null, maybe it is due to being a jre the default java installation

Right, you MUST use java command of a JDK, take a look to my examples, they are ready to use JAVA_HOME environment var, use MinGW/mintty and be sure shell examples will work in Windows . 

Jose Maria Arranz Santamaria

unread,
Jan 16, 2014, 2:41:23 PM1/16/14
to relp...@googlegroups.com
Update to the latest version... there is a new simple interactive shell!!  It is very simple but enough to use Java like a scripting lang!!

Enjoy

Javier Neira Sanchez

unread,
Jan 16, 2014, 5:53:44 PM1/16/14
to relp...@googlegroups.com
I have updated the version and the println test is succesful with jdk 6 and 7 but the console doent work:

* with jdk 1.6:
>"C:\Program Files\Java\jdk1.6.0_25\bin\java" -Djava.home="C:\Program Files\Java\jdk1.6.0_25" -cp target/classes com.innowhere.relproxy.jproxy.JProxyShell ""

Exception in thread "main" java.lang.NullPointerException
        at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1173)
        at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:1
46)
        at sun.awt.FontConfiguration.<init>(FontConfiguration.java:71)
        at sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:23)

        at sun.awt.Win32GraphicsEnvironment.createFontConfiguration(Win32Graphic
sEnvironment.java:423)
        at sun.java2d.SunGraphicsEnvironment$2.run(SunGraphicsEnvironment.java:2
38)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:
129)
        at sun.awt.Win32GraphicsEnvironment.<init>(Win32GraphicsEnvironment.java
:79)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi
ronment.java:68)
        at java.awt.Robot.<init>(Robot.java:77)
        at com.innowhere.relproxy.impl.jproxy.shell.Keyboard.<init>(Keyboard.jav
a:86)
        at com.innowhere.relproxy.impl.jproxy.shell.WindowUnicodeKeyboard.<init>
(WindowUnicodeKeyboard.java:27)
        at com.innowhere.relproxy.impl.jproxy.shell.JProxyShellProcessor.<init>(
JProxyShellProcessor.java:29)
        at com.innowhere.relproxy.impl.jproxy.JProxyShellInteractiveImpl.<init>(
JProxyShellInteractiveImpl.java:18)
        at com.innowhere.relproxy.impl.jproxy.JProxyShellImpl.main(JProxyShellIm
pl.java:30)
        at com.innowhere.relproxy.jproxy.JProxyShell.main(JProxyShell.java:13)

* with jdk 1.7.0 
>"C:\Program Files\Java\jdk1.7.0_51\bin\java" -Djava.home="C:\Program Files\Java\jdk1.7.0_51" -cp target/classes com.innowhere.relproxy.jproxy.JProxyShell ""
RelProxy Java Shell v0.8
Write help for help
Exception in thread "main" java.lang.InternalError
        at java.util.Currency$1.run(Currency.java:224)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.Currency.<clinit>(Currency.java:192)
        at java.text.DecimalFormatSymbols.initialize(DecimalFormatSymbols.java:5
66)
        at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java:94)
        at java.text.DecimalFormatSymbols.getInstance(DecimalFormatSymbols.java:
157)
        at java.text.NumberFormat.getInstance(NumberFormat.java:767)
        at java.text.NumberFormat.getNumberInstance(NumberFormat.java:407)
        at java.util.Scanner.useLocale(Scanner.java:1230)
        at java.util.Scanner.<init>(Scanner.java:585)
        at java.util.Scanner.<init>(Scanner.java:623)
        at com.innowhere.relproxy.impl.jproxy.shell.JProxyShellProcessor.loop(JP
roxyShellProcessor.java:70)
        at com.innowhere.relproxy.impl.jproxy.JProxyShellInteractiveImpl.init(JP
roxyShellInteractiveImpl.java:32)
        at com.innowhere.relproxy.impl.jproxy.JProxyShellImpl.main(JProxyShellIm
pl.java:31)
        at com.innowhere.relproxy.jproxy.JProxyShell.main(JProxyShell.java:13)
Caused by: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.7.0_51\lib\
currency.data (El sistema no puede encontrar el archivo especificado)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at java.io.FileInputStream.<init>(FileInputStream.java:101)
        at java.util.Currency$1.run(Currency.java:198)
        ... 14 more

I'll try to investigate them

Jose Maria Arranz Santamaria

unread,
Jan 17, 2014, 3:18:39 AM1/17/14
to relp...@googlegroups.com

WOW!! two very different errors just changing the Java version!!

Some ideas:

I can't found  -Djava.home like an standard parameter:

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html

There is a system property named "java.home" but I suppose this property is defined by Java runtime, is not specified you can define it externally and be recognized as the "java home" by the JVM.

Usually there is no need of defining the "java home" because the java command knows how to locate itself, anyway it seems more appropriated to define instead JAVA_HOME as an environment variable:

http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html

I use JAVA_HOME in my scripts, it is recognized by the JVM and in the same time I use it to locate the java command instead of settings PATHs, it works for me in Ming32 environment (with or without mintty)

https://github.com/jmarranz/relproxy/blob/master/cmd/jproxysh

In my opinion both errors has nothing to to with RelProxy and seems related to bad JVM bootstrap because both errors have to do with setting up standard Java classes, for instance, java.util.Scanner.<init>(
Scanner.java:623)  is just the "innocent" call:

new Scanner(System.in,encoding.name());

https://github.com/jmarranz/relproxy/blob/master/src/main/java/com/innowhere/relproxy/impl/jproxy/shell/JProxyShellProcessor.java

I expect this fixes it.

Regards

Javier Neira Sanchez

unread,
Jan 17, 2014, 4:54:28 AM1/17/14
to relp...@googlegroups.com
Mmm i already had the JAVA_HOME env to a jdk:

>set JAVA_HOME
JAVA_HOME=C:\Archivos de programa\Java\jdk1.6.0_14

But i'm afraid my default java installaition is a jre

Finally I get the relproxy shell running in a dos console using the java executable from a jdk without the -Djava.home as you proposed prop:

>"C:\Archivos de programa\Java\jdk1.6.0_22\bin\java"  -cp target/classes com.innowhere.relproxy.jproxy.JProxyShell ""

Javier Neira Sanchez

unread,
Jan 17, 2014, 4:58:07 AM1/17/14
to relp...@googlegroups.com
or exactly like your shell scripts:

>"%JAVA_HOME%\bin\java"  -cp target/classes com.innowhere.relproxy.jproxy.JProxyShell ""

Jose Maria Arranz Santamaria

unread,
Jan 17, 2014, 5:17:54 AM1/17/14
to relp...@googlegroups.com
YEAH!!

In a normal use you just need to add the RelProxy jar to your classpath instead of the development target/classes folder.

Jose Maria Arranz Santamaria

unread,
Jan 23, 2014, 3:42:21 PM1/23/14
to relp...@googlegroups.com
OH NO!!

jproxysh was not in Github repository (.gitignore was avoiding it)  :( 

Now it is there.

Anyway jproxysh is Unix based, with a little work you can make a simple jproxysh.cmd (or .bat) if you want to specify some configuration variable.

I'm not interested on maintaining a Windows version of scripts because MingGW exists.

Jose Maria Arranz Santamaria

unread,
Dec 30, 2014, 12:58:35 PM12/30/14
to relp...@googlegroups.com
Hello Javier

One year later I've published v0.8.1 as you know.

I've splitted relproxy up in two projects, one just with the source code of RelProxy (named "relproxy") including some unit tests and command examples, another one relproxy_test_itsnat project for web testing (it binds the source code of RelProxy not the jar because I need to debug src code). The project example based on GWT (relproxy_ex_gwt) is a conventional Eclipse-GWT project with RelProxy jar dependency. 

I think a grails guy doesn't need RelProxy but I know your curiosity is big :)

Regards
Reply all
Reply to author
Forward
0 new messages