ServletContextListener called twice for one virtual host on glassfish - glassfish

I have a situation when ServletContextListener methods contextInitialized is called twice even if I have only one virtual host defined on the server ... I use Glassfish server.

This is the same issue I faced recently with glassfish where I had my ServletContextListener invoked twice even if I had a single virtual host defined on the glassfish server
By far I found three reasons why this can happen, and they are as follows
If we configure servlet with web.xml and servlet annotation at the same time
If we have multiple virual host on application server(Which doesn't stand valid for this question as we have only one virtual host)
If the application is already deployed on glassfish server and when you run the servlet, the application server starts the servlet which is already and then redeploys the servlet which we asked it to run . so turns out the listener is called twice
Now if we start the glassfish server with no application deployed on it and then run the servlet the method is only called once.
I hope this helped

Related

Weblogic managed servers internal communication with each other in a cluster

I've created multiple managed servers in Weblogic. Each managed server has same IP(IP of weblogic server) and unique port.
I've installed ear and war files in these managed servers and all of them has their own context-root.
For example I have ear file A with context-root A on server A and a war file B with context-root B on server B.
Whenever I browse IP:PORT(A) which has set on server A, this application needs some files on war file B which has deployed in server B. So A can not find its resources and I get error.
I should mention that I put them in a cluster too but nothing changed.
How can handle this matter?
The cluster won't help you in this way because each web app is isolated from others in its own web container. If you need to share data or resources between web apps you can use a shared file system or a database for instance.
For this purpose I've used Oracle Http Server (OHS) plugin. after hours of searching in internet I've found that Weblogic application server does not implement anything to handle this issue.
https://docs.oracle.com/middleware/1213/webtier/

Disable direct access to application via Tomcat

I have a small local (internal to organisation) browser application running on Tomcat. I have inherited an application (also for internal organisation use only) running under PHP server which I have been asked to get running on the same box. I decided the best thing was to get both Tomcat and PHP running under Apache Web Server. Initially I thought this was essential although I now thing as long as I had left them running with different ports this was unnecessary (?).
I have got my Tomcat app running through Apache using the proxy_http_module. I was wondering if there is an easy way to stop direct access to the application via tomcat?
So for example in Tomcat the app is set to run as
http://localserver:1234/superapp
using the virtual host configuration apache allows access as
http://localserver/superapp
presumably this means if I now go in as http://localserver:1234/superapp I am bypassing apache web server ? Assuming (bold assumption) that I have not misunderstood the mechanism, is there a simple way to stop access directly via tomcat (http://localserver:1234/superapp).
Thanks.
You could consider using the proxy_ajp instead of proxy_http. But you can also use the RemoteAddrValve to define restrictions based on IP address:
<Engine name="Catalina" defaultHost="localhost">
...
...
...
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.0\.0\.1"/>
...
</Engine>

weblogic AS: application deployed on a cluster with two managed servers

I'm on Weblogic AS 10.3.5, I have two managed servers pointed to a cluster, so I have two url, one for the first managed server, the other one for the second.
I will deploy my application on the cluster, so will I reach it on both the url? will the application deployed and running on both the servers?
How does it work? Can you give me some references, please?
Is it clear?
Thanks a lot!
First, you shouldn't be using WebLogic 10.3.5 anymore since it has reached the last stage of support called Sustained Support. Consider to upgrade at least to WebLogic 10.3.6.
Related to your question, I believe you are talking about a Web Application and how to access it. First you need to read about Load Balancing in a Cluster. For the web part (JSP and Servlets) basically you have to options: setup a Web Server (like Apache HTTP) to make use of the WebLogic Plug-in, that will then be connected to the WebLogic cluster. The other easier option is to simply use an LBR (load balance router hardware).
These are the "software" solutions you have for Load Balancing your web application in a clustered WebLogic:
WebLogic Server supports the following Web servers and associated
proxy plug-ins:
WebLogic Server with the HttpClusterServlet
Netscape Enterprise Server with the Netscape (proxy) plug-in
Apache with the Apache Server (proxy) plug-in
Microsoft Internet Information Server with the Microsoft-IIS (proxy) plug-in
You can read more about this options at the Configure Proxy Plug-ins documentation page for WebLogic 10.3.6.

RMI returning EJB remote objects

My requirement is
I have two machines, client and server. On server ONLY one port is open (which should not be JNDI port). Client needs reference of EJB remote objects which are deployed in Server, so that it can call methods on those EJB objects.
Here I am planning for RMI communication between client and server on the open port on Server. Upon getting the call server will return the EJB3 object to the client.
Here are my questions
Does RMI allow to return remote EJB3 references to client?
If yes, once EJB reference forwarded to the client, if client calls a method in remote EJB, using which port this communication takes place? Becausue only one port open on server ?
Here is it fine to go with RMI or EJB can be used as communication? I have searched in net, but its not possible to bind an EJB to a port.
Can RMI application deployed in Glassfish?
Thanks
Dek
Does RMI allow to return remote EJB3 references to client?
Yes.
If yes, once EJB reference forwarded to the client, if client calls a method in remote EJB, using which port this communication takes place?
Whichever Piet the EJB is exported on.
Becausue only one port open on server?
Eh?
Here is it fine to go with RMI or EJB can be used as communication?
They are the same thing. The question is meaningless.
I have searched in net, but its not possible to bind an EJB to a port.
That depends on a lot of things such as whether you're using RMI/IIOP and possibly in the specific container.
Can RMI application deployed in Glassfish?
Yes.

Cannot Start Weblogic Managed Server,

We are running Weblogic 7sp6. We have a working single node cluster with an Admin and two Managed servers. We are re-creating a 2nd standalone cluster on a 2nd server. We reinstalled Weblogic and have copied over all the configuration files to make thing. Its the same on both clusters. We changed all the references to IP and hostnames. We have used this method before without problems.
In the current case I can startup the Admin which listens on port 7001,7002. But when I try and startup either of the Managed servers it tells me that myserver1/2 is already up. (Managed Servers). I confirmed that myserver is configured to use port 7012,7013 and I cannot find any port conflicts especially because these exact ports worked on the first cluster. Any ideas of what else to look at? I have logged in the admin console and can see the ports are all unique. Thanks
The current version of WebLogic is 10.3. I'd strongly urge you to upgrade your WebLogic as soon as possible, especially if you're still using the version of JDK that it was certified for. If you're running JDK 1.4, you're crazy.