Exception sending context initialized - spring

When i am running my application it give me this exception:-
Exception sending context initialized event to listener instance of class
org.springframework.web.util.Log4jConfigListener
java.lang.ExceptionInInitializerError
But this problem is not permanent. If i remove the log4j entries from web.xml and restart p.c and then again add log4j entries and start the server, then the application works fine.
I noticed that when the application is deployed and when i undeploy and again deploy the same application, this problem emerge.
Please help me ........ i am facing this problem from 3 months...

I just investigated it a little and have found the similar issue:
It causes when multiple jar file for log4j is available to application.
From web/application server and from build path(Included from other
path rather than web/application server)
You can see the entire thread here:
http://www.coderanch.com/t/551933/Spring/Exception-sending-context-initialized-event
looks like this is your problem.

Related

Embedded ActiveMQ Server within Tomcat 8

I am trying to embed ActiveMQ Server within Tomcat 8 server.
For that I was following two tutorials available online.
https://isomorphic.atlassian.net/wiki/display/Main/Real-Time+Messaging+with+Tomcat+and+ActiveMQ
and
http://www.tomcatexpert.com/blog/2010/12/20/integrating-activemq-tomcat-using-global-jndi
In first tutorial changes were made only in $TomcatHome/conf/context.xml. But in second tutorial it was recommended to modify context.xml, server.xml and activemq.xml.
I follows both the tutorial separately one by one, also tried to use these with "Tomcat 7". But looks like both are not working for me.
With these changes, tomcat server starts without any issue no error in log. But Embedded ActiveMQ BrokerService is not getting started with Tomcat. Nothing is there in startup log for BrokerService.
Means there is no effect of these configurations on Tomcat Serve, and startup log is same with or without these configuration.
Am I missing anything in configuration for Tomcat 7 or Tomcat 8?
Why new JNDI Resource TAGs in configuration files is not getting picked by Tomcat?
Guys please help me.
I suggest looking at starting up ActiveMQ using the Spring XML bean configuration. Generally, you'll need/want to do some configuration of the broker and having the full XML is a simple way to manage that. I suggest looking at creating a simple war file that starts up a Spring beans.xml file. That file should just be the same contents as the conf/activemq.xml configuration. You then add all the JNDI resources as needed to point to the embedded broker.

Configuring WebLogic Logging for Commons Logging

I'm writing a Spring web application deployed to a WebLogic 10.3.3 server. I've tried to enable logging as described by the Oracle documentation here: http://docs.oracle.com/cd/E14571_01/web.1111/e13739/config_logs.htm#WLLOG154
Both commons-logging-1.1.1.jar and com.bea.core.weblogic.commons.logging_1.4.0.0.jar are placed in the lib folder of the WebLogic domain, and I'm attempting to initialize the logger exactly as described in the Oracle example. I see the following exception in the server console:
Caused by: org.apache.commons.logging.LogConfigurationException: The chosen
LogFactory implementation does not extend LogFactory. Please check your
configuration. (Caused by java.lang.ClassCastException:weblogic.logging.commons.LogFactoryImpl)
Does anyone know of any possible solutions?
Works for me. Seems like a classloader issue.
Check whether another commons-logging lib is not loaded before application provided commons-logging.

glassfish 3.1.2 monitoring EJB container, bean-methods

the glassfish application server provides a nice monitoring REST interface.
To use it u can enable several monitorable items in the admin console, for example the EJB container. The documentation says, you can retreive EJB-statistics for every deployed application.
If you request a URL like localhost:4848/monitoring/domain1/server/applications/APPNAME/EJBNAME you will get statistics for a given EJB of the application.
Further, there is a possibility to look more deeply into each bean-method of the ejb, for example the executiontime, about which the documentation says:
"Time, in milliseconds, spent executing the method for the last successful/unsuccessful attempt to run the operation. This is collected for stateless and stateful session beans and entity beans if monitoring is enabled on the EJB container."
The problem now is, monitoring is enabled on the EJB-container (Level set to HIGH), but nothing is sampled in any bean-method in any EJB in any deployed application.
Is there something special to do in the bean and/or the glassfish ?
Thanks in advance for help,
Chris
EDIT:
Ok, I noticed something more about that behaviour:
In the server log you get a log message for each deployed EJB like that:
INFO: EJB5181:Portable JNDI names for EJB DataFetcher // ...
If I set the ejb-container monitoring level to HIGH (which is what I want to do), I get the following warning for each deployed EJB, regardless which app I deploy:
WARNING: MNTG0201:Flashlight listener registration failed for listener class : com.sun.ejb.monitoring.stats.StatelessSessionBeanStatsProvider , will retry later
I googled the warning but none of the resulst really help me enabling EJB monitoring...
This seems to be a Bug in Glassfish.
EJB Monitoring is currently not working in 3.1.2.
JIRA issue is already raised: http://java.net/jira/browse/GLASSFISH-19677
There is nothing "special" to do.
http://docs.oracle.com/cd/E18930_01/html/821-2431/abeea.html
For me it seems as if you probably enabled the monitoring option on the wrong configuration. Please double check.
To get rid of this message you can disable the monitoring on ejb container option below in the image
From Monitor Data--->Configure monitoring--->make ejb container log off

Why do I get "HTTP Status 503 - This application is not currently available" in tomcat 6?

I have an application written with Struts2 and Spring for DI and I'm using Tomcat 6 as container. Assuming I have packaged the application as my-application.war after deployment on Tomcat I can access it through http://my-host/my-application.
When I delete the .war file, Tomcat's supposed to undeploy the application and according to here When I try the http://my-host/my-application I should get:
HTTP Status 404
but instead I get:
HTTP Status 503 - This application is not currently available
When I redeploy the application to same context path I get a weird exception:
Unable to instantiate Action, [ActionClass], defined for '' in
namespace '/' Failed to convert value of type [MyClass] to required type
[MyClass] for property 'myClass': no matching editors or conversion strategy
found
in which ActionClass has a property myClass of type MyClass which is injected by Spring and by default is a singleton. It's weird because type of both objects is the same. I suspect the application don't get undeployed completely in the first place cause when I restart Tomcat the scenario will be repeated. I would appreciate any help on finding the possible cause of this.
Well I think I found the answer. As I guessed the problem was with the improper undeployment.
It seems that deploying and undeploying an application without restarting the tomcat is a tricky business. When you deploy your application Tomcat classloader loads the classes in of the application and once they're loaded it seems they won't be unloaded with undeployment. And constantly deploying and undeploying an application will cause a serious memory leak. This case is specially true with singletons since the remained version of object in JVM doesn't match the newly deployed class. Hence the error I got above.
The safe path seems to be restarting Tomcat each time you redeploy any application.
Sources helped me find these information:
What makes hot deployment a "hard problem"?
Tomcat: hot deploying new jars
This post on CodeRanch
And some more sources found on Google

App hangs on --> 'Initializing Spring root WebApplicationContext' on websphere

When I try to deploy the app ear through RSA on websphere, the deployment hangs on the following line:
Initializing Spring root WebApplicationContext.
Initialization successful.
And then server times out.
How can I troubleshoot this problem?
Which log should I see? The logs folder is rather confusing with too many files.
When I deploy the app through the admin console by building .ear first, it deploys fine.
I assume you are referring to publish the application within RSA/RAD. The logs are the same whether you deploy through this or via the admin console.
SystemOut, SystemErr and trace.logs would be my first points of check.
I am assuming your application spits out this info line:
Initializing Spring root WebApplicationContext. Initialization successful
When does it do this? This would likely occur after the application has been deployed and the application is in its starting phase.
I would check this location
/profiles//installedApps/
Replace all the <...> with the respective values in your environment.
Once deployment is successful you should see a directory with the name of your application eg.
This tells you that the application is installed in your Test environment server.
Publishing effectively does two activities - Install and Start the application.
Once you see the EAR here you know that your problem lies in your application start up activities.
Try and see if you can narrow down from there.
HTH
Manglu

Resources