I have a URL in camel route which is set via JVM custom property and it remains unchanged.
**<camel:to id="to-server" uri="{{serverURL}}" />**
serverURL property is set to a site loadbalancer address http://xyz:8080/Server/transactionServlet
In the network layer this URL can either be pointed to Server 1 or Server 2, the URL should work regardless of which server we're using.
After the switch over from Server 1 to Server 2, our WAR still tries to post to Server 1 and fails.
It appears that our WAR is caching the the URL address (what the site loadbalancer was pointing to at the time) when it was started and does not recognize that we have switched over.
The only workaround is to restart the application WAR, at which point it stores the Server 2 address (what the site loadbalancer is now pointing to) and begins posting transactions to Server 2.
is there any way to make camel not cache the IP Address and post to whatever server URL is pointing to ?
I am using Apache Camel 2.14
Have a look at networkaddress.cache.ttl.
Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as integer to indicate the number of seconds to cache the successful lookup.
A value of -1 indicates "cache forever". The default behavior is to cache forever when a security manager is installed, and to cache for an implementation specific period of time, when a security manager is not installed.
Related
I am trying to set up session replication between two tomcat servers(server1,server2) in two different machines.
I am using StaticMembershipInterceptor and StaticMember instead of Multicast. I am not using any loadbalancer.
Below is the site mainly I have followed. I referred this configuration as this is the exact requirement I have.
http://khaidoan.wikidot.com/tomcat-cluster-session-replication-without-multicasting
I am using Tomcat9.
What I am expecting is after the above configuration is:
Server1: Tomcat A
Server2: Tomcat B
Exected Result :
Firststep:
I start the Tomcat A. Load the webpage.(http://server1:8080) Login to application by entering username and password and session is created.
Secondstep:
I start the Tomcat B. Load the webpage.(http://server2:8080). It should automcatically login to the application without entering username and password. No login page should be available.
Actual Result after the above configuration:
In Secondstep: Login page is available. the reason why login page appears is it creates different session.
When I tested the same configuration in the two nodes of same machine, it works fine. But in different machine, it does not work.
What I tried so far:
Checked the log file of two tomcats - I can see the connection is
established.
Made sure has distributable tag
Also added the same in context.xml
Tried adding inside the tag as I saw it in couple of forum.
Checked netstat -ano I could see ports are listening at 4100 in both
the machines
Am I missing any other configuration? Not sure why it does not work.
I'm assuming you are using cookie-based session-tracking, because it is enabled by default and is preferred over URL-based session-tracking in Tomcat if the client is willing to send JSESSIONID cookies.
Cookies are scoped to a particular hostname and path. So, when you login to Tomcat A (http://server1:8080), you get a cookie scoped to server1/path. Wen you visit Tomcat B (http://server2:8080), your cookie for server1 isn't sent and you are challenged to login.
If you want this to work, you will need to choose one of the following options:
Use a reverse-proxy / load-balancer
Use multiple-IP DNS to resolve server (not server or server2) to multiple IP addresses, each pointing to a separate Tomcat instance
Disable cookie-based session tracking
But the way you are testing things cannot work due to the rules browsers follow for HTTP cookie handling.
I am trying to connect to a file(say index.jsp) on my tomcat server at server startup from within the context initializer method.
What is the best way to do this?
In essence I want to make an HttpConnection to a file on the same server when the server is starting up. Thanks!
There is no port defined for a servlet, so there's no place to query. Tomcat can have 26 HTTP connectors listening on 26 different TCP ports. You are trying to be smarter than the system by picking the port number from some HTTP request because HTTP requests of course have a destination port - however that's just that: the destination port used for that particular HTTP request, and it must be known before writing the HTTP request to the socket. Chicken and egg.
By the way, why do you need a port number? I mean, in a reverse-proxy deployment, for example, the port number is only used by the reverse proxy and should not be used to make hyperlinks, for example.
So, here are some advices: the Internet address of your application (protocol, hostname, port) is deployment configuration that cannot be guessed inside the application itself. Similarly, low level connection details like port numbers are server configuration that still can't be guessed inside the application and must be passed instead. These pieces of configuration are usually passed via:
a table in the database
a configuration file on the filesystem
environment variables
The most recent trend is employing environment variables, that are used to pass configuration bits between programs written in many different languages and deployed in a variety of environments (virtual machines, containers)
Anyone knows what do I have to change so that WebLogic Transaction manager works with a cluster ? I tested and I have it working by now with one server. How can I run it on a cluster ?
InterposedTransactionManager itm = TxHelper.getClientInterposedTransactionManager(initialCtx, serverName);
Is the second parameter I do believe needs to be changed !
That is the correct call - from the documentation:
If the initial context is obtained from a non-clustered server, then the server name specified should refer to the same server. If the initial context is obtained from a cluster, then the server name specified should refer to a server within the cluster.
Just pick any server in your cluster and it should still work the same way.
You will probably want to look into other options if you are clustering such as (Oracle API here):
setClusterwideRecoveryEnabled(boolean isClusterwideRecoveryEnabled)
Specifies whether recovery operations for a distributed transaction are applied to all the servers of the cluster hosting InterposedTransactionManager rather than just the server hosting the InterposedTransactionManager.
I get a IllegalArgumentException: Request header is too large from glassfish every now and then.
I know how to get arround this - need to switch to POST request. There is enough good articles about this.
But my problem is that I don't know who sends me this request.
Is there a way to put more details into this error message?
The IP Address would be enough.
I guess this error happens before my servlet code is processed.
So I cannot add the IP address to the error message by my self.
Thanks for your help.
Definitely in this case the control will not even come to the application to apply some logic to know the Remote Address. Only the Server you are using provide these information in logs.
Any server which you are using logs the request in web access logs.
By default those log entries will also have the remote address of the client who made the request. If it does not exist, check with the Server team how to configure logging the remote address in the web access logs.
References:
How to enable access logging in Glassfish
Enabling Http Access log in Glassfish
One way would be to use a ThreadLocal and put the instance of HttpServletRequest inside it in the beginning of request processing (a servlet Filter perhaps).
This way, in the error handler, you could obtain the instance of HttpServletRequest from the thread local variable, and - for example - check the IP adress of the sender.
When executing a post or put request assumption is made that there is not limit in data size which is send over the line.
Most web servers have a default configuration of these values. Per default the max-post-size in glassfish 3 is 8192 bytes and glassfish 2.1 is
4096 bytes
Add the following property to http-listener element under domain.xml :
<property name="maxPostSize" value="">
Increase the value if already exists.
I would start with enabling access logging:
asadmin set configs.config.server-config.http-service.access-logging-enabled=false
you should also set your logging format with
asadmin configs.config.server-config.http-service.access-log.format=XXXX
hope this helps tracking down the problem
I have a simple web service deployed on tomcat using Apache Axis.
If i access the webservice as http://localhost:8080/webservices/TransactionService i see the usual message
TransactionService
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
showing that the web service is available and ready for use.
However if i access it as http://10.0.0.1:8080/webservices/TransactionService (10.0.0.1 is the actual IP of the machine. I'm accessing it on the same machine as above, machine hosting tomcat) i get:
HTTP Status 404 - /webservices/TransactionService
--------------------------------------------------------------------------------
type: Status report
message: /webservices/TransactionService
description: The requested resource (/webservices/TransactionService) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.5
There is nothing in the tomcat logs
If i try deploying on Jetty it all works fine.
Is there any explanation for this? Any pointers most welcome.
Tomcat can listen on different hostnames/IPs in a different way. Specifically, every host/IP can have its own work directory:
<Host name="localhost" workDir="/workdir">
...
</Host>
Application deployed to one workdir won't be available to a host with another workdir.
Check your configuration.
UPDATE: if name is specified as name, not IP, check that that name is resolved to 10.* address too.
Also, one of the hosts is default. It responds to all requests now matter what host they are targeted too, if there is no specific Host. For your setup you may want to leave only that one active.
I don't think a change to Tomcat configuration is the answer. I don't have to do such a thing to use my local IP address or localhost.
Could it be as simple as an addition to your hosts file? I've got mine in c:/windows/system32/drivers/etc/hosts, and there's an entry for "127.0.0.1 localhost" in it.