You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Anazys - Apache <ap...@anazys.com> on 2008/07/15 10:26:46 UTC

[users@httpd] RewriteMap with Java

Hi all,

I try tu use a RewriteMap to rewrite dynamically urls on MacOS 10.5  
Leopard Server. The code is really simple in the http.conf file :

	RewriteMap    mymap       prg:/path/to/map.class
	RewriteRule   ^/path/(.*)$  /path/page?${mymap:$1}

But when I launch Apache, I have this message in error log :
	[Mon Jul 14 15:47:43 2008] [error] (86)Bad CPU type in executable:  
exec of '/etc/apache2/Main.class' failed

Anybody knows what could be the problem ?
Is it possible tu use a Java file for RewriteMap ?

Thanks for your help
Cedric.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteMap with Java & RewriteLock

Posted by Eric Covener <co...@gmail.com>.
On Wed, Jul 16, 2008 at 10:49 AM, Anazys - Apache <ap...@anazys.com> wrote:
> My Java class read from stdin (System.in), the main problem is the loop :
> with the "while read text", there is an infinite loop.
>
> But when I only write a call from the shell to the java class :
>        #!/bin/sh
>        java -classpath /path/to/java/class/ MainClass
> It work perfectly the first time but nothing after this first call. It's
> normal because there isn't any loop, but i don't know how to write this loop
> in the shell script.

It's a bug in your java code. It should be able to read until stdin is closed.



-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteMap with Java & RewriteLock

Posted by Anazys - Apache <ap...@anazys.com>.
My Java class read from stdin (System.in), the main problem is the  
loop : with the "while read text", there is an infinite loop.

But when I only write a call from the shell to the java class :
	#!/bin/sh
	java -classpath /path/to/java/class/ MainClass
It work perfectly the first time but nothing after this first call.  
It's normal because there isn't any loop, but i don't know how to  
write this loop in the shell script.

Thanks for your help Eric.


Le 16 juil. 08 à 15:38, Eric Covener a écrit :

> On Wed, Jul 16, 2008 at 3:01 AM, Anazys - Apache <ap...@anazys.com>  
> wrote:
>> Thanks for your answer. I already try this but when I write this  
>> script, I
>> don't know how to handle the loop with stdin (in the shell script  
>> or in the
>> java file ?) :
>> I try this in the shell :
>>       #!/bin/sh
>>       while read text
>>       do
>>               java -classpath /path/to/java/class/ MainClass
>>       done
>
>
> Your java class should read from stdin.
>
> -- 
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server  
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteMap with Java & RewriteLock

Posted by Eric Covener <co...@gmail.com>.
On Wed, Jul 16, 2008 at 3:01 AM, Anazys - Apache <ap...@anazys.com> wrote:
> Thanks for your answer. I already try this but when I write this script, I
> don't know how to handle the loop with stdin (in the shell script or in the
> java file ?) :
> I try this in the shell :
>        #!/bin/sh
>        while read text
>        do
>                java -classpath /path/to/java/class/ MainClass
>        done


Your java class should read from stdin.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteMap with Java & RewriteLock

Posted by Anazys - Apache <ap...@anazys.com>.
Thanks for your answer. I already try this but when I write this  
script, I don't know how to handle the loop with stdin (in the shell  
script or in the java file ?) :
I try this in the shell :
	#!/bin/sh
	while read text
	do
		java -classpath /path/to/java/class/ MainClass
	done


But it don't seem to work..

I didn't manage to configure the lock file, could it be the main  
problem ?
I just add "RewriteLock /etc/apache2/myLock.lock" in my http.conf  
file. But apache server simply don't start with that, without any  
error in the log file. I try creating the file or not, with chmod 777.  
But I think I miss something.

Somebody could help ?
Thanks
Cedric

Le 15 juil. 08 à 13:28, Eric Covener a écrit :

> On Tue, Jul 15, 2008 at 4:26 AM, Anazys - Apache <ap...@anazys.com>  
> wrote:
>> Hi all,
>>
>> I try tu use a RewriteMap to rewrite dynamically urls on MacOS 10.5  
>> Leopard
>> Server. The code is really simple in the http.conf file :
>>
>>       RewriteMap    mymap       prg:/path/to/map.class
>>       RewriteRule   ^/path/(.*)$  /path/page?${mymap:$1}
>>
>> But when I launch Apache, I have this message in error log :
>>       [Mon Jul 14 15:47:43 2008] [error] (86)Bad CPU type in  
>> executable:
>> exec of '/etc/apache2/Main.class' failed
>>
>> Anybody knows what could be the problem ?
>> Is it possible tu use a Java file for RewriteMap ?
>>
>
> You need to write a shell script that launches java class, and use the
> script in your Apache config. Class files are not executables.
>
>
> -- 
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server  
> Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteMap with Java

Posted by Eric Covener <co...@gmail.com>.
On Tue, Jul 15, 2008 at 4:26 AM, Anazys - Apache <ap...@anazys.com> wrote:
> Hi all,
>
> I try tu use a RewriteMap to rewrite dynamically urls on MacOS 10.5 Leopard
> Server. The code is really simple in the http.conf file :
>
>        RewriteMap    mymap       prg:/path/to/map.class
>        RewriteRule   ^/path/(.*)$  /path/page?${mymap:$1}
>
> But when I launch Apache, I have this message in error log :
>        [Mon Jul 14 15:47:43 2008] [error] (86)Bad CPU type in executable:
> exec of '/etc/apache2/Main.class' failed
>
> Anybody knows what could be the problem ?
> Is it possible tu use a Java file for RewriteMap ?
>

You need to write a shell script that launches java class, and use the
script in your Apache config. Class files are not executables.


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org