keke357 / netlogo-sql

Automatically exported from code.google.com/p/netlogo-sql
0 stars 0 forks source link

Sql extensions not working with applet #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. includes[sql] in a model
2.save the model as an applet
3.try to run the applet in a browser

What is the expected output? What do you see instead?
The model is supposed running. Instead I got a message: " Code: Can't open 
extension http://localhost:8080/Simulation/sql/sql.jar"

What version of the product are you using? On what operating system?
I use NetLogo 5.0.2 on a windows 7 with Java 6.

I would be happy to know if you think it's possible to resolve that issue? And 
how long it would take.

Do you know if it could have compatibility issues if the client uses Java 7.

Thanks

Original issue reported on code.google.com by delay.ma...@gmail.com on 28 Mar 2013 at 8:31

GoogleCodeExporter commented 9 years ago
I am not entirely sure what is causing the error, but most likely this error is 
caused by not including the jar files of the extension on the webserver. 
However as I have never used the netlogo applets I am not entirely sure how 
this works. I guess that the folder of Simulation should contain a folder sql 
which contains sql.jar and the other dependencies of netlogo-sql.

That said even if this would resolve this specific error, you will run into 
additional problems: Connecting to database servers from applets is very hard 
to do because it (usually) requires the applet to be signed to allow access to 
a database server, and that database server needs to be reachable for all users 
of the applet which in itself poses a significant security risk (especially if 
the applet is to be available on the internet).

Given these problems and inherent security issues we never considered support 
for applets with netlogo-sql. I will see if I can include some additional 
information in the manual to get it to run, but I would strongly advice against 
it.

Original comment by MHGRotte...@gmail.com on 29 Mar 2013 at 1:37

GoogleCodeExporter commented 9 years ago
Thanks for the quick answer.

The folder Simulation contains already a folder sql that contains the
sql.jar.
I tried currently with the Simulation folder in the www folder of a wamp
server.
The sql.jar is accessible but can't be open by the applet.

For me, the easiest way to bring my model to internet is to use applet. I
tried using hubnet and displaying a client applet but this applet is not
working with Java 7.

You can find my topic in netlogo-devel where we talk about the
possibilities to bring my game in a browser:
https://groups.google.com/forum/?fromgroups=#!topic/netlogo-devel/SPeZ8MxYLW0

Original comment by delay.ma...@gmail.com on 29 Mar 2013 at 2:11

GoogleCodeExporter commented 9 years ago
The only other problem I can think of is that it can load the sql.jar, but not 
the other required jar files. I will see if I can get a simple model to run, 
but like most Java developers I know next to nothing of applets.

Original comment by MHGRotte...@gmail.com on 29 Mar 2013 at 2:22

GoogleCodeExporter commented 9 years ago
Ok let me know if you find a solution. Thanks!

Original comment by delay.ma...@gmail.com on 29 Mar 2013 at 4:22

GoogleCodeExporter commented 9 years ago
Hi,
Any progress on this issue? Can I help with something?

Original comment by delay.ma...@gmail.com on 5 Apr 2013 at 6:31

GoogleCodeExporter commented 9 years ago
I have looked into it and you should be able to get it to work if you do the 
following:
1. Sign all the jar files for the applet
2. Include all the jar files of the sql extension in the archive list of the 
applet tag

For point 1 you will need to create a keypair using keytool, and obtain a 
certificate for it. See 
http://docs.oracle.com/javase/7/docs/technotes/guides/plugin/developer_guide/rsa
_signing.html for details. For testing purposes you should be able to use a 
self-signed certificate, but if you want to deploy to the internet you will 
need to get a certificate signed by a Certificate Authority; this usually costs 
money.

With the signed key, you can then use jarsigner to sign all(!) jar files needed 
for running the applet:
* NetLogoLite.jar
* sql/bonecp-0.7.0.jar
* sql/guava-r07.jar
* sql/mysql-connector-java-5.1.19.jar
* sql/postgresql-9.1-901.jdbc4.jar
* sql/slf4j-api-1.5.10.jar
* sql/slf4j-simple-1.5.10.jar
* sql/sql.jar

For point 2 you will need to change the html file of the applet to refer to all 
jar files needed. The archive attribute of applet will need to be changed to:
archive="NetLogoLite.jar,sql/sql.jar,sql/bonecp-0.7.0.jar,sql/guava-r07.jar,sql/
mysql-connector-java-5.1.19.jar,sql/postgresql-9.1-901.jdbc4.jar,sql/slf4j-api-1
.5.10.jar,sql/slf4j-simple-1.5.10.jar"

If you don't use postgresql (or mysql) you can leave its driver out; if you use 
a different database then you need to sign and include its driver as well.

I'd strongly suggest to try this with a self-signed certificate before going 
through the hassle of obtaining a CA-signed certificate.

Original comment by MHGRotte...@gmail.com on 6 Apr 2013 at 9:12