I have a web-app (Tomcat 6, log4j 1.2.16), which starts with a listener. Undeploying the application throws the following exception:
INFO (HqListener.java:28) - HqListener exited!
log4j:ERROR log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload.
java.lang.IllegalStateException: Class invariant violation
at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at com.mchange.v2.log.log4j.Log4jMLog.getMLogger(Log4jMLog.java:51)
at com.mchange.v2.log.MLog.getLogger(MLog.java:145)
at com.mchange.v2.sql.SqlUtils.<clinit>(SqlUtils.java:37)
at com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:290)
at com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:316)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:181)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at net.hq.util.Db.init(Db.java:15)
at net.hq.process.ConnectionGateway.run(ConnectionGateway.java:89)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "HQ Gateway Thread" java.lang.NullPointerException
at net.hq.process.ConnectionGateway.run(ConnectionGateway.java:129)
at java.lang.Thread.run(Thread.java:662)
Jul 3, 2011 3:03:53 AM org.apache.catalina.core.StandardContext stop
HqListener.java is my listener and it reports a successful shutdown.
How do I get rid of this exception message?
Check this jira bug for your solution: http://java.net/jira/browse/GLASSFISH-16767
Similar resolved issue on stackoverflow here: Undeploying a Grails App from Glassfish gets a Class invariant violation
Setting the property
<jvm-options>
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
</jvm-options>
in the domain.xml file in Glassfish resolves the issue; not certain where to set this in Tomcat, perhaps server.xml?
The way I solved this problem (in glassfish environment) is to avoid declaring the logger as static, e.g.
private static final Logger logger = LoggerFactory.getLogger(BootStrapListener.class);
If you remove static from the above declaration, you will no longer get the above error.
Related
after some code changes I observe a very odd exception from the payara server. The problem with it, I cannot pinpoint down what it is complaining about. Basically I don't know even what is wrong.
Any ideas what could be wrong are much appreciated.
Exceptions in the log during startup:
{"Timestamp":"2018-07-14T11:31:34.430+0000","Level":"WARNING","Version":"Payara 4.1","LoggerName":"javax.enterprise.system.core","ThreadID":"58","ThreadName":"AutoDeployer","TimeMillis":"1531567894430","LevelValue":"900","MessageID":"NCLS-CORE-00069","LogMessage":{"Exception":"Exception while dispatching an event","StackTrace":"org.glassfish.api.invocation.InvocationException
at org.glassfish.api.invocation.InvocationManagerImpl.postInvoke(InvocationManagerImpl.java:219)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:310)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:333)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:505)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:227)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:536)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:544)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:540)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:570)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:562)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:561)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1469)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1851)
at org.glassfish
.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:597)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:484)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:412)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:403)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
"}}
Followed by -- twice:
{"Timestamp":"2018-07-14T11:31:34.998+0000","Level":"SEVERE","Version":"Payara 4.1","LoggerName":"javax.enterprise.web.core","ThreadID":"58","ThreadName":"AutoDeployer","TimeMillis":"1531567894998","LevelValue":"1000","MessageID":"AS-WEB-CORE-00108","LogMessage":{"Exception":"ContainerBase.addChild: start: ","StackTrace":"org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5523)
at com.sun.enterprise.web.WebModule.start(WebModule.java:594)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:956)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:939)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2105)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1750)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:294)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:357)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:509)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:227)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:536)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:544)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:540)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.e
xecute(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:570)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:562)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:561)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1469)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1851)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:597)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:484)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:412)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:403)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2884)
at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:2080)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:236)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:95)
at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:239)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:336)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:163)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5520)
... 34 more
Caused by: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3005)
at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:5043)
at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1732)
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2882)
... 41 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:353)
at com.sun.enterprise.web.WebContainer.createListenerInstance(WebContainer.java:808)
at com.sun.enterprise.web.WebModule.createListenerInstance(WebModule.java:2102)
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:3003)
... 44 more
Caused by: java.lang.NullPointerException
at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:358)
at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:283)
at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:476)
at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:429)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:337)
... 47 more
"}}
This warning comes later a couple of times
{"Timestamp":"2018-07-14T11:31:35.079+0000","Level":"WARNING","Version":"Payara 4.1","LoggerName":"javax.enterprise.web","ThreadID":"58","ThreadName":"AutoDeployer","TimeMillis":"1531567895079","LevelValue":"900","LogMessage":{"Exception":"java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener","StackTrace":"java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:960)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:939)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2105)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1750)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:294)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:357)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:509)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:227)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:536)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:544)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:540)
at j
ava.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:570)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:562)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:561)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1469)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1851)
at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:597)
at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:484)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:412)
at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:403)
at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
"}}
These exceptions are now repeated multiple times followed by the container has not yet started exception and in the end the good old "Autodeploy failed"
Locally it deploys fine, only on the server (OpenShift Linux Pod) it fails.
This are the only warnings I get on a local successful deploy (app runs):
WARNUNG: Could not load service class fish.payara.appserver.roles.api.extension.RolesCDIExtension
WARNUNG: Could not load service class fish.payara.appserver.roles.api.extension.RolesCDIExtension
WARNUNG: Could not load service class fish.payara.appserver.roles.api.extension.RolesCDIExtension
Information: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
Information: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
Information: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(#Observes ProcessAnnotatedType) receives events for all annotated types. Consider restricting events using #WithAnnotations or a generic type with bounds.
WARNUNG: The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean from private javax.enterprise.inject.spi.Bean org.glassfish.soteria.cdi.LoginToContinueInterceptor.interceptedBean is not resolvable to a concrete type.
WARNUNG: The following warnings have been detected: WARNING: Parameter interceptedBean of type javax.enterprise.inject.spi.Bean from private javax.enterprise.inject.spi.Bean org.glassfish.soteria.cdi.RememberMeInterceptor.interceptedBean is not resolvable to a concrete type.
WARNUNG: Class class [Ljava.lang.String; has null package
INFORMATION: Initializing Soteria 1.1-b01 for context ''
INFORMATION: Mojarra 2.2.14 (-SNAPSHOT 20170628-1326 unable to get svn info) für Kontext '' wird initialisiert.
WARN: WELD-000718: No EEModuleDescriptor defined for bean archive with ID: XXXXXXXXX_war.war. #Initialized and #Destroyed events for ApplicationScoped may be fired twice.
What have I tried:
Reverted any version updates of any libs
removed any Startup EJBs -- which in the end showed the above error
Verified the configuration
Thanks in advance
Paul
The exception is most probably a deployment error caused by your application or configuration. Payara Server has a bug that it doesn't log the original exception but throws only a subsequent exception, so you can't see what's wrong in your application from the log messages.
The issue with logging the original message is described in https://github.com/payara/Payara/issues/2332. It's fixed in Payara 5.182 and users also reported that the new weld version in 5.182 removed their deployment error.
You may try upgrading to Payara 5.182. If that's not possible, you may find out what's causing the deployment problem by debugging your the server, putting an exception breakpoint on DeploymentException and check the message of the exception.
I could pin it down to the Payara version (docker image). It seems like that where is a bigger difference between:
sh-4.2$ ./asadmin version
Version = Payara Server 4.1.2.181 #badassfish (build 220)
Command version executed successfully.
Which works fine and:
sh-4.2$ ./asadmin version
Version = Payara Server 4.1.2.182.1 #badassfish (build 308)
Command version executed successfully.
Which causes the error above. I haven't looked into the details till now -- and just reverted the version of the Payara to 4.1.2.181 again.
Disclaimer: As it is a docker image it is possible, that the payara was modified and it has nothing todo with the payara itself. I haven't verified that, as mentioned above.
I have a custom exception like this
#ResponseStatus(HttpStatus.UNAUTHORIZED)
public class AccessException extends RuntimeException {
}
But when I throw it from a #RestController, it's logging this:
2018-04-17 11:44:58.239 WARN 17928 --- [nio-8080-exec-3] .w.s.m.a.ResponseStatusExceptionResolver : Resolved exception caused by Handler execution: site.user.AccessException
I tried checking the source code but could not find where this is getting logged. I don't want to turn off logging because it may log other things that I am interested in. I just don't think that a custom exception like this should be logged every time.
You may set log level for class org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver to ERROR. That way you will only loose WARN, DEBUG and TRACE logs for this class only.
If there are some WARN-level exceptions you want to see from this class I see two options:
copy org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver to your codebase, change the logging. Make sure that your copy is on the top of the classpath and Spring is below. This is kind of hack. ResponseStatusExceptionResolver is implementation detail of Spring. It may be changed/moved/deleted in future release.
write your own implementation of org.springframework.web.servlet.HandlerExceptionResolver, register it, make sure that ResponseStatusExceptionResolver is not registered.
In Spring you can add this line into your application.properties to specify logging level for certain class:
logging.level.site.user.AccessException=ERROR
or
logging.level.site.user.AccessException=OFF
in my Scenario, i try to use JCA Adapters to connect to an external storage - just to try this feature of J2EE.
I use JBoss EAP 7 and its packed implementation ironjacamar.
i deploy an adapter.rar, which contains an adapter.jar (this contains the Connection and ConnectionFactory Interfaces and all implementations) and META-INF/ironjacamar.xml.
I then deploy a app.war file, containing a Bean with an annotated field:
#RequestScoped
public class Bean {
...
#Resource(lookup = "java:/eis/StorageConnectionFactory")
private StorageConnectionFactory connectionFactory;
}
The war also contains the adapter.jar as library - as it needs to know of all the classes at runtime (NoClassDefFound etc.)
To my amazement, the Connector itself seems to work - as is get the Exception:
java.lang.IllegalArgumentException: Can not set conn.StorageConnectionFactoryImpl field Bean.connectionFactory to conn.HsmConnectionFactoryImp
and on ommitting the interfaces even:
#Resource(lookup = "java:/eis/StorageConnectionFactory")
private StorageConnectionFactoryImpl connectionFactory;
still
java.lang.IllegalArgumentException: Can not set conn.StorageConnectionFactoryImpl field Bean.connectionFactory to conn.HsmConnectionFactoryImp
I see that the Problem is, that the adapter.rar does nto share the same classloader as the app.war and both contain the corresponding classes, leading to a sort of ClassCastException - how do i solve this issue correctly?
It seems you haven't configure resource adapter properly.
See the below guide, it will help you to configure:
https://access.redhat.com/documentation/en/red-hat-jboss-enterprise-application-platform/version-7.0/configuration-guide/#configuring_jca_subsystem
We are facing a weird issue in production. Ours is a web application deployed in Tomcat 7. We are using Antisamy-1.5.3.jar for XSS prevention.Each user request is intercepted by a filter which scans the requests for any malicious content.
This setup was all fine in Tomcat 6 for more than a year. We migrated to Tomcat 7. Users get NoClassDefFoundError on and off when they open the app(not consistent) but when Tomcat is restarted it works fine.
Below is the flow where exception is thrown
User request is intercepted by AntiSamyFilter and scan method on owasp.validator.html.AntiSamy class(AntiSamy internal class) is called.
Below is the code for scan method
public CleanResults scan(String taintedHTML, Policy policy)
throws ScanException, PolicyException
{
return new AntiSamyDOMScanner(policy).scan(taintedHTML);
}
When AnitSamyDOMScanner class is referenced in the code above, static init block of super class of AntiSamyDOMScanner – AbstractAntiSamyScanner is called which is as below
private static ResourceBundle getResourceBundle() {
try {
return ResourceBundle.getBundle("AntiSamy", Locale.getDefault()); }
catch (MissingResourceException mre) {
}
return ResourceBundle.getBundle("AntiSamy", new Locale("en", "US"));
}
This is where the exception is thrown because, tomcat for some reason can’t load resource bundle – AntiSamy_en_US.properties file present inside the jar file at the root level.
Since this is error in static block, ExceptionInInitializer is thrown ultimately leading to NoClassDefFoundError.
Below are the two exception when looked at together – we can see that NoClassDefFoundError is caused due to exception in static init block of AbstractAntiSamyScanner.
SEVERE: Servlet.service() for servlet [jsp] in context with path [/app] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.owasp.validator.html.scan.AntiSamyDOMScanner] with root cause
java.lang.NoClassDefFoundError: Could not initialize class org.owasp.validator.html.scan.AntiSamyDOMScanner
at org.owasp.validator.html.AntiSamy.scan(AntiSamy.java:93)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:124)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
java.lang.NoClassDefFoundError: Could not initialize class org.owasp.validator.html.scan.AntiSamyDOMScanner StackTrace: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.owasp.validator.html.scan.AntiSamyDOMScanner at
WE have tried copying the Antisamy.properties under Tomcat lib and also WEB-INF/classes but it didnt work.
Any thoughts on what could cause the AbstractAntiSamyScanner not find the resource bundle within the jar?
I tried to deploy play framework 2.4 application on glassfish.
I used maven play2 plugin and made war file with the following instruction.
https://play2-maven-plugin.github.io/play2-maven-plugin/1.0.0-beta4/war-packaging.html
After that, I tried to deploy my war from glassfish console, but it returned the following error.
Error occurred during deployment: Exception while loading the app :
CDI deployment failure:Exception List with 3 exceptions:
Exception 0 : org.jboss.weld.exceptions.DeploymentException:
WELD-001408: Unsatisfied dependencies for type Environment with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public play.api.db.BoneConnectionPool(Environment)
at play.api.db.BoneConnectionPool.<init>(BoneConnectionPool.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:515)
at org.jboss.weld.bootst .... msg.seeServerLog
Error occurred during deployment: Exception while loading the app :
CDI deployment failure:
WELD-001408: Unsatisfied dependencies for type Database with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject public modules.MyBatisModule$PlayDataSourceProvider(Database)
at modules.MyBatisModule$PlayDataSourceProvider.<init>(PlayDataSourceProvider.java:0) .
Please see server.log for more details.
And MyBatisModule is like this.
public class MyBatisModule extends org.mybatis.guice.MyBatisModule {
#Override
protected void initialize() {
environmentId("development");
bindConstant().annotatedWith(Names.named("mybatis.configuration.failFast")).to(true);
bindDataSourceProviderType(PlayDataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
addMapperClasses();
}
#Singleton
public static class PlayDataSourceProvider implements Provider<DataSource> {
final Database db;
#Inject
public PlayDataSourceProvider(final Database db) {
this.db = db;
}
public DataSource get() {
return db.getDataSource();
}
}
I think the application can't read application.conf that containts DB setting. But I'm not sure.
Could you give me any advices?
Update 2015/01/13
I disabled "Implicit CDI" option on glassfish console when I deployed application.
I don't get the first error now, but I get another error...
Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.google.inject.CreationException:
Unable to create injector, see the following errors:
1) Error in custom provider, Configuration error: Configuration error
[Cannot connect to database [default]] while locating play.api.db.DBApiProvider while locating play.api.db.DBApi for parameter 0
at play.db.DefaultDBApi.<init>(DefaultDBApi.java:28)
at play.db.DefaultDBApi.class(DefaultDBApi.java:28) while locating play.db.DefaultDBApi while locating play.db.DBApi for field
at play.db.DBModule$NamedDatabaseProvider.dbApi(DBModule.java:61) while locating play.db.DBModule$NamedDatabaseProvider
at com.google.inject.util.Providers$GuicifiedProviderWithDependencies.initialize(Providers.java:149)
at play.db.DBModule.bindings(DBModule.java:40): Binding(interface play.db.Database qualified with QualifierInstanc .... msg.seeServerLog
My conf/application.conf is here:
db.default.driver=oracle.jdbc.driver.OracleDriver
db.default.url="jdbc:oracle:thin:#url..."
db.default.username=username
db.default.password=password
And it works on local environment.
I think glassfish can't read application.conf in war file.
I'm sorry. Could you give me the advice again?
Update 2015/01/14
The following is the part of full log.
Caused by: Configuration error: Configuration error[Exception during pool initialization]
at play.api.Configuration$.configError(Configuration.scala:178)
at play.api.PlayConfig.reportError(Configuration.scala:1048)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:69)
at play.api.db.PooledDatabase.createDataSource(Databases.scala:199)
at play.api.db.DefaultDatabase.dataSource$lzycompute(Databases.scala:124)
at play.api.db.DefaultDatabase.dataSource(Databases.scala:122)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:143)
at play.api.db.DefaultDatabase.getConnection(Databases.scala:139)
at play.api.db.DefaultDBApi$$anonfun$connect$1.apply(DefaultDBApi.scala:44)
... 130 more
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:542)
at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:171)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:60)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:48)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80)
at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:58)
at play.api.db.HikariCPConnectionPool$$anonfun$1.apply(HikariCPModule.scala:54)
at scala.util.Try$.apply(Try.scala:191)
at play.api.db.HikariCPConnectionPool.create(HikariCPModule.scala:54)
... 136 more
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:441)
at com.zaxxer.hikari.pool.BaseHikariPool.initializeConnections(BaseHikariPool.java:540)
... 144 more
3) Error in custom provider, java.lang.NullPointerException
at play.db.DBModule.bindings(DBModule.java:40):
Binding(interface play.db.Database qualified with QualifierInstance(#play.db.NamedDatabase(value=default)) to ProviderTarget(play.db.DBModule$NamedDatabaseProvider#34850279)) (vi
a modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
while locating play.db.Database annotated with #play.db.NamedDatabase(value=default)
Some thoughts (it should be comment, but I cannot write comments on SO yet).
If your application.conf file is inside WEB-INF/classes directory, it should be found (more info - https://www.playframework.com/documentation/2.4.x/ProductionConfiguration#Specifying-an-alternate-configuration-file).
Does war file contain JDBC driver?
Maybe you should configure JNDI - https://www.playframework.com/documentation/2.4.x/ScalaDatabaseOthers#Exposing-the-datasource-through-JNDI
My problem cause is that:
Caused by: java.sql.SQLException: JDBC4 Connection.isValid() method not supported, connection test query must be configured
https://www.playframework.com/documentation/2.4.x/Migration24#JDBC-connection-pool
After I add the following setting on application.conf, it works.
(This sql is for Oracle DB.)
db.default.hikaricp.connectionTestQuery="SELECT 1 FROM DUAL"
Thank you for your help!