jcman jcsearch with function exec in php

User 26c54ae8b9

31-12-2008 00:44:34

Dear Chemaxon,





Info : Linux Fedora - jchem 5.1.4 - apache 2 - Mysql





TEST 1 :





I execute jcsearch with php function :


exec (sh "/var/www/test/jchem/bin/jcsearch -q "CC" -f sdf -o /var/www/test/resultat/res.sdf /var/www/test/jchem/bin/MOLECULESbdd2.SDF'");





When i use a SDF file with jcsearch it's ok.





TEST 2 :


I execute jcsearch with php function again but with a database mysql :





$cmd='sh /var/www/test/jchem/bin/jcsearch -q "CC" -f :Tcd_id DB:molecules -o /var/www/test/resultat/res.txt;


exec ($cmd);





When i use a connection with a database it doesn't work, and i can't catch error message.





Info :


-I have execute in command line jcman with option --saveconf and i have a file .jchem in directory /var/www/.chemaxon.


-I have export CLASSPATH for drivers JAVA.


-The user mysql "bdkarim" have full access to my database.


- My Php web page is executed by user "apache". With command line with user apache it's ok.





Do you have an idea ?





Thanks,





Karim.

ChemAxon 9c0afc9aaf

02-01-2009 18:37:25

Hi,
Quote:
When i use a connection with a database it doesn't work, and i can't catch error message.
You should be able to see error messages by redirecting them to a file via standard stderr redirection e.g. :





<command> 2> error.txt





This topic may or may not be helpful, also PHP problems (turned out the enviroment setting for the PHP user were a bit different):


http://www.chemaxon.com/forum/viewpost17739.html&highlight=php#17739





Best regards,





Szilard

User 26c54ae8b9

02-01-2009 21:22:55

Hi Szilard,





Thanks for response but i can't catch error with 2>err.txt. The file is not created.





I have seen the post, but i don't need licence for jcsearch utilitie. So it's not the same problem.





If you have an idea, i will be very greatfull,





Karim.

User 26c54ae8b9

04-01-2009 18:11:00

Finally i can catch error...apache user have now access to write.


I have this error :





Cannot connect:


java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver


at java.net.URLClassLoader$1.run(URLClassLoader.java:199)


at java.security.AccessController.doPrivileged(Native Method)


at java.net.URLClassLoader.findClass(URLClassLoader.java:187)


at java.lang.ClassLoader.loadClass(ClassLoader.java:289)


at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)


at java.lang.ClassLoader.loadClass(ClassLoader.java:235)


at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)


at java.lang.Class.forName0(Native Method)


at java.lang.Class.forName(Class.java:141)


at chemaxon.util.ConnectionHandler.setConnected(ConnectionHandler.java:196)


at chemaxon.util.ConnectionHandler.connect(ConnectionHandler.java:234)


at chemaxon.jchem.Command.run(Command.java:555)


at chemaxon.jchem.Command.main(Command.java:201)





My CLASSPATH is initialialised and the directory have all access (chmod 777).





TOMCAT 5 not use CLASSPATH i think...





An idea ?





Thanks


Karim.

ChemAxon e274e1bada

05-01-2009 15:06:06

Hi Karim,





I don't understand your problem very well. The jcsearch and Tomcat are two different things. jcsearch is a standalone Java application and it doesn't need any connection with Tomcat.


It seems, the mysql driver is not in your CLASSPATH.





Edvard

User 26c54ae8b9

05-01-2009 16:19:40

Sorry...i try again...





So, jcsearch must have CLASSPATH initialised.


With command line, jcsearch is OK because i have initialised CLASSPATH.





But, with a web page (PHP), i have a message error because my web server doesn't use CLASSPATH. So, jcsearch is KO.





Is it possible to use jcsearch/jcman with mysql database without CLASSPATH ?


I want to use jcsearch/jcman with mysql but without CLASSPATH because i don't know how to parameter my web server (APACHE).


Actually, i use jdbc driver for mysql.





Thanks,


Karim.

User 26c54ae8b9

05-01-2009 20:45:26

I have found the solution :


I have initialised "CLASSPATH" and restart httpd (/etc/init.d/httpd restart).





Thanks,





This post is closed.





Karim.