Thanks Guillaume ,
I printed the variable java_cmd :
print ('Java_cmd : %s' %java_cmd)
subprocess.call(java_cmd, env=os.environ)
Then parsed the generated string to run the application and it starts
successfully from the command line.
But when I tried to make it as a "srvany" based Windows service It
failed to run, after a lot of work I found two issues:
First : there is a 259 characters limitation (And I have a very huge
classpath) to be provided as a command in the Registry "service-name
\Parameters\Application" key .
Second : It substitutes the ";" with " " (spaces)
To overcome these issues I shrank the classpath by moving the Play
jars to "C:\p\" directory, then I tried to set the Windows environment
variable CLASSPATH, But apparently commands running from the registry
can no see the windows environment variables.
So I added a new registry Multi-line String value "service-name
\Parameters\AppEnvironment" , It contains CLASSPATH=My very big semi
colon separated classpath jars.
In the registry key "service-name\Parameters\Application" I added Its
value to be :
"C:\Program Files\Java\jdk1.6.0_13\bin\java" -javaagent:C:
\play-1.0.3.2\framework/play.jar -Dapplication.path=c:\dirX\playAppDir
-Dplay.id= play.server.Server
This workaround worked SUCCESSFULLY .
But I had another problem however this command runs successfully from
the command-line and connects successfully to SQL Server 2005, It
fails to connect to the SQL Server when I run as windows service.
I tried to change the Service Log on configuration to use "NT AUTHORITY
\NetworkService" instead of logging on as Local system account , But
still I get this error message :
2010-10-06 10:30:14 INFO ~ Starting c:\dirX\playAppDir
2010-10-06 10:30:14 INFO ~ Module secure is available (c:\dirX
\playAppDir\.\modules\secure)
2010-10-06 10:30:14 INFO ~ Precompiling ...
2010-10-06 10:30:46 ERROR ~ Cannot connected to the database : The TCP/
IP connection to the host 127.0.0.1, port 1433 has failed. Error:
"Unrecognized Windows Sockets error: 10106: create. Verify the
connection properties, check that an instance of SQL Server is running
on the host and accepting TCP/IP connections at the port, and that no
firewall is blocking TCP connections to the port.".
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection
to the host 127.0.0.1, port 1433 has failed. Error: "Unrecognized
Windows Sockets error: 10106: create. Verify the connection
properties, check that an instance of SQL Server is running on the
host and accepting TCP/IP connections at the port, and that no
firewall is blocking TCP connections to the port.".
at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:
171)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:
1033)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:
817)
at
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:
700)
at
com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:
842)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at play.db.DBPlugin.onApplicationStart(DBPlugin.java:46)
at play.Play.start(Play.java:381)
at play.Play.init(Play.java:247)
at play.server.Server.main(Server.java:85)
P.S : My connection string is :
db.url=jdbc:sqlserver://
127.0.0.1;databaseName=My_DB;user=sa;password=secret
P.P.S : SQL Server TCP/IP is enabled and accepts remote connections .
Thanks in advance,
On Sep 30, 5:12 pm, Guillaume Bort <
guillaume.b...@gmail.com> wrote:
> You don't really need python. You can run the JVM directly. Have a
> look at the Java process run by python and start the same directly.
>
>
>
>
>
>
>
>
>
> On Thu, Sep 30, 2010 at 3:30 PM, MonTarO <
ahmed.rif...@gmail.com> wrote:
> > Hello All,
>
> > Thanks to this article (the last reply)
> >
http://groups.google.com/group/play-framework/browse_thread/thread/e6...
> > I made a newservicecalled (PlayServ)
> > Theapplicationreally started onWindowsstartup and using the
> > sysinternals process explorer, the processes tree were in this tree :
> > +srvany
> > +python
> > +java
> > When I manually stop theservice(PlayServ), It killed the (srvany)
> > process and its first child only (python), SO (java) process still
> > alive; It means that theapplicationis still UP.
> > --------------------------------------------------------------------------- ----------------------------------------------
> > I tried the way mentioned here to run a batch file as awindows
> >service :
> >
http://www.mike-tech.com/article.php?gif=win2k&article=135
>
> > the same scenario happened but the tree was like :
> > +srvany
> > +cmd
> > +python
> > +java
>
> > when trying to stop theserviceIt killed (srvany) and the first child
> > only (cmd) and left (python) and (java) running ..The same problem.
> > --------------------------------------------------------------------------- ----------------------------------------------
> > I triedhttp://
www.firedaemon.com/firedaemon-pro.phpand It really
> > worked Like expected, but unfortunately its not free !
>
> > Is there any other scenario to run aPLAYapplicationa aWindows
> >Servicecan be started/Stopped safely ?
>
> > Million Thanks in advance ,
>
> > --
> > You received this message because you are subscribed to the Google Groups "play-framework" group.
> > To post to this group, send email
toplay-f...@googlegroups.com.
> > To unsubscribe from this group, send email
toplay-framewo...@googlegroups.com.
> Guillaume Bort,
http://guillaume.bort.fr
> write
guillaume.b...@gmail.com