Re: using Servlet Filter to rewrite domain of JSESSIONID cookie?

2010-07-02 Thread André Warnier

Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Nikita,

On 7/1/2010 6:37 PM, Nikita Tovstoles wrote:

I borrowed sub-domain from Google Analytics terminology. I have one
server, running one tomcat instance with one virtual host. That host is
running one app - a JS/html widget that is embedded on multiple sites.

We need to track usage per-deployment (per site embedding the wiget). For
(google) analytics purposes, the easiest way to do so is to have a different
(sub)domain per deployment. So the same tomcat instance is responding to
requests for site1.widget.com, site2.widget.com, etc.

a user may interact with 2 widget deployed on 2 different sites (and thus
served from different (sub)domains) within 30 minutes. It is for this case
that we want user to share the same HttpSession:

- go to some site A where our widget is deployed at site1.widget.com
- go to some other site B where our widget is deployed at site2.widget.com
- reuse the same JSESSIONID because its' domain is set to .widget.com


This sounds like a job for a non-JSESSIONID cookie that is created from
your own code.


+1

But I am still lost as to what you are calling sites and subdomains and deployed at 
site1.widget.com.

If I follow the explanation above, you have something like this :
Host name=localhost appBase=webapps
 Aliassite1.widget.com/Alias
 Aliassite2.widget.com/Alias
 Aliassite3.widget.com/Alias
 Aliassite4.widget.com/Alias
...
/Host

Is that it ?
And if so, where is the widget-webapp deployed (on disk), and how many times 
really ?

I am not trying to be a pedant, just to make sure I understand the layout, so that we 
might maybe come up with a suggestion to solve your problem (even if it is not by changing 
the JSESSIONID cookie domain)



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: SSL and non SSL configuration on tomcat 6.0.26, confused

2010-07-02 Thread Pid
On 01/07/2010 20:11, John-Paul Ranaudo wrote:
 I wish I could provide more information. At least I have narrowed down
 the problem. I am having a meeting with the architects of both
 frameworks today so perhaps I'll get some details.

Given some examples of URLs that fail, and bits of code/HTML/JSP that
are relevant would be a start.


p

 Thanks.
 
 On Thu, Jul 1, 2010 at 2:54 PM, Pid p...@pidster.com
 mailto:p...@pidster.com wrote:
 
 On 01/07/2010 19:38, John-Paul Ranaudo wrote:
  I did more tracing and remote debugging and I was mistaken (too many
  late nights). Each framework is sending us the request via port
 80. The
  problem comes from the fact the one of the frameworks uses HTTPS
 before
  the load balancers so when we send back a redirect it is using the
 wrong
  scheme. HTTP instead of HTTPS. I need a way of knowing which framework
  made the request so I can alter the scheme on redirect for just
 the one
  framework.
 
  btw, the frameworks are proprietary and much like existing portal
  frameworks.
 
  So I am wondering if I can do this with virtual hosts or somehow
 detect
  the incoming URL to tell which domain its coming from and handle
  appropriately.
 
 I wondering too, but mostly because you're not really giving us any real
 information about what's happening.
 
 The word 'framework' might mean something specific to you, but it
 doesn't help me understand what's happening on your server(s).
 
 We can't help you without accurate and detailed information.
 
 
 I /guess/ that virtual hosts won't help you.
 
 I /guess/ that the domain it's coming from won't matter so much as the
 domain requested.
 
 
 p
 
 
 
  On Thu, Jul 1, 2010 at 11:31 AM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com wrote:
 
  On 01/07/2010 16:01, John-Paul Ranaudo wrote:
   I am confused no doubt. What you say here is correct:
  
   /In your description of the issue so far, you've said that the
   application *is* using SSL.  The load-balancers might be
  terminating it
forwarding unencrypted connections/
   /
   /
   /I think I understand what you mean by redirecting. Our current
   configuration. Framework A does not use SSL thus uses connector
  port 80.
   Framework B, the problem, uses SSL/port 443. /
 
  It might help illuminate matters if you explain exactly what
 Frameworks
  A  B actually are.  Are they separate web applications?  How
 do they
  relate to each other, are they on separate URLs?
 
   Connector port=80 protocol=HTTP/1.1
 connectionTimeout=2 /
   (Used by framework A)
   Connector port=443 protocol=HTTP/1.1
 connectionTimeout=2
   scheme=https secure=true / (Used by framework B)
  
   Now I could change the port 80 connector to have a redirectPort
   attribute like so:
  
   /
   Connector port=80 protocol=HTTP/1.1
 connectionTimeout=2
   redirectPort=443/
  
   The problem with this approach is that framework A which
 does not use
   SSL now will use it via he redirect port. We'll then get the
 same
  mixed
   content warnings in the browser.
 
  It won't use it unless it's told to.  So what's telling it to?
 
  As far as I can see, there's nothing stopping the whole site
 running
  under 443, which would prevent you seeing mixed content errors.
 
  Have you identified exactly which resources are being served
 via HTTP
  within an HTTPS page?  What are they?
 
 
  p
 
   I hope this explains the problem more clearly.
   /
   /
  
  
   Redirecting as I explained below just means that you can
  upgrade to
   HTTPS for specific paths.  The load-balancer still
 handles it.
  
  
If we use anything that forces SSL it will fail for
 the other
   framework which does
not use SSL.
  
   Why?
  
   How are you switching back to HTTP for 'the other
 framework',
  once the
   user has been on a page served under HTTPS?
  
  
   p
  
  
On Thu, Jul 1, 2010 at 3:59 AM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com
mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com 

Re: Tomcat 6.0.26 with Java 6 update 20 on Sun Solaris 5.8 Sparc - Web application unable to execute properly

2010-07-02 Thread Mikolaj Rydzewski

On 07/02/2010 01:23 AM, rahul wrote:
1. I tried building the war in Windows and worked fine. I transferred 
the war to UNIX, it mis-behaves as described earlier.

2. I tried building the war in UNIX, it mis-behaves as described earlier. I 
transferred the war to Windows and it worked fine.
   


I guess there are jsp:include page / and %@ include file % 
directives in you webapp. Check them for case sensitivity.



--

Mikolaj Rydzewskim...@ceti.pl


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



JNI error under tomcat: java.lang.UnsatisfiedLinkError

2010-07-02 Thread dennis ch
Hi,

I have a java class (eval.java) that invokes a native method in an so file
(libmodel.so, using SWIG 1.3.29 to generate JNI code/wrapper and compiled
the library). I can use System.loadLibrary() to load the libmodel.so without
any error (-Djava.library.path=/usr/lib), and the native method initModel()
works fine as a standalone application.

However, when I deploy it as a web service (tomcat 6.0.26 + axis2 1.5.1 +
eclipse jee helios) to call the native method, I got the following error
(the first line means the .so was successfully loaded):

Load library successfully

[ERROR] com.model.modelJNI.initModel()V
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
at 
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
at 
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at 
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at 
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.UnsatisfiedLinkError: com.model.modelJNI.initModel()V
at com.model.modelJNI.initModel(Native Method)
at com.model.model.initModel(model.java:13)
at com.webservice.run(EvalVita.java:763)
... 25 more


Below is the body of Eval.java:

import com.model.*;

public class Eval {

  static void loadModel() {

try {
System.loadLibrary(model);

System.out.println(Load library successfully);

} catch (UnsatisfiedLinkError e) {

System.err.println(Native code library failed to load. + e);

}
  }
  public void run() {

loadModel();
model.initModel();
  }
}


Do I miss anything here?  Any input is appreciated!

Dennis


Re: [OT] Using httpd's mod_rewrite with mod_jk

2010-07-02 Thread André Warnier

Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rainer,

On 7/1/2010 4:54 AM, Rainer Jung wrote:

Usually mod_rewrite is perfectly compatible with mod_jk. I must confess,
that I'm not 100% sure about the case, where you try to rewrite a
request that originally would have been handled by mod_jk to something
that should not be handled by it.


It appears that my setup (rewriting a request that normally would go to
jk to one that shouldn't go to jk) still ends up being handled by jk.


Christopher,

I personally find it hard to visualise when exactly in the Apache request handling cycle 
the JkMount directive intervenes.  Like, /before RewriteRule/ or /after RewriteRule/.
I am sure that it is at a very specific place in the cycle and with a very specific 
precedence, but neither the Apache httpd nor the mod_jk documentation explicitly indicate 
this (*).  (Unlike, for example, in this page, where the precedence is clear : 
http://httpd.apache.org/docs/2.2/sections.html#mergin)

And if even Rainer isn't sure..

That is why, with Apache/mod_jk, I tend to prefer working with the alternative to JkMount 
explained here (at the very end of the page) : 
http://tomcat.apache.org/connectors-doc/reference/apache.html

(section: Using SetHandler and Environment Variables)

To me, this makes it clearer, because the proxying to Tomcat is now embedded in a 
Location section, which has a clear precedence in the Apache configuration logic.


Using that syntax, the directives

JkMount /context/some-specific-path/foo workerX
JkMount /context/some-other-path/bar workerX
JkMount /context/*.do workerX
JkMount /context/*.jsp workerX

would be expressed as

Location /context/some-specific-path
  # covers the 1st one above
  setHandler jakarta-servlet
  SetEnv JK_WORKER_NAME workerX
  # but, as an example, exclude some URLs from the proxying
  SetEnvIf REQUEST_URI \.(css|gif|jpe?g|js)$ no-jk
  ...
/Location
...
LocationMatch /context/.*\.(do|jsp)$
  # covers #3 and #4 above
  setHandler jakarta-servlet
  SetEnv JK_WORKER_NAME workerX
  ...
/Location

Now, the problem becomes : are these Location and LocationMatch sections evaluated before, 
or after the Rewrite rules ?

But for that, the Apache documentation is explicit.
Rewrite happens *before* the URL is compared to the Location* sections.


(*) probably, because it is difficult to explain precisely in less than 2 pages of html 
full of Apache internals which most users would not understand anyway, so Rainer is 
discouraged from even attempting to... ;-)


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: SSL Not working on tomcat 5.5.29

2010-07-02 Thread Pid
On 02/07/2010 06:30, kareem_s_m wrote:
 
 Hi All,
 
 I am working on upgrading tomcat from 5.5.28 to 5.5.29 for one of the
 applications. I see that the website renders and works fine in 5.5.29 on
 port 8080 (non SSL) but with  SSL (port 8443) the website doesnot run at
 all. When I try to see what's going on in Fiddle, I see 502 error. Also
 nothing is written to the log flies. It is as if tomcat is not even running
 in port 8443.
 
 Under tomcat 5.5.28, the site renders fine with SSL and non SSL.
 
 Is there something I could be missing?

Are the Connector definitions in server.xml files identical?

You can post it inline here, if you remove the comments and any passwords.


p



signature.asc
Description: OpenPGP digital signature


Re: using Servlet Filter to rewrite domain of JSESSIONID cookie?

2010-07-02 Thread Pid
On 02/07/2010 08:31, André Warnier wrote:
 Christopher Schultz wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Nikita,

 On 7/1/2010 6:37 PM, Nikita Tovstoles wrote:
 I borrowed sub-domain from Google Analytics terminology. I have one
 server, running one tomcat instance with one virtual host. That host is
 running one app - a JS/html widget that is embedded on multiple sites.

 We need to track usage per-deployment (per site embedding the wiget).
 For
 (google) analytics purposes, the easiest way to do so is to have a
 different
 (sub)domain per deployment. So the same tomcat instance is responding to
 requests for site1.widget.com, site2.widget.com, etc.

 a user may interact with 2 widget deployed on 2 different sites (and
 thus
 served from different (sub)domains) within 30 minutes. It is for this
 case
 that we want user to share the same HttpSession:

 - go to some site A where our widget is deployed at site1.widget.com
 - go to some other site B where our widget is deployed at
 site2.widget.com
 - reuse the same JSESSIONID because its' domain is set to .widget.com

 This sounds like a job for a non-JSESSIONID cookie that is created from
 your own code.

 +1
 
 But I am still lost as to what you are calling sites and subdomains
 and deployed at site1.widget.com.
 If I follow the explanation above, you have something like this :
 Host name=localhost appBase=webapps
  Aliassite1.widget.com/Alias
  Aliassite2.widget.com/Alias
  Aliassite3.widget.com/Alias
  Aliassite4.widget.com/Alias
 ...
 /Host

You can omit the aliases and just rely on the defaultHost setting in
Engine to route all requests to a specific Host.


p

 Is that it ?
 And if so, where is the widget-webapp deployed (on disk), and how many
 times really ?
 
 I am not trying to be a pedant, just to make sure I understand the
 layout, so that we might maybe come up with a suggestion to solve your
 problem (even if it is not by changing the JSESSIONID cookie domain)
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 




signature.asc
Description: OpenPGP digital signature


Re: Application vars -

2010-07-02 Thread André Warnier

Eric P wrote:

So it makes sense to go into what disruption means. I'm not 100% sure
about the following, it would be good if a tomcat heavyweight would
confirm/refute what I say.

When you initiate a webapp reload, Tomcat waits for requests that have
already started processing to terminate. This ensures that people who
accessed your app just before the webapp get a complete response. Once
that's done, the application is reloaded and your servlets' init 
methods are
called if necessary. During this time, incoming requests aren't 
denied, they

are just paused until the reload is complete.

So the only disruption people see is your application freezing up for the
time it takes to reload (which is going to depend on what you your
initialization consists of). No ugly server unavailable errors or 
anything

of the sort.

If you don't like the idea of your app freezing, think about this. 
Rereading

environment params without reloading has its own risks, namely potential
race conditions. Imagine you have 5 parameters, and requests are 
coming in
as you are reading these in and initializing your webapp. A request 
might be
handled while 2 params have been read, but 3 still contain the old 
values.

If you start to think about locking/synchronization to solve this you're
definitely better off just using Tomcat's reload mechanism.

So my answer would be, trust Tomcat's reloading process unless you
absolutely want to avoid your webapp freezing for the time it will 
take for

it to init (this depends on the webapp). If you want to do your own
reloading, think long and hard about potential race conditions 
(which will

occur in all except the simplest cases).

Again, all this should probably be verified, you can set up very 
simple test

cases with a JSP that  sleeps, etc.




Shay,
I think you made a good case for keeping app vars in web.xml (i.e., 
seems pretty apparent now that's where they belong).


Thanks for taking the time to respond.  I sincerely appreciate it!
Eric P.


+1
Very neat explanation.

While not being a great specialist, I would just like to expone what may be an 
alternative, if one really wants to diminish the (apparent) time it takes for a new 
version of a webapp to become available.  Since I am no great specialist, I will just 
outline the idea without Java/servlet specifics.


(Maybe also I am barging through an open door, and there already exists a standard 
mechanism for doing this, but oh well..)


Imagine that you have 2 identical versions of the same intrinsic webapp 
deployed, like

catalina_base/webapps/webappA
catalina_base/webapps/webappB

You create a 3rd webapp webappX, which is the one the users see, and which is just a 
dispatcher to either one of the two webapps webappA and webappB.

So you now have :

catalina_base/webapps/webappX
catalina_base/webapps/webappA
catalina_base/webapps/webappB

The users always use the URL /webappX.
When a call is made to webappX, /it/ decides, in function of some external parameter Y, 
whether to dispatch the call to either webappA or webappB.


Say that initially the external parameter Y (which could be a system-wide property) is set 
so that all calls to /webappX are currently dispatched to /webappA.

Now you want to update webappA.
You change the parameter Y so that calls are now dispatched to (identical) 
/webappB.
Then you update (redeploy) webappA.  Users see no delay, because they get 
directed to webappB.
When webappA is deployed and started (which you could check by calling it 
directly),
you can reset the parameter Y to its former value, and users will again be dispatched to 
webappA.  Now you can redeploy webappB, to keep it in sync.





-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: SSL Not working on tomcat 5.5.29

2010-07-02 Thread André Warnier

kareem_s_m wrote:

Hi All,

I am working on upgrading tomcat from 5.5.28 to 5.5.29 for one of the
applications. I see that the website renders and works fine in 5.5.29 on
port 8080 (non SSL) but with  SSL (port 8443) the website doesnot run at
all. When I try to see what's going on in Fiddle, I see 502 error. Also
nothing is written to the log flies. It is as if tomcat is not even running
in port 8443.

Under tomcat 5.5.28, the site renders fine with SSL and non SSL.

Is there something I could be missing?

On the face of it, I would estimate the probability of that at so close to 1 as cannot be 
distinguished from it.
But if you want someone here to help, you will have to provide some more details, such as 
for example a copy-and-paste of your Connector tags, and maybe tell us which platform 
this is, and where these Tomcat's are coming from.
Useful : go to the Tomcat bin subdirectory with a console window, run version.sh or 
version.bat, and paste the result in your next message.





-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
Hi all,

I have a very simple file upload mechanism in java. I just take the file and
save it on the server. I'm testing this simple code with selenium and *when
a timeout occurs in the selenium test *tomcat creates 0 byte files under
tomcat_home/work/Catalina/localhost/uploadServlet/ directory as MultiPart*
files. It creates thousands of files, until there is no disk space left on
device. What may cause this problem? How can I solve this? Is there anyone
has an idea about this?

My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun java
1.6

Thanks,

Here is the code snippet that i use

File fFile = null;
FileOutputStream fileOutputStream = null;
FileInputStream fileInputStream = null;
try {

String strFileName = request.getParameter(FileName);
String strPath = request.getParameter(Path);
//String strMediaType = request.getParameter(MediaType);

//String strDescription = request.getParameter(Description);
fFile = (File) request.getAttribute(Content);

int index = strPath.length() - 1; //If the user forgets to
put the last / for the path... We put it for him/her

if (strPath.charAt(index) != '/') {
strPath += /;
}
if (!new File(strPath).exists()) {
new File(strPath).mkdirs();
}

File file = new File(strPath + strFileName);
fileOutputStream = new FileOutputStream(file);
fileInputStream = new FileInputStream(fFile);

byte[] bBuf = new byte[1024];

int iBufLen = 0;
int iReadLen = 1024;
int iTotelLen = 0;
/*read 1024 bytes at a time*/
while ((iBufLen = fileInputStream.read(bBuf)) != -1) {

fileOutputStream.write(bBuf);
fileOutputStream.flush();
iTotelLen += iBufLen;
if (fileInputStream.available()  iReadLen) {
iReadLen = fileInputStream.available();

break;
}
}

byte[] tempbBuf = new byte[iReadLen];
fileInputStream.read(tempbBuf, 0, iReadLen);

fileOutputStream.write(tempbBuf);


} catch (IOException ex) {
ex.printStackTrace();
} finally {
fileOutputStream.close();
fileInputStream.close();

if (fFile.exists()) {

fFile.delete();
}
}



-- 
Murat BIRBEN


Re: using Servlet Filter to rewrite domain of JSESSIONID cookie?

2010-07-02 Thread André Warnier

Pid wrote:

On 02/07/2010 08:31, André Warnier wrote:

Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Nikita,

On 7/1/2010 6:37 PM, Nikita Tovstoles wrote:

I borrowed sub-domain from Google Analytics terminology. I have one
server, running one tomcat instance with one virtual host. That host is
running one app - a JS/html widget that is embedded on multiple sites.

We need to track usage per-deployment (per site embedding the wiget).
For
(google) analytics purposes, the easiest way to do so is to have a
different
(sub)domain per deployment. So the same tomcat instance is responding to
requests for site1.widget.com, site2.widget.com, etc.

a user may interact with 2 widget deployed on 2 different sites (and
thus
served from different (sub)domains) within 30 minutes. It is for this
case
that we want user to share the same HttpSession:

- go to some site A where our widget is deployed at site1.widget.com
- go to some other site B where our widget is deployed at
site2.widget.com
- reuse the same JSESSIONID because its' domain is set to .widget.com

This sounds like a job for a non-JSESSIONID cookie that is created from
your own code.


+1

But I am still lost as to what you are calling sites and subdomains
and deployed at site1.widget.com.
If I follow the explanation above, you have something like this :
Host name=localhost appBase=webapps
 Aliassite1.widget.com/Alias
 Aliassite2.widget.com/Alias
 Aliassite3.widget.com/Alias
 Aliassite4.widget.com/Alias
...
/Host


You can omit the aliases and just rely on the defaultHost setting in
Engine to route all requests to a specific Host.


I know, but I am trying to get a grip of what the OP means by sites etc..
This is to try to figure out if, apart from modifying the domain of the JSESSIONID cookie 
(which seems difficult), there is a better solution to the OP's underlying issue (Google 
Analytics).
Maybe this thing can be solved by a simple servlet filter, or UrlRewriteFilter, or some 
dispatching servlet, or having the application do a getHostName() or ..


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 09:43, Murat Birben wrote:
 Hi all,
 
 I have a very simple file upload mechanism in java. I just take the file and
 save it on the server. I'm testing this simple code with selenium and *when
 a timeout occurs in the selenium test *tomcat creates 0 byte files under
 tomcat_home/work/Catalina/localhost/uploadServlet/ directory as MultiPart*
 files. It creates thousands of files, until there is no disk space left on
 device. What may cause this problem? How can I solve this? Is there anyone
 has an idea about this?

Thousands of 0 byte files are causing the disk to run out of space?


p

 My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun java
 1.6
 
 Thanks,
 
 Here is the code snippet that i use
 
 File fFile = null;
 FileOutputStream fileOutputStream = null;
 FileInputStream fileInputStream = null;
 try {
 
 String strFileName = request.getParameter(FileName);
 String strPath = request.getParameter(Path);
 //String strMediaType = request.getParameter(MediaType);
 
 //String strDescription = request.getParameter(Description);
 fFile = (File) request.getAttribute(Content);
 
 int index = strPath.length() - 1; //If the user forgets to
 put the last / for the path... We put it for him/her
 
 if (strPath.charAt(index) != '/') {
 strPath += /;
 }
 if (!new File(strPath).exists()) {
 new File(strPath).mkdirs();
 }
 
 File file = new File(strPath + strFileName);
 fileOutputStream = new FileOutputStream(file);
 fileInputStream = new FileInputStream(fFile);
 
 byte[] bBuf = new byte[1024];
 
 int iBufLen = 0;
 int iReadLen = 1024;
 int iTotelLen = 0;
 /*read 1024 bytes at a time*/
 while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
 
 fileOutputStream.write(bBuf);
 fileOutputStream.flush();
 iTotelLen += iBufLen;
 if (fileInputStream.available()  iReadLen) {
 iReadLen = fileInputStream.available();
 
 break;
 }
 }
 
 byte[] tempbBuf = new byte[iReadLen];
 fileInputStream.read(tempbBuf, 0, iReadLen);
 
 fileOutputStream.write(tempbBuf);
 
 
 } catch (IOException ex) {
 ex.printStackTrace();
 } finally {
 fileOutputStream.close();
 fileInputStream.close();
 
 if (fFile.exists()) {
 
 fFile.delete();
 }
 }
 
 
 




signature.asc
Description: OpenPGP digital signature


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Murat Birben wrote:

Hi all,

I have a very simple file upload mechanism in java. I just take the file and
save it on the server. I'm testing this simple code with selenium and *when
a timeout occurs in the selenium test *tomcat creates 0 byte files under
tomcat_home/work/Catalina/localhost/uploadServlet/ directory as MultiPart*
files. It creates thousands of files, until there is no disk space left on
device. What may cause this problem? How can I solve this? Is there anyone
has an idea about this?

My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun java
1.6


Hi.
I am not good enough in those things to evaluate your code, but here are a couple of tips 
to do what you seem to want to do. Have a look at :


- up to Tomcat 5.5, there was an application called DAV available with Tomcat.
That is something designed to do just that : allow users to upload/download) files to/from 
the server using Tomcat. With some caveats, this works together with what Microsoft calls 
web folders, and allows Windows workstation users to see folders on the server within 
their Windows Explorer (like network shares), and copy/move files to/from there.

(It also works, and usually better, with other client DAV implementations).

- see http://commons.apache.org/fileupload/
(this may even be included in Tomcat by now; I think I heard something about 
this a while ago)

The point is : allowing users to upload files to the server, and allowing them to specify 
a path on the server, is dangerous and difficult to do right.

Better to use something that is already ready and debugged.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Mark Thomas

On 02/07/2010 11:00, André Warnier wrote:


- up to Tomcat 5.5, there was an application called DAV available with
Tomcat.


The WebDAV servlet is still there in Tomcat 7. We just removed the 
example app from 6 onwards.



- see http://commons.apache.org/fileupload/
(this may even be included in Tomcat by now; I think I heard something
about this a while ago)


File upload is part of the Servlet 3 spec so that feature is in Tomact 7.

Mark



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

André Warnier wrote:
...


The point is : allowing users to upload files to the server, and 
allowing them to specify a path on the server, is dangerous and 
difficult to do right.

Better to use something that is already ready and debugged.


Let me be more explicit, after having just a quick look at your code :

enter path : /etc
enter filename : passwd

or more devious :

enter path : /some/innocent/path
enter filename : ../../../../../etc/passwd

and your server would not last 2 minutes on the Internet.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Mark Thomas wrote:

On 02/07/2010 11:00, André Warnier wrote:


- up to Tomcat 5.5, there was an application called DAV available with
Tomcat.


The WebDAV servlet is still there in Tomcat 7. We just removed the 
example app from 6 onwards.


Noted, thanks.
But it seems hard to find.
I do not see any obvious links to it on 
http://tomcat.apache.org/tomcat-7.0-doc/index.html
If I wanted to set this up, where do I start ?

(I have never used it personally with Tomcat.  Assuming I wanted to, is it safe, like 
production-safe (or like Apache's mod_dav safe) ?)






- see http://commons.apache.org/fileupload/
(this may even be included in Tomcat by now; I think I heard something
about this a while ago)


File upload is part of the Servlet 3 spec so that feature is in Tomact 7.


Ah.  So that means that Tomcat can now handle multipart/form-data POSTs in 
general ?

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
Yes 0 byte files are causing the disk to run out of space

@Andre Warnier
I'm not actually saving files on the server. I just tried to simplify my
problem and tried that simple code. Now i'll give a try to apache fileupload
api, thanks for advice

On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com wrote:

 On 02/07/2010 09:43, Murat Birben wrote:
  Hi all,
 
  I have a very simple file upload mechanism in java. I just take the file
 and
  save it on the server. I'm testing this simple code with selenium and
 *when
  a timeout occurs in the selenium test *tomcat creates 0 byte files under
  tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
 MultiPart*
  files. It creates thousands of files, until there is no disk space left
 on
  device. What may cause this problem? How can I solve this? Is there
 anyone
  has an idea about this?

 Thousands of 0 byte files are causing the disk to run out of space?


 p

  My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun java
  1.6
 
  Thanks,
 
  Here is the code snippet that i use
 
  File fFile = null;
  FileOutputStream fileOutputStream = null;
  FileInputStream fileInputStream = null;
  try {
 
  String strFileName = request.getParameter(FileName);
  String strPath = request.getParameter(Path);
  //String strMediaType = request.getParameter(MediaType);
 
  //String strDescription =
 request.getParameter(Description);
  fFile = (File) request.getAttribute(Content);
 
  int index = strPath.length() - 1; //If the user forgets to
  put the last / for the path... We put it for him/her
 
  if (strPath.charAt(index) != '/') {
  strPath += /;
  }
  if (!new File(strPath).exists()) {
  new File(strPath).mkdirs();
  }
 
  File file = new File(strPath + strFileName);
  fileOutputStream = new FileOutputStream(file);
  fileInputStream = new FileInputStream(fFile);
 
  byte[] bBuf = new byte[1024];
 
  int iBufLen = 0;
  int iReadLen = 1024;
  int iTotelLen = 0;
  /*read 1024 bytes at a time*/
  while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
 
  fileOutputStream.write(bBuf);
  fileOutputStream.flush();
  iTotelLen += iBufLen;
  if (fileInputStream.available()  iReadLen) {
  iReadLen = fileInputStream.available();
 
  break;
  }
  }
 
  byte[] tempbBuf = new byte[iReadLen];
  fileInputStream.read(tempbBuf, 0, iReadLen);
 
  fileOutputStream.write(tempbBuf);
 
 
  } catch (IOException ex) {
  ex.printStackTrace();
  } finally {
  fileOutputStream.close();
  fileInputStream.close();
 
  if (fFile.exists()) {
 
  fFile.delete();
  }
  }
 
 
 





-- 
Murat BIRBEN


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 11:01, Murat Birben wrote:
 Yes 0 byte files are causing the disk to run out of space

You understand my surprise?

Are you sure the disk is running out of space, or is it that the number
of files permitted in a directory has been exceeded?


p


 @Andre Warnier
 I'm not actually saving files on the server. I just tried to simplify my
 problem and tried that simple code. Now i'll give a try to apache
 fileupload api, thanks for advice
 
 On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
 mailto:p...@pidster.com wrote:
 
 On 02/07/2010 09:43, Murat Birben wrote:
  Hi all,
 
  I have a very simple file upload mechanism in java. I just take
 the file and
  save it on the server. I'm testing this simple code with selenium
 and *when
  a timeout occurs in the selenium test *tomcat creates 0 byte files
 under
  tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
 MultiPart*
  files. It creates thousands of files, until there is no disk space
 left on
  device. What may cause this problem? How can I solve this? Is
 there anyone
  has an idea about this?
 
 Thousands of 0 byte files are causing the disk to run out of space?
 
 
 p
 
  My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29,
 sun java
  1.6
 
  Thanks,
 
  Here is the code snippet that i use
 
  File fFile = null;
  FileOutputStream fileOutputStream = null;
  FileInputStream fileInputStream = null;
  try {
 
  String strFileName = request.getParameter(FileName);
  String strPath = request.getParameter(Path);
  //String strMediaType = request.getParameter(MediaType);
 
  //String strDescription =
 request.getParameter(Description);
  fFile = (File) request.getAttribute(Content);
 
  int index = strPath.length() - 1; //If the user forgets to
  put the last / for the path... We put it for him/her
 
  if (strPath.charAt(index) != '/') {
  strPath += /;
  }
  if (!new File(strPath).exists()) {
  new File(strPath).mkdirs();
  }
 
  File file = new File(strPath + strFileName);
  fileOutputStream = new FileOutputStream(file);
  fileInputStream = new FileInputStream(fFile);
 
  byte[] bBuf = new byte[1024];
 
  int iBufLen = 0;
  int iReadLen = 1024;
  int iTotelLen = 0;
  /*read 1024 bytes at a time*/
  while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
 
  fileOutputStream.write(bBuf);
  fileOutputStream.flush();
  iTotelLen += iBufLen;
  if (fileInputStream.available()  iReadLen) {
  iReadLen = fileInputStream.available();
 
  break;
  }
  }
 
  byte[] tempbBuf = new byte[iReadLen];
  fileInputStream.read(tempbBuf, 0, iReadLen);
 
  fileOutputStream.write(tempbBuf);
 
 
  } catch (IOException ex) {
  ex.printStackTrace();
  } finally {
  fileOutputStream.close();
  fileInputStream.close();
 
  if (fFile.exists()) {
 
  fFile.delete();
  }
  }
 
 
 
 
 
 
 
 
 -- 
 Murat BIRBEN




signature.asc
Description: OpenPGP digital signature


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
I'm getting There is no space left on disk message when i try to do some
work on the server after this 0 byte files are created

On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com wrote:

 On 02/07/2010 11:01, Murat Birben wrote:
  Yes 0 byte files are causing the disk to run out of space

 You understand my surprise?

 Are you sure the disk is running out of space, or is it that the number
 of files permitted in a directory has been exceeded?


 p


  @Andre Warnier
  I'm not actually saving files on the server. I just tried to simplify my
  problem and tried that simple code. Now i'll give a try to apache
  fileupload api, thanks for advice
 
  On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
  mailto:p...@pidster.com wrote:
 
  On 02/07/2010 09:43, Murat Birben wrote:
   Hi all,
  
   I have a very simple file upload mechanism in java. I just take
  the file and
   save it on the server. I'm testing this simple code with selenium
  and *when
   a timeout occurs in the selenium test *tomcat creates 0 byte files
  under
   tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
  MultiPart*
   files. It creates thousands of files, until there is no disk space
  left on
   device. What may cause this problem? How can I solve this? Is
  there anyone
   has an idea about this?
 
  Thousands of 0 byte files are causing the disk to run out of space?
 
 
  p
 
   My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29,
  sun java
   1.6
  
   Thanks,
  
   Here is the code snippet that i use
  
   File fFile = null;
   FileOutputStream fileOutputStream = null;
   FileInputStream fileInputStream = null;
   try {
  
   String strFileName = request.getParameter(FileName);
   String strPath = request.getParameter(Path);
   //String strMediaType =
 request.getParameter(MediaType);
  
   //String strDescription =
  request.getParameter(Description);
   fFile = (File) request.getAttribute(Content);
  
   int index = strPath.length() - 1; //If the user forgets
 to
   put the last / for the path... We put it for him/her
  
   if (strPath.charAt(index) != '/') {
   strPath += /;
   }
   if (!new File(strPath).exists()) {
   new File(strPath).mkdirs();
   }
  
   File file = new File(strPath + strFileName);
   fileOutputStream = new FileOutputStream(file);
   fileInputStream = new FileInputStream(fFile);
  
   byte[] bBuf = new byte[1024];
  
   int iBufLen = 0;
   int iReadLen = 1024;
   int iTotelLen = 0;
   /*read 1024 bytes at a time*/
   while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
  
   fileOutputStream.write(bBuf);
   fileOutputStream.flush();
   iTotelLen += iBufLen;
   if (fileInputStream.available()  iReadLen) {
   iReadLen = fileInputStream.available();
  
   break;
   }
   }
  
   byte[] tempbBuf = new byte[iReadLen];
   fileInputStream.read(tempbBuf, 0, iReadLen);
  
   fileOutputStream.write(tempbBuf);
  
  
   } catch (IOException ex) {
   ex.printStackTrace();
   } finally {
   fileOutputStream.close();
   fileInputStream.close();
  
   if (fFile.exists()) {
  
   fFile.delete();
   }
   }
  
  
  
 
 
 
 
 
  --
  Murat BIRBEN





-- 
Murat BIRBEN


RE: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Ralph Carlson
you can also try the oreilly file upload api, I have used it in many projects 
without issue

http://www.servlets.com/cos/ (download)
http://java.itags.org/java-essentials/11012/ (an example)

From: users-return-214291-racarlson=mediacomcc@tomcat.apache.org 
[users-return-214291-racarlson=mediacomcc@tomcat.apache.org] On Behalf Of 
Murat Birben [muratbir...@gmail.com]
Sent: Friday, July 02, 2010 6:01 AM
To: Tomcat Users List; p...@pidster.com
Subject: Re: Tomcat 5.5 creates 0 byte files

Yes 0 byte files are causing the disk to run out of space

@Andre Warnier
I'm not actually saving files on the server. I just tried to simplify my
problem and tried that simple code. Now i'll give a try to apache fileupload
api, thanks for advice

On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com wrote:

 On 02/07/2010 09:43, Murat Birben wrote:
  Hi all,
 
  I have a very simple file upload mechanism in java. I just take the file
 and
  save it on the server. I'm testing this simple code with selenium and
 *when
  a timeout occurs in the selenium test *tomcat creates 0 byte files under
  tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
 MultiPart*
  files. It creates thousands of files, until there is no disk space left
 on
  device. What may cause this problem? How can I solve this? Is there
 anyone
  has an idea about this?

 Thousands of 0 byte files are causing the disk to run out of space?


 p

  My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun java
  1.6
 
  Thanks,
 
  Here is the code snippet that i use
 
  File fFile = null;
  FileOutputStream fileOutputStream = null;
  FileInputStream fileInputStream = null;
  try {
 
  String strFileName = request.getParameter(FileName);
  String strPath = request.getParameter(Path);
  //String strMediaType = request.getParameter(MediaType);
 
  //String strDescription =
 request.getParameter(Description);
  fFile = (File) request.getAttribute(Content);
 
  int index = strPath.length() - 1; //If the user forgets to
  put the last / for the path... We put it for him/her
 
  if (strPath.charAt(index) != '/') {
  strPath += /;
  }
  if (!new File(strPath).exists()) {
  new File(strPath).mkdirs();
  }
 
  File file = new File(strPath + strFileName);
  fileOutputStream = new FileOutputStream(file);
  fileInputStream = new FileInputStream(fFile);
 
  byte[] bBuf = new byte[1024];
 
  int iBufLen = 0;
  int iReadLen = 1024;
  int iTotelLen = 0;
  /*read 1024 bytes at a time*/
  while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
 
  fileOutputStream.write(bBuf);
  fileOutputStream.flush();
  iTotelLen += iBufLen;
  if (fileInputStream.available()  iReadLen) {
  iReadLen = fileInputStream.available();
 
  break;
  }
  }
 
  byte[] tempbBuf = new byte[iReadLen];
  fileInputStream.read(tempbBuf, 0, iReadLen);
 
  fileOutputStream.write(tempbBuf);
 
 
  } catch (IOException ex) {
  ex.printStackTrace();
  } finally {
  fileOutputStream.close();
  fileInputStream.close();
 
  if (fFile.exists()) {
 
  fFile.delete();
  }
  }
 
 
 





--
Murat BIRBEN
-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Implementing Connection Pooling

2010-07-02 Thread Caldarale, Charles R
 From: Andrew Laughlin [mailto:andrew.laugh...@gmail.com]
 Subject: Re: Implementing Connection Pooling
 
 Because I won't have this info until run-time.

Which means you can't configure the appropriate Resource elements.

 It appears Apache Commons has a GenericObjectPool class 
 I can used to implement my own connection pooling facility.
 However I don't want to go to the trouble if the current 
 method actually works.

Which it can't possibly do, for the reasons previously given.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.



embedded tomcat, work folder wipe out issue

2010-07-02 Thread Federico Fissore

hello all

first mail to the list: please forward me to any RTFM you may think useful

I've embedded tomcat so to have multiple webapps running with separate 
java processes (each embedded tomcat runs its own webapp, listening to a 
different tcp port), because of some memory issues we have.


having some issues with jsps not being recompiled after an upgrade of a 
webapp (that takes a restart of its tomcat), we scripted the wipe out of 
that context work folder


say the folder is 
/opt/tomcats/work/StandardHost[localhost].StandardContext[/myWebApp]Engine/... 
after tomcat has stopped, we delete the myWebApp]Engine folder so to 
oblige the starting tomcat to recompile every jsp


that USUALLY works fine BUT some times I got a JasperException: Unable 
to load class for JSP, with the root cause being 
ClassNotFoundException: org.apache.jsp.WEB_002dINF.jsp.systemCheck_jsp


I checked for that file in the work folder and it's there! both the 
.java and .class files


Restarting tomcat, until now, solved the issue

what do you think is going on?

thank you in advance

federico

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
I've tried apache.commons.fileupload api but the result doesn't change. I
set the selenium waitForPageToLoad prop very small to produce the problem
and when time exceeded test fails and thousands of 0 bytes are generated.
I'll try the oreilly fileupload api too but it seems to me as the reason is
not about the upload api.

Is there anyone has another idea about this?

On Fri, Jul 2, 2010 at 3:19 PM, Ralph Carlson racarl...@mediacomcc.comwrote:

 you can also try the oreilly file upload api, I have used it in many
 projects without issue

 http://www.servlets.com/cos/ (download)
 http://java.itags.org/java-essentials/11012/ (an example)
 
 From: 
 users-return-214291-racarlson=mediacomcc@tomcat.apache.org[users-return-214291-racarlson=
 mediacomcc@tomcat.apache.org] On Behalf Of Murat Birben [
 muratbir...@gmail.com]
 Sent: Friday, July 02, 2010 6:01 AM
 To: Tomcat Users List; p...@pidster.com
 Subject: Re: Tomcat 5.5 creates 0 byte files

 Yes 0 byte files are causing the disk to run out of space

 @Andre Warnier
 I'm not actually saving files on the server. I just tried to simplify my
 problem and tried that simple code. Now i'll give a try to apache
 fileupload
 api, thanks for advice

 On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com wrote:

  On 02/07/2010 09:43, Murat Birben wrote:
   Hi all,
  
   I have a very simple file upload mechanism in java. I just take the
 file
  and
   save it on the server. I'm testing this simple code with selenium and
  *when
   a timeout occurs in the selenium test *tomcat creates 0 byte files
 under
   tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
  MultiPart*
   files. It creates thousands of files, until there is no disk space left
  on
   device. What may cause this problem? How can I solve this? Is there
  anyone
   has an idea about this?
 
  Thousands of 0 byte files are causing the disk to run out of space?
 
 
  p
 
   My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun
 java
   1.6
  
   Thanks,
  
   Here is the code snippet that i use
  
   File fFile = null;
   FileOutputStream fileOutputStream = null;
   FileInputStream fileInputStream = null;
   try {
  
   String strFileName = request.getParameter(FileName);
   String strPath = request.getParameter(Path);
   //String strMediaType = request.getParameter(MediaType);
  
   //String strDescription =
  request.getParameter(Description);
   fFile = (File) request.getAttribute(Content);
  
   int index = strPath.length() - 1; //If the user forgets to
   put the last / for the path... We put it for him/her
  
   if (strPath.charAt(index) != '/') {
   strPath += /;
   }
   if (!new File(strPath).exists()) {
   new File(strPath).mkdirs();
   }
  
   File file = new File(strPath + strFileName);
   fileOutputStream = new FileOutputStream(file);
   fileInputStream = new FileInputStream(fFile);
  
   byte[] bBuf = new byte[1024];
  
   int iBufLen = 0;
   int iReadLen = 1024;
   int iTotelLen = 0;
   /*read 1024 bytes at a time*/
   while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
  
   fileOutputStream.write(bBuf);
   fileOutputStream.flush();
   iTotelLen += iBufLen;
   if (fileInputStream.available()  iReadLen) {
   iReadLen = fileInputStream.available();
  
   break;
   }
   }
  
   byte[] tempbBuf = new byte[iReadLen];
   fileInputStream.read(tempbBuf, 0, iReadLen);
  
   fileOutputStream.write(tempbBuf);
  
  
   } catch (IOException ex) {
   ex.printStackTrace();
   } finally {
   fileOutputStream.close();
   fileInputStream.close();
  
   if (fFile.exists()) {
  
   fFile.delete();
   }
   }
  
  
  
 
 
 


 --
 Murat BIRBEN
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org




-- 
Murat BIRBEN


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 12:20, Murat Birben wrote:
 I'm getting There is no space left on disk message when i try to do
 some work on the server after this 0 byte files are created

What is your OS and exact version?


p


 On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com
 mailto:p...@pidster.com wrote:
 
 On 02/07/2010 11:01, Murat Birben wrote:
  Yes 0 byte files are causing the disk to run out of space
 
 You understand my surprise?
 
 Are you sure the disk is running out of space, or is it that the number
 of files permitted in a directory has been exceeded?
 
 
 p
 
 
  @Andre Warnier
  I'm not actually saving files on the server. I just tried to
 simplify my
  problem and tried that simple code. Now i'll give a try to apache
  fileupload api, thanks for advice
 
  On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com wrote:
 
  On 02/07/2010 09:43, Murat Birben wrote:
   Hi all,
  
   I have a very simple file upload mechanism in java. I just take
  the file and
   save it on the server. I'm testing this simple code with
 selenium
  and *when
   a timeout occurs in the selenium test *tomcat creates 0 byte
 files
  under
   tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
  MultiPart*
   files. It creates thousands of files, until there is no disk
 space
  left on
   device. What may cause this problem? How can I solve this? Is
  there anyone
   has an idea about this?
 
  Thousands of 0 byte files are causing the disk to run out of
 space?
 
 
  p
 
   My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29,
  sun java
   1.6
  
   Thanks,
  
   Here is the code snippet that i use
  
   File fFile = null;
   FileOutputStream fileOutputStream = null;
   FileInputStream fileInputStream = null;
   try {
  
   String strFileName =
 request.getParameter(FileName);
   String strPath = request.getParameter(Path);
   //String strMediaType =
 request.getParameter(MediaType);
  
   //String strDescription =
  request.getParameter(Description);
   fFile = (File) request.getAttribute(Content);
  
   int index = strPath.length() - 1; //If the user
 forgets to
   put the last / for the path... We put it for him/her
  
   if (strPath.charAt(index) != '/') {
   strPath += /;
   }
   if (!new File(strPath).exists()) {
   new File(strPath).mkdirs();
   }
  
   File file = new File(strPath + strFileName);
   fileOutputStream = new FileOutputStream(file);
   fileInputStream = new FileInputStream(fFile);
  
   byte[] bBuf = new byte[1024];
  
   int iBufLen = 0;
   int iReadLen = 1024;
   int iTotelLen = 0;
   /*read 1024 bytes at a time*/
   while ((iBufLen = fileInputStream.read(bBuf)) !=
 -1) {
  
   fileOutputStream.write(bBuf);
   fileOutputStream.flush();
   iTotelLen += iBufLen;
   if (fileInputStream.available()  iReadLen) {
   iReadLen = fileInputStream.available();
  
   break;
   }
   }
  
   byte[] tempbBuf = new byte[iReadLen];
   fileInputStream.read(tempbBuf, 0, iReadLen);
  
   fileOutputStream.write(tempbBuf);
  
  
   } catch (IOException ex) {
   ex.printStackTrace();
   } finally {
   fileOutputStream.close();
   fileInputStream.close();
  
   if (fFile.exists()) {
  
   fFile.delete();
   }
   }
  
  
  
 
 
 
 
 
  --
  Murat BIRBEN
 
 
 
 
 
 -- 
 Murat BIRBEN




signature.asc
Description: OpenPGP digital signature


Mod_jk: Uri * is invalid. Uri must start with /

2010-07-02 Thread Matteo Turra
I have Apache/2.2.14 (Unix) and mod_jk/1.2.28 with a Tomcat 6.0.20 farm
in load balancing.

In the mod_jk.log I get a line like this each second.

[warn] map_uri_to_worker_ext::jk_uri_worker_map.c (962): Uri * is
invalid. Uri must start with /

I checked all the JkMount directive in the virtual host

Any suggestion?





Re: Mod_jk: Uri * is invalid. Uri must start with /

2010-07-02 Thread Pid
On 02/07/2010 13:50, Matteo Turra wrote:
 I have Apache/2.2.14 (Unix) and mod_jk/1.2.28 with a Tomcat 6.0.20 farm
 in load balancing.
 
 In the mod_jk.log I get a line like this each second.
 
 [warn] map_uri_to_worker_ext::jk_uri_worker_map.c (962): Uri * is
 invalid. Uri must start with /
 
 I checked all the JkMount directive in the virtual host
 
 Any suggestion?

Post your workers.properties and the full set of JkMount directives
you're using.


p




signature.asc
Description: OpenPGP digital signature


Getting a servlet to work within static pages

2010-07-02 Thread David kerber

My system:
Debian Lenny (5.x) on a low end machine in my basement (so I can do 
whatever I want/need to it)


TC 6.0.24, installed in /home/davek/apache-tomcat-6.0.24

java version 1.5.0_17
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_17-b04)
Java HotSpot(TM) Client VM (build 1.5.0_17-b04, mixed mode, sharing)

Web content and apps are installed in
/home/content/webapps/ROOT
and
/home/content/webapps/ginp

ROOT contains all the static content for my personal website, with 
various html files and sub-folders, and a couple of .jsp files from this 
issue I'm asking about.


ginp is the open-source photo album project I'm using to manage and 
display post some of my pictures.


I'm trying to figure out how to use some of the functions from ginp 
(specifically one of several defined as tagsets) in my static pages to 
display a list of available photo albums.  And I want to do this 
transparently, so the list appears to be just part of a static page, 
without me having to have /ginp/ show on the url because it was 
redirected or forwarded to the servlet.


I've tried renaming the .html page to .jsp and putting the code to call 
the tag in the desired spot (code below), but I'm getting the exception 
below.  I think the biggest issue is my unfamiliarity with using 
tablibs, but am wondering if there is also some tomcat setup issues I'm 
missing here.


Any help appreciated!!

Dave


The complete .jsp is:

HTML
HEAD
  TITLEPhotography/TITLE
/HEAD
BODY background=sand.gif
H2 align=centerPhotography/H2
P
Some of my favorite pictures for you to peruse and comment on:

br
h3Picture collections/h3

%@ taglib uri=/ginp prefix=ginp %
ginp:setup /
h1ginp:trans code=Collections //h1
h3ginp:getcollectiontitles
a href=%=link%%=name%/abr //ginp:getcollectiontitles
/h3
P
A HREF=davek_1.htmBack to the Home Page/A
/BODY
/HTML



org.apache.jasper.JasperException: File /ginp not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)

org.apache.jasper.compiler.TagLibraryInfoImpl.init(TagLibraryInfoImpl.java:160)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:382)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:445)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1392)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
ubuntu 8.04 server

On Fri, Jul 2, 2010 at 3:50 PM, Pid p...@pidster.com wrote:

 On 02/07/2010 12:20, Murat Birben wrote:
  I'm getting There is no space left on disk message when i try to do
  some work on the server after this 0 byte files are created

 What is your OS and exact version?


 p


  On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com
  mailto:p...@pidster.com wrote:
 
  On 02/07/2010 11:01, Murat Birben wrote:
   Yes 0 byte files are causing the disk to run out of space
 
  You understand my surprise?
 
  Are you sure the disk is running out of space, or is it that the
 number
  of files permitted in a directory has been exceeded?
 
 
  p
 
 
   @Andre Warnier
   I'm not actually saving files on the server. I just tried to
  simplify my
   problem and tried that simple code. Now i'll give a try to apache
   fileupload api, thanks for advice
  
   On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
  mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com wrote:
  
   On 02/07/2010 09:43, Murat Birben wrote:
Hi all,
   
I have a very simple file upload mechanism in java. I just
 take
   the file and
save it on the server. I'm testing this simple code with
  selenium
   and *when
a timeout occurs in the selenium test *tomcat creates 0 byte
  files
   under
tomcat_home/work/Catalina/localhost/uploadServlet/ directory
 as
   MultiPart*
files. It creates thousands of files, until there is no disk
  space
   left on
device. What may cause this problem? How can I solve this? Is
   there anyone
has an idea about this?
  
   Thousands of 0 byte files are causing the disk to run out of
  space?
  
  
   p
  
My environment is: Ubuntu - 8.04 server, apache tomcat -
 5.5.29,
   sun java
1.6
   
Thanks,
   
Here is the code snippet that i use
   
File fFile = null;
FileOutputStream fileOutputStream = null;
FileInputStream fileInputStream = null;
try {
   
String strFileName =
  request.getParameter(FileName);
String strPath = request.getParameter(Path);
//String strMediaType =
  request.getParameter(MediaType);
   
//String strDescription =
   request.getParameter(Description);
fFile = (File) request.getAttribute(Content);
   
int index = strPath.length() - 1; //If the user
  forgets to
put the last / for the path... We put it for him/her
   
if (strPath.charAt(index) != '/') {
strPath += /;
}
if (!new File(strPath).exists()) {
new File(strPath).mkdirs();
}
   
File file = new File(strPath + strFileName);
fileOutputStream = new FileOutputStream(file);
fileInputStream = new FileInputStream(fFile);
   
byte[] bBuf = new byte[1024];
   
int iBufLen = 0;
int iReadLen = 1024;
int iTotelLen = 0;
/*read 1024 bytes at a time*/
while ((iBufLen = fileInputStream.read(bBuf)) !=
  -1) {
   
fileOutputStream.write(bBuf);
fileOutputStream.flush();
iTotelLen += iBufLen;
if (fileInputStream.available()  iReadLen) {
iReadLen = fileInputStream.available();
   
break;
}
}
   
byte[] tempbBuf = new byte[iReadLen];
fileInputStream.read(tempbBuf, 0, iReadLen);
   
fileOutputStream.write(tempbBuf);
   
   
} catch (IOException ex) {
ex.printStackTrace();
} finally {
fileOutputStream.close();
fileInputStream.close();
   
if (fFile.exists()) {
   
fFile.delete();
}
}
   
   
   
  
  
  
  
  
   --
   Murat BIRBEN
 
 
 
 
 
  --
  Murat BIRBEN





-- 
Murat BIRBEN


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Murat Birben wrote:

I've tried apache.commons.fileupload api but the result doesn't change. I
set the selenium waitForPageToLoad prop very small to produce the problem
and when time exceeded test fails and thousands of 0 bytes are generated.
I'll try the oreilly fileupload api too but it seems to me as the reason is
not about the upload api.

Is there anyone has another idea about this?


Murat,

I have the feeling that you are not really familiar with the underlying HTTP mechanisms 
for multipart posts and/or file uploads.

Can you post here a copy of the html form used by the client ?
(take out the target server name etc..)



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
Ok, here is the html form:

form action=ResourceUploadServlet method=POST
enctype=multipart/form-data
   input type=file name=Content /
FileName :input type=text name=FileName /
Path:input  type=text name=Path /
input type=submit value=Submit /
/form

Thanks for your concern,

On Fri, Jul 2, 2010 at 4:02 PM, André Warnier a...@ice-sa.com wrote:

 Murat Birben wrote:

 I've tried apache.commons.fileupload api but the result doesn't change. I
 set the selenium waitForPageToLoad prop very small to produce the problem
 and when time exceeded test fails and thousands of 0 bytes are generated.
 I'll try the oreilly fileupload api too but it seems to me as the reason
 is
 not about the upload api.

 Is there anyone has another idea about this?

  Murat,

 I have the feeling that you are not really familiar with the underlying
 HTTP mechanisms for multipart posts and/or file uploads.
 Can you post here a copy of the html form used by the client ?
 (take out the target server name etc..)




 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org




-- 
Murat BIRBEN


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 14:02, Murat Birben wrote:
 ubuntu 8.04 server

What does the command 'df -k' report?
Please paste the results.


p

 On Fri, Jul 2, 2010 at 3:50 PM, Pid p...@pidster.com
 mailto:p...@pidster.com wrote:
 
 On 02/07/2010 12:20, Murat Birben wrote:
  I'm getting There is no space left on disk message when i try to do
  some work on the server after this 0 byte files are created
 
 What is your OS and exact version?
 
 
 p
 
 
  On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com wrote:
 
  On 02/07/2010 11:01, Murat Birben wrote:
   Yes 0 byte files are causing the disk to run out of space
 
  You understand my surprise?
 
  Are you sure the disk is running out of space, or is it that
 the number
  of files permitted in a directory has been exceeded?
 
 
  p
 
 
   @Andre Warnier
   I'm not actually saving files on the server. I just tried to
  simplify my
   problem and tried that simple code. Now i'll give a try to
 apache
   fileupload api, thanks for advice
  
   On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com wrote:
  
   On 02/07/2010 09:43, Murat Birben wrote:
Hi all,
   
I have a very simple file upload mechanism in java. I
 just take
   the file and
save it on the server. I'm testing this simple code with
  selenium
   and *when
a timeout occurs in the selenium test *tomcat creates
 0 byte
  files
   under
tomcat_home/work/Catalina/localhost/uploadServlet/
 directory as
   MultiPart*
files. It creates thousands of files, until there is
 no disk
  space
   left on
device. What may cause this problem? How can I solve
 this? Is
   there anyone
has an idea about this?
  
   Thousands of 0 byte files are causing the disk to run out of
  space?
  
  
   p
  
My environment is: Ubuntu - 8.04 server, apache tomcat
 - 5.5.29,
   sun java
1.6
   
Thanks,
   
Here is the code snippet that i use
   
File fFile = null;
FileOutputStream fileOutputStream = null;
FileInputStream fileInputStream = null;
try {
   
String strFileName =
  request.getParameter(FileName);
String strPath = request.getParameter(Path);
//String strMediaType =
  request.getParameter(MediaType);
   
//String strDescription =
   request.getParameter(Description);
fFile = (File)
 request.getAttribute(Content);
   
int index = strPath.length() - 1; //If the
 user
  forgets to
put the last / for the path... We put it for him/her
   
if (strPath.charAt(index) != '/') {
strPath += /;
}
if (!new File(strPath).exists()) {
new File(strPath).mkdirs();
}
   
File file = new File(strPath + strFileName);
fileOutputStream = new FileOutputStream(file);
fileInputStream = new FileInputStream(fFile);
   
byte[] bBuf = new byte[1024];
   
int iBufLen = 0;
int iReadLen = 1024;
int iTotelLen = 0;
/*read 1024 bytes at a time*/
while ((iBufLen =
 fileInputStream.read(bBuf)) !=
  -1) {
   
fileOutputStream.write(bBuf);
fileOutputStream.flush();
iTotelLen += iBufLen;
if (fileInputStream.available() 
 iReadLen) {
iReadLen =
 fileInputStream.available();
   
break;
}
  

Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Murat Birben wrote:

Ok, here is the html form:

form action=ResourceUploadServlet method=POST
enctype=multipart/form-data
   input type=file name=Content /
FileName :input type=text name=FileName /
Path:input  type=text name=Path /
input type=submit value=Submit /
/form


Ok.
First, you should probably change the form tag as follows :
   form action=/ResourceUploadServlet method=POST
 enctype=multipart/form-data

Next:
When the browser sends this to the server, it will do this using a particular format, 
similar to the (internal) format of an email with attachments.
This is what the part : enctype=multipart/form-data is all about. Are you familiar with 
this ?



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 14:21, André Warnier wrote:
 Murat Birben wrote:
 Ok, here is the html form:

 form action=ResourceUploadServlet method=POST
 enctype=multipart/form-data
input type=file name=Content /
 FileName :input type=text
 name=FileName /
 Path:input  type=text name=Path /
 input type=submit value=Submit /
 /form

 Ok.
 First, you should probably change the form tag as follows :
form action=/ResourceUploadServlet method=POST
  enctype=multipart/form-data

Better:

 action=%= request.getContextPath() %/ResourceUploadServlet

Even better:

 action=%= response.encodeURI(request.getContextPath() +
'/ResourceUploadServlet') %


p

 Next:
 When the browser sends this to the server, it will do this using a
 particular format, similar to the (internal) format of an email with
 attachments.
 This is what the part : enctype=multipart/form-data is all about. Are
 you familiar with this ?
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org
 




signature.asc
Description: OpenPGP digital signature


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 13:47, Murat Birben wrote:
 I've tried apache.commons.fileupload api but the result doesn't change. I
 set the selenium waitForPageToLoad prop very small to produce the problem
 and when time exceeded test fails and thousands of 0 bytes are generated.
 I'll try the oreilly fileupload api too but it seems to me as the reason is
 not about the upload api.
 
 Is there anyone has another idea about this?

It's been a while, since I used commons-file-upload, but I remember the
examples being fairly comprehensive.  The streaming API seemed nicer to use.

I don't remember being forced to write a file to the disk, maybe you can
catch the error and not write the file at all.


p



 On Fri, Jul 2, 2010 at 3:19 PM, Ralph Carlson racarl...@mediacomcc.comwrote:
 
 you can also try the oreilly file upload api, I have used it in many
 projects without issue

 http://www.servlets.com/cos/ (download)
 http://java.itags.org/java-essentials/11012/ (an example)
 
 From: 
 users-return-214291-racarlson=mediacomcc@tomcat.apache.org[users-return-214291-racarlson=
 mediacomcc@tomcat.apache.org] On Behalf Of Murat Birben [
 muratbir...@gmail.com]
 Sent: Friday, July 02, 2010 6:01 AM
 To: Tomcat Users List; p...@pidster.com
 Subject: Re: Tomcat 5.5 creates 0 byte files

 Yes 0 byte files are causing the disk to run out of space

 @Andre Warnier
 I'm not actually saving files on the server. I just tried to simplify my
 problem and tried that simple code. Now i'll give a try to apache
 fileupload
 api, thanks for advice

 On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com wrote:

 On 02/07/2010 09:43, Murat Birben wrote:
 Hi all,

 I have a very simple file upload mechanism in java. I just take the
 file
 and
 save it on the server. I'm testing this simple code with selenium and
 *when
 a timeout occurs in the selenium test *tomcat creates 0 byte files
 under
 tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
 MultiPart*
 files. It creates thousands of files, until there is no disk space left
 on
 device. What may cause this problem? How can I solve this? Is there
 anyone
 has an idea about this?

 Thousands of 0 byte files are causing the disk to run out of space?


 p

 My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29, sun
 java
 1.6

 Thanks,

 Here is the code snippet that i use

 File fFile = null;
 FileOutputStream fileOutputStream = null;
 FileInputStream fileInputStream = null;
 try {

 String strFileName = request.getParameter(FileName);
 String strPath = request.getParameter(Path);
 //String strMediaType = request.getParameter(MediaType);

 //String strDescription =
 request.getParameter(Description);
 fFile = (File) request.getAttribute(Content);

 int index = strPath.length() - 1; //If the user forgets to
 put the last / for the path... We put it for him/her

 if (strPath.charAt(index) != '/') {
 strPath += /;
 }
 if (!new File(strPath).exists()) {
 new File(strPath).mkdirs();
 }

 File file = new File(strPath + strFileName);
 fileOutputStream = new FileOutputStream(file);
 fileInputStream = new FileInputStream(fFile);

 byte[] bBuf = new byte[1024];

 int iBufLen = 0;
 int iReadLen = 1024;
 int iTotelLen = 0;
 /*read 1024 bytes at a time*/
 while ((iBufLen = fileInputStream.read(bBuf)) != -1) {

 fileOutputStream.write(bBuf);
 fileOutputStream.flush();
 iTotelLen += iBufLen;
 if (fileInputStream.available()  iReadLen) {
 iReadLen = fileInputStream.available();

 break;
 }
 }

 byte[] tempbBuf = new byte[iReadLen];
 fileInputStream.read(tempbBuf, 0, iReadLen);

 fileOutputStream.write(tempbBuf);


 } catch (IOException ex) {
 ex.printStackTrace();
 } finally {
 fileOutputStream.close();
 fileInputStream.close();

 if (fFile.exists()) {

 fFile.delete();
 }
 }








 --
 Murat BIRBEN
 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org


 
 




signature.asc
Description: OpenPGP digital signature


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
It is a virtual machine on ESXi so df shows me the whole storage I think. Is
there any other way to see the disk usage for virtual machines?


On Fri, Jul 2, 2010 at 4:20 PM, Pid p...@pidster.com wrote:

 On 02/07/2010 14:02, Murat Birben wrote:
  ubuntu 8.04 server

 What does the command 'df -k' report?
 Please paste the results.


 p

  On Fri, Jul 2, 2010 at 3:50 PM, Pid p...@pidster.com
  mailto:p...@pidster.com wrote:
 
  On 02/07/2010 12:20, Murat Birben wrote:
   I'm getting There is no space left on disk message when i try to
 do
   some work on the server after this 0 byte files are created
 
  What is your OS and exact version?
 
 
  p
 
 
   On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com
  mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com wrote:
  
   On 02/07/2010 11:01, Murat Birben wrote:
Yes 0 byte files are causing the disk to run out of space
  
   You understand my surprise?
  
   Are you sure the disk is running out of space, or is it that
  the number
   of files permitted in a directory has been exceeded?
  
  
   p
  
  
@Andre Warnier
I'm not actually saving files on the server. I just tried to
   simplify my
problem and tried that simple code. Now i'll give a try to
  apache
fileupload api, thanks for advice
   
On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
  mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com
mailto:p...@pidster.com mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com wrote:
   
On 02/07/2010 09:43, Murat Birben wrote:
 Hi all,

 I have a very simple file upload mechanism in java. I
  just take
the file and
 save it on the server. I'm testing this simple code
 with
   selenium
and *when
 a timeout occurs in the selenium test *tomcat creates
  0 byte
   files
under
 tomcat_home/work/Catalina/localhost/uploadServlet/
  directory as
MultiPart*
 files. It creates thousands of files, until there is
  no disk
   space
left on
 device. What may cause this problem? How can I solve
  this? Is
there anyone
 has an idea about this?
   
Thousands of 0 byte files are causing the disk to run out
 of
   space?
   
   
p
   
 My environment is: Ubuntu - 8.04 server, apache tomcat
  - 5.5.29,
sun java
 1.6

 Thanks,

 Here is the code snippet that i use

 File fFile = null;
 FileOutputStream fileOutputStream = null;
 FileInputStream fileInputStream = null;
 try {

 String strFileName =
   request.getParameter(FileName);
 String strPath =
 request.getParameter(Path);
 //String strMediaType =
   request.getParameter(MediaType);

 //String strDescription =
request.getParameter(Description);
 fFile = (File)
  request.getAttribute(Content);

 int index = strPath.length() - 1; //If the
  user
   forgets to
 put the last / for the path... We put it for him/her

 if (strPath.charAt(index) != '/') {
 strPath += /;
 }
 if (!new File(strPath).exists()) {
 new File(strPath).mkdirs();
 }

 File file = new File(strPath +
 strFileName);
 fileOutputStream = new
 FileOutputStream(file);
 fileInputStream = new
 FileInputStream(fFile);

 byte[] bBuf = new byte[1024];

 int iBufLen = 0;
 int iReadLen = 1024;
 int iTotelLen = 0;
 /*read 1024 bytes at a time*/
 while ((iBufLen =
  fileInputStream.read(bBuf)) !=
   -1) {

 fileOutputStream.write(bBuf);
 

Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Murat Birben
Actually i'm not familiar with the interanls of
enctype=multipart/form-data thing. I think, i should read about this
right?
By the way i'll change the form tag as you and Pid suggested.

Thanks,

On Fri, Jul 2, 2010 at 4:21 PM, André Warnier a...@ice-sa.com wrote:

 Murat Birben wrote:

 Ok, here is the html form:

form action=ResourceUploadServlet method=POST
 enctype=multipart/form-data
   input type=file name=Content /
FileName :input type=text name=FileName /
Path:input  type=text name=Path /
input type=submit value=Submit /
/form

  Ok.
 First, you should probably change the form tag as follows :

   form action=/ResourceUploadServlet method=POST
  enctype=multipart/form-data

 Next:
 When the browser sends this to the server, it will do this using a
 particular format, similar to the (internal) format of an email with
 attachments.
 This is what the part : enctype=multipart/form-data is all about. Are you
 familiar with this ?



 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org




-- 
Murat BIRBEN


Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread Pid
On 02/07/2010 14:33, Murat Birben wrote:
 It is a virtual machine on ESXi so df shows me the whole storage I

Does it?  I'm not sure it does.

 think. Is there any other way to see the disk usage for virtual machines?

That's a question I can't answer I'm afraid.


p


 On Fri, Jul 2, 2010 at 4:20 PM, Pid p...@pidster.com
 mailto:p...@pidster.com wrote:
 
 On 02/07/2010 14:02, Murat Birben wrote:
  ubuntu 8.04 server
 
 What does the command 'df -k' report?
 Please paste the results.
 
 
 p
 
  On Fri, Jul 2, 2010 at 3:50 PM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com wrote:
 
  On 02/07/2010 12:20, Murat Birben wrote:
   I'm getting There is no space left on disk message when i
 try to do
   some work on the server after this 0 byte files are created
 
  What is your OS and exact version?
 
 
  p
 
 
   On Fri, Jul 2, 2010 at 1:13 PM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com wrote:
  
   On 02/07/2010 11:01, Murat Birben wrote:
Yes 0 byte files are causing the disk to run out of space
  
   You understand my surprise?
  
   Are you sure the disk is running out of space, or is it that
  the number
   of files permitted in a directory has been exceeded?
  
  
   p
  
  
@Andre Warnier
I'm not actually saving files on the server. I just
 tried to
   simplify my
problem and tried that simple code. Now i'll give a try to
  apache
fileupload api, thanks for advice
   
On Fri, Jul 2, 2010 at 11:52 AM, Pid p...@pidster.com
 mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com
   mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com
mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com
  mailto:p...@pidster.com mailto:p...@pidster.com
 mailto:p...@pidster.com mailto:p...@pidster.com wrote:
   
On 02/07/2010 09:43, Murat Birben wrote:
 Hi all,

 I have a very simple file upload mechanism in
 java. I
  just take
the file and
 save it on the server. I'm testing this simple
 code with
   selenium
and *when
 a timeout occurs in the selenium test *tomcat
 creates
  0 byte
   files
under
 tomcat_home/work/Catalina/localhost/uploadServlet/
  directory as
MultiPart*
 files. It creates thousands of files, until there is
  no disk
   space
left on
 device. What may cause this problem? How can I solve
  this? Is
there anyone
 has an idea about this?
   
Thousands of 0 byte files are causing the disk to
 run out of
   space?
   
   
p
   
 My environment is: Ubuntu - 8.04 server, apache
 tomcat
  - 5.5.29,
sun java
 1.6

 Thanks,

 Here is the code snippet that i use

 File fFile = null;
 FileOutputStream fileOutputStream = null;
 FileInputStream fileInputStream = null;
 try {

 String strFileName =
   request.getParameter(FileName);
 String strPath =
 request.getParameter(Path);
 //String strMediaType =
   request.getParameter(MediaType);

 //String strDescription =
request.getParameter(Description);
 fFile = (File)
  request.getAttribute(Content);

 int index = strPath.length() - 1;
 //If the
  user
   forgets to
 put the last / for the path... We put it for him/her

 if 

Re: Getting a servlet to work within static pages

2010-07-02 Thread David kerber

On 7/2/2010 9:23 AM, Pid wrote:

On 02/07/2010 14:01, David kerber wrote:

My system:
Debian Lenny (5.x) on a low end machine in my basement (so I can do
whatever I want/need to it)

TC 6.0.24, installed in /home/davek/apache-tomcat-6.0.24

java version 1.5.0_17
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_17-b04)
Java HotSpot(TM) Client VM (build 1.5.0_17-b04, mixed mode, sharing)

Web content and apps are installed in
/home/content/webapps/ROOT
and
/home/content/webapps/ginp

ROOT contains all the static content for my personal website, with
various html files and sub-folders, and a couple of .jsp files from this
issue I'm asking about.

ginp is the open-source photo album project I'm using to manage and
display post some of my pictures.

I'm trying to figure out how to use some of the functions from ginp
(specifically one of several defined as tagsets) in my static pages to
display a list of available photo albums.  And I want to do this
transparently, so the list appears to be just part of a static page,
without me having to have /ginp/ show on the url because it was
redirected or forwarded to the servlet.

I've tried renaming the .html page to .jsp and putting the code to call
the tag in the desired spot (code below), but I'm getting the exception
below.  I think the biggest issue is my unfamiliarity with using
tablibs, but am wondering if there is also some tomcat setup issues I'm
missing here.

Any help appreciated!!

Dave


The complete .jsp is:

HTML
HEAD
   TITLEPhotography/TITLE
/HEAD
BODY background=sand.gif
H2 align=centerPhotography/H2
P
Some of my favorite pictures for you to peruse and comment on:

br
h3Picture collections/h3

%@ taglib uri=/ginp prefix=ginp %


Silly question, have you got the jars for that taglib in:

ROOT/WEB-INF/lib?

p


Not silly at all.  I was thinking they'd pick up what they need from the 
ginp webapp, but I've never done this kind of cross-context calling 
before.  I'll try that.



D

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: [OT] Using httpd's mod_rewrite with mod_jk

2010-07-02 Thread Rainer Jung

On 02.07.2010 02:37, Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rainer,

On 7/1/2010 4:54 AM, Rainer Jung wrote:

Usually mod_rewrite is perfectly compatible with mod_jk. I must confess,
that I'm not 100% sure about the case, where you try to rewrite a
request that originally would have been handled by mod_jk to something
that should not be handled by it.


It appears that my setup (rewriting a request that normally would go to
jk to one that shouldn't go to jk) still ends up being handled by jk.


Two possibilities: if it doesn't actually work, you can set the env var
no-jk as a side effect in your rewrite rule. If mod_jk fins this env
var set, it will decline to handle the request. Alternatively, if you
are fine with redirecting by mod_rewrite instead of rewriting
internally, the redirecting should also win over mod_jk.


Okay, I changed my RewriteRule to this:

 RewriteRule .* /bad-browser.shtml [L,E=no-jk]


OK, I did a little test:

RewriteRule .* /bad-browser.shtml [L,E=no-jk:1]

should work. A quick glance at mod_rewrite's code indicates it drops E= 
rules when no value is present.


Have fun!

Rainer

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Mod_jk: Uri * is invalid. Uri must start with /

2010-07-02 Thread Rainer Jung

On 02.07.2010 14:50, Matteo Turra wrote:

I have Apache/2.2.14 (Unix) and mod_jk/1.2.28 with a Tomcat 6.0.20 farm
in load balancing.

In the mod_jk.log I get a line like this each second.

[warn] map_uri_to_worker_ext::jk_uri_worker_map.c (962): Uri * is
invalid. Uri must start with /

I checked all the JkMount directive in the virtual host

Any suggestion?


The broken URI is the one send with the request. I assume there's some 
probing going on, like live checking done by a load balancer, end-to-end 
monitoring or similar.


I guess they are sending you something like

OPTIONS * HTTP/1.1

which is a vlid request, but mod-jk complains. Nothings broken, but of 
course the warning is annoying. You could file an issue in bugzilla, 
because this will be easy to fix (don't warn if the URI is '*').


Regards,

Rainer

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Murat Birben wrote:

Actually i'm not familiar with the interanls of
enctype=multipart/form-data thing. I think, i should read about this
right?

Right.

Start here :
http://www.w3.org/TR/html401/interact/forms.html
17.13 Form submission

Then graduate to this if you really want to know the details :
RFC 2045
http://www.ietf.org/rfc/rfc2045.txt

But, as a summary :
With the form you showed earlier, what the browser will send to the server is a block of 
text data looking (approximately) like this :


(start)
POST /ResourceUploadServlet HTTP/1.1
Content-type: multipart/form-data; boundary=-something
.. more header lines, followed by one empty line ..

-something
Content-type: text/plain
Content-disposition: form-data; name=FileName
Content-length: 18

some-file-name.pdf
-something
Content-type: text/plain
Content-disposition: form-data; name=Path
Content-length: 10

/some/path
-something
Content-type: application/pdf
Content-disposition: form-data; name=Content; 
filename=some/path/and/file-name.pdf
Content-length: 132456
Content-transfer-encoding: Base64

pcEAJ2AJBAAA+BK/EAAABgAAHAgAAA4AYmpiauvI68gA
AAAHBBYALhAAAImiAACJogAAHAD//w8A
AAD//w8AAAD//w8AAKQAAMADwAMAAMAD
wAMAAADAAwAAAMADwAMAABQAANQD3AYA
AADcBgAAANwG3AYAAAwAAADoBgAADNQDrAwAAP4ABwAA
AAAHAAcABwAH2wcAAADbBwAAANsH
KwwAAAItDC0MLQwtDC0MLQwAACQA
AACqDQAAaAIAABIQAAByUQwAABUAwAMAAADbBwAA
AADbBwAAANsH2wcAAADbBwAAAFEM
AADAAwAAAMADAAcHAADbZgwAABYAAAD3
.. and many similar lines
...
(end)

Each input of the form is going to result in one of the form-data blocks above. The 
input type=file will result in some very large block like the last one, which contains 
the binary data of the file, encoded in Base64 encoding.


Tomcat 5.5 (and 6.0), natively, do not contain any standard code capable of parsing such a 
POST data format and returning it nicely to your servlet.

(And you cannot just do a request.getParameter('Content') either.)
(but with Tomcat 7.0 however you should be able to).

To handle this kind of POST with Tomcat 5.5 or 6.0, you have either to do the work 
yourself (not recommended), or use something like FileUpload to do it.

But you cannot just read the body of the request, and copy it to a disk file.
Or rather, you can, but then you will have the whole block above in your disk 
file.

I do not remember how the FileUpload module really works, but it allows you to retrieve 
each of the blocks above (=form parameters) independently, and it will do all the decoding 
for you.
For the file part (named Content), it probably gives you already a Stream, from which 
you can read to retrieve the (decoded) content of the file.

THAT is what you should be copying to a disk file.

Got the general idea ?

And, as pid was saying, the FileUpload documentation should certainly provide some good 
examples.


But, no matter how you do this,

read this 3 times
/NEVER/ accept the path or the filename that the user is entering in the form, to just 
write this file to disk.

/read this 3 times

Remember what the user has entered, and write it somewhere as a text.  But create a path 
and a (unique) filename yourself, in your servlet, to write the file.
That will protect you not only against nasty people trying to crash your server, but also 
against innocent users entering file names with spaces in them, or funny characters that 
are illegal in a filename on your system, or re-using a filename that already exists.

(to name just a few of the things that can happen).

All that still does not tell us why your servlet creates 0-size files, but maybe with the 
above explanation you can figure this out yourself.


My scenario :
- your first getParameter() call sucks in the whole POST (all the above)
- your next getParameter() calls do not have anything else to get, and return 
null
- by the time you try to read the body of the POST, there is nothing left, so you also get 
null

- and then you write this (null) to the output file, and you get a null-size 
file.

Repeat the above cycle once for each POST.




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 5.5 creates 0 byte files

2010-07-02 Thread André Warnier

Pid wrote:

On 02/07/2010 14:33, Murat Birben wrote:

It is a virtual machine on ESXi so df shows me the whole storage I


Does it?  I'm not sure it does.


No, it does not. It shows only the disks allocated to this virtual machine.
That's the point of virtual machines, you /can/ only access whatever is allocated to that 
virtual machine.





think. Is there any other way to see the disk usage for virtual machines?


That's a question I can't answer I'm afraid.


There should be a way, from the web console of vmware ESX, to point to the one virtual 
machine and see how much disk space is allocated/used.

But the first method is easier.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Question on ClientAbortException

2010-07-02 Thread Leo Donahue - PLANDEVX
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/connector/ClientAbortException.html

What does this mean exactly?  A user makes a request for a resource and closes 
the browser before they get the response?


Jul 2, 2010 10:04:27 AM com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: executePhase(RENDER_RESPONSE 
6,com.sun.faces.context.facescontexti...@1efe4ac) threw exception
javax.faces.FacesException
at 
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:135)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at 
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at 
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at 
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at 
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
at 
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at 
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at 
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at 
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:619)
Caused by: ClientAbortException:  java.io.IOException
at 
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:358)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at 
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:309)
at 
org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
at org.apache.catalina.connector.Response.flushBuffer(Response.java:548)
at 
org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:279)
at 
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:203)
at 
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
... 32 more
Caused by: java.io.IOException
at 
org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:696)
at 
org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:726)
at 
org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:124)
at 
org.apache.coyote.http11.InternalAprOutputBuffer.doWrite(InternalAprOutputBuffer.java:532)
at org.apache.coyote.Response.doWrite(Response.java:560)
at 
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)
... 39 more


Using CATALINA_BASE:   C:\apache-tomcat-6.0.26
Using CATALINA_HOME:   C:\apache-tomcat-6.0.26
Using CATALINA_TMPDIR: C:\apache-tomcat-6.0.26\temp
Using JRE_HOME:C:\Program 

Re: Question on ClientAbortException

2010-07-02 Thread Pid
On 02/07/2010 20:49, Leo Donahue - PLANDEVX wrote:
 http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/connector/ClientAbortException.html
 
 What does this mean exactly?  A user makes a request for a resource and 
 closes the browser before they get the response?

Yup.


p




signature.asc
Description: OpenPGP digital signature


Re: Implementing Connection Pooling

2010-07-02 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

On 7/2/2010 8:27 AM, Caldarale, Charles R wrote:

 From: Andrew Laughlin [mailto:andrew.laugh...@gmail.com] Subject:
 Re: Implementing Connection Pooling
 
 Because I won't have this info until run-time.
 
 Which means you can't configure the appropriate Resource elements.
 
 It appears Apache Commons has a GenericObjectPool class I can used
 to implement my own connection pooling facility. However I don't
 want to go to the trouble if the current method actually works.
 
 Which it can't possibly do, for the reasons previously given.

Tomcat's Resource configuration is intended to be in complete control
of the management of the DataSource, and doing what you are doing might
work for this version of Tomcat, but not for another.

I think, Andrew, that you should probably manage your DataSource
entirely on your own, and configure it 100% in your own
ServletContextListener.

Consider the following (which has already been mentioned by someone
else): once you call getConnection on the BasicDataSource, the
configuration information appears to be set in stone: you can't change
the username and password (or connection URL) at that point.

If you deploy several webapps using the same Resource template, then
will share the same DataSource. Once the first webapp calls
getConnection, the configuration is fixed, and then all webapps share
the same configuration from that point forward, which is likely to be a
security problem.

Tomcat also fails to close-down a DataSource that has been created for a
particular webapp after that webapp is undeployed. I'm not entirely sure
if Tomcat replaces the DataSource when another webapp defines a similar
Resource (in META-INF/context.xml, of course). This may be another
situation where security and/or resource management issues arise.

It's not hard to create your own BasicDataSource in a
ServletContextListener and stuff it into the JNDI context yourself. If
you do this, your custom realm should probably work just fine (you might
have to set localDataSource=true in your Realm configuration).

Hope that helps,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwuTmcACgkQ9CaO5/Lv0PABmQCcCsc60xWYmWVD4RkHzkYLKd/k
CagAn1ENZBfCrJesfboW9w2ooYtM2eRx
=88gj
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Question on ClientAbortException

2010-07-02 Thread Caldarale, Charles R
 From: Leo Donahue - PLANDEVX [mailto:leodona...@mail.maricopa.gov]
 Subject: Question on ClientAbortException
 
 http://tomcat.apache.org/tomcat-6.0-
 doc/api/org/apache/catalina/connector/ClientAbortException.html
 
 What does this mean exactly?  A user makes a request for a resource and
 closes the browser before they get the response?

Probably.
 
 Caused by: java.io.IOException
 at
 org.apache.coyote.http11.InternalAprOutputBuffer.
 flushBuffer(InternalAprOutputBuffer.java:696)

The APR flushBuffer() method got a negative response from the native 
Socket.sendbb() method in the APR library.  The usual cause is client 
disconnect, but other less common network errors could trigger it.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Getting a servlet to work within static pages

2010-07-02 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

David,

On 7/2/2010 10:04 AM, David kerber wrote:
 On 7/2/2010 9:23 AM, Pid wrote:

 Silly question, have you got the jars for that taglib in:

 ROOT/WEB-INF/lib?

 p
 
 Not silly at all.  I was thinking they'd pick up what they need from the
 ginp webapp, but I've never done this kind of cross-context calling
 before.  I'll try that.

Tomcat isn't going to load taglibs from another context, so you'd better
deploy the taglib JAR in both contexts. Once you do that, use the
correct taglib URI to reference it. Presumably /ginp isn't correct.
It's probably something like http://www.ginp.com/taglibs/v1; or
something like that.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwuUngACgkQ9CaO5/Lv0PCudACfVnrN/mCn7+KExkaH+qjHIhEF
4p4An0alqNJw25RbmAMct70vugUSoCfp
=IXCV
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: embedded tomcat, work folder wipe out issue

2010-07-02 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Federico,

On 7/2/2010 8:36 AM, Federico Fissore wrote:
 I've embedded tomcat so to have multiple webapps running with separate
 java processes (each embedded tomcat runs its own webapp, listening to a
 different tcp port), because of some memory issues we have.

Have you considered simply using CATALINA_BASE to run separate Tomcats?
That would likely be easier than writing an embedded Tomcat wrapper, etc.

 having some issues with jsps not being recompiled after an upgrade of a
 webapp (that takes a restart of its tomcat), we scripted the wipe out of
 that context work folder
 
 say the folder is
 /opt/tomcats/work/StandardHost[localhost].StandardContext[/myWebApp]Engine/...
 after tomcat has stopped, we delete the myWebApp]Engine folder so to
 oblige the starting tomcat to recompile every jsp

Are you sure Tomcat is completely shut down when you perform the delete?
If not, Tomcat might have some in-memory notion of what's on the disk,
and get confused when the files suddenly disappear.

Have you tried undeploying the webapp and re-deploying? That should
cause Tomcat to clear it's own work directory for that webapp.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwuU1cACgkQ9CaO5/Lv0PCiewCeKJln6FZmFtAv9fv6wCEPDu7b
rAEAoKNXlXtWZF+IMgym5e8dLBwI4W/Y
=5fG3
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: JK connector and extra characters showing up

2010-07-02 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chuck,

On 6/30/2010 11:18 PM, Caldarale, Charles R wrote:
 From: Christopher Schultz [mailto:ch...@christopherschultz.net]
 Subject: Re: JK connector and extra characters showing up

 Those 4 extra characters are likely to be the chunk size. 31 66 66 38
 is, well, 1ff8, which is 792 in decimal.
 
 Not on my calculator; would you believe 8184 in decimal?  There's an 
 extremely low probability of having a decimal value containing fewer digits 
 than its hex equivalent...

Hmm. It appears I was sleepy and lazy altogether.

8 + 16*15 + 32 * 15 + 64 * 1 = 792

but the LHS is complete malarkey. At least my arithmetic was correct ;)

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwuiDcACgkQ9CaO5/Lv0PA50gCfTIFZAozmYPnf2mfIPjc7c9GE
e+MAn0rDAb6XYpKsf4eKdDbJlh3iZ2lT
=O2b0
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Application vars -

2010-07-02 Thread Shay Rojansky
Just my comments on the dispatching idea proposed below...

If smooth processing with no freeze-time is important, I'm assuming there is
also some sort of cluster/high-availability functionality. If this is the
case, you are already running at least two Tomcats on different servers, and
using some load-balancing/dispatch mechanism - for example Apache with
mod_jk. If you have just one Tomcat you have much more to worry about than
Tomcat freezing during webapp reload :)

So, why not just use the load balancer's functionalities, instead of writing
a dispatcher yourself (webappX below)? In other words, you stop the webapp
on tomcat1 - the load balancer (or mod_jk or whatever) detects this
immediately and stops forwarding requests to it. You do whatever config
change, and start the app again. At this point the new app is added back to
the load balancer. Repeat same thing with tomcat2, tomcat3...

Seems simpler than deploying two copies of a webapp + a third dispatcher
that you need to write and maintain (and all this across the N servers in
your cluster)...

One last note: if I remember correctly, you can only forward requests within
the same servlet context (i.e. webapp), so dispatching from webappX to
webappA or webappB would be non-trivial. You could do redirections, but this
exposes your internal mechanism to clients and is really bad.

Shay

On Fri, Jul 2, 2010 at 4:27 AM, André Warnier a...@ice-sa.com wrote:

 Eric P wrote:

 So it makes sense to go into what disruption means. I'm not 100% sure
 about the following, it would be good if a tomcat heavyweight would
 confirm/refute what I say.

 When you initiate a webapp reload, Tomcat waits for requests that have
 already started processing to terminate. This ensures that people who
 accessed your app just before the webapp get a complete response. Once
 that's done, the application is reloaded and your servlets' init methods
 are
 called if necessary. During this time, incoming requests aren't denied,
 they
 are just paused until the reload is complete.

 So the only disruption people see is your application freezing up for the
 time it takes to reload (which is going to depend on what you your
 initialization consists of). No ugly server unavailable errors or
 anything
 of the sort.

 If you don't like the idea of your app freezing, think about this.
 Rereading
 environment params without reloading has its own risks, namely potential
 race conditions. Imagine you have 5 parameters, and requests are coming
 in
 as you are reading these in and initializing your webapp. A request might
 be
 handled while 2 params have been read, but 3 still contain the old
 values.
 If you start to think about locking/synchronization to solve this you're
 definitely better off just using Tomcat's reload mechanism.

 So my answer would be, trust Tomcat's reloading process unless you
 absolutely want to avoid your webapp freezing for the time it will take
 for
 it to init (this depends on the webapp). If you want to do your own
 reloading, think long and hard about potential race conditions (which
 will
 occur in all except the simplest cases).

 Again, all this should probably be verified, you can set up very simple
 test
 cases with a JSP that  sleeps, etc.



 Shay,
 I think you made a good case for keeping app vars in web.xml (i.e., seems
 pretty apparent now that's where they belong).

 Thanks for taking the time to respond.  I sincerely appreciate it!
 Eric P.

  +1
 Very neat explanation.

 While not being a great specialist, I would just like to expone what may be
 an alternative, if one really wants to diminish the (apparent) time it takes
 for a new version of a webapp to become available.  Since I am no great
 specialist, I will just outline the idea without Java/servlet specifics.

 (Maybe also I am barging through an open door, and there already exists a
 standard mechanism for doing this, but oh well..)

 Imagine that you have 2 identical versions of the same intrinsic webapp
 deployed, like

 catalina_base/webapps/webappA
 catalina_base/webapps/webappB

 You create a 3rd webapp webappX, which is the one the users see, and which
 is just a dispatcher to either one of the two webapps webappA and webappB.
 So you now have :

 catalina_base/webapps/webappX
 catalina_base/webapps/webappA
 catalina_base/webapps/webappB

 The users always use the URL /webappX.
 When a call is made to webappX, /it/ decides, in function of some external
 parameter Y, whether to dispatch the call to either webappA or webappB.

 Say that initially the external parameter Y (which could be a system-wide
 property) is set so that all calls to /webappX are currently dispatched to
 /webappA.
 Now you want to update webappA.
 You change the parameter Y so that calls are now dispatched to (identical)
 /webappB.
 Then you update (redeploy) webappA.  Users see no delay, because they get
 directed to webappB.
 When webappA is deployed and started (which you could check by calling it
 directly),
 

Re: JNI error under tomcat: java.lang.UnsatisfiedLinkError

2010-07-02 Thread Shay Rojansky
Hi Dennis.

So do you see the Load library successful message?

Also, if I remember correctly, the code in eval.java is not a safe way to
load a native library. It's a very good idea to place the System.loadLibrary
in a static { } block, instead of in a method. The way your class is
written, it's possible for the run method to be executed more than once, in
which case loadLibrary will be called more than once (and so will the native
initModels). Not sure what the effects are and if it's related to your
problem but it's a good idea to avoid trouble by fixing it.

Shay

On Fri, Jul 2, 2010 at 3:46 AM, dennis ch dennis.ch2...@gmail.com wrote:

 Hi,

 I have a java class (eval.java) that invokes a native method in an so file
 (libmodel.so, using SWIG 1.3.29 to generate JNI code/wrapper and compiled
 the library). I can use System.loadLibrary() to load the libmodel.so
 without
 any error (-Djava.library.path=/usr/lib), and the native method initModel()
 works fine as a standalone application.

 However, when I deploy it as a web service (tomcat 6.0.26 + axis2 1.5.1 +
 eclipse jee helios) to call the native method, I got the following error
 (the first line means the .so was successfully loaded):

 Load library successfully

 [ERROR] com.model.modelJNI.initModel()V
 java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
 org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
at
 org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
at
 org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at
 org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at
 org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
at
 org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
 Caused by: java.lang.UnsatisfiedLinkError: com.model.modelJNI.initModel()V
at com.model.modelJNI.initModel(Native Method)
at com.model.model.initModel(model.java:13)
at com.webservice.run(EvalVita.java:763)
... 25 more


 Below is the body of Eval.java:

 import com.model.*;

 public class Eval {

  static void loadModel() {

try {
System.loadLibrary(model);

System.out.println(Load library successfully);

} catch (UnsatisfiedLinkError e) {

System.err.println(Native code library failed to load. + e);

}
  }
  public void run() {

loadModel();
model.initModel();
  }
 }


 Do I miss anything here?  Any input is appreciated!

 Dennis



Re: SSL SetAllPropertiesRule warning and error [SOLVED]

2010-07-02 Thread MohsenEbrahimi21

Thank you so much Renato. You are the best. 
I searched a lot and didn't find anything, but changing the protocol
attribute works fine.
Thank you so much again.
-- 
View this message in context: 
http://old.nabble.com/SSL-SetAllPropertiesRule-warning-and-error-tp15432321p29062319.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org