Spring Security JaasAuthenticationProvider does not see Wildfly 10 securitydomain - spring-security

We are migrating our code from JBoss 4.2.1 AS and Spring Security 3.2.9 to JBoss Wildfly 10.0.0 and Spring Security 4.0.4
I'm having the following problem with my Spring Security JaasAuthenticationProvider integration with JBoss Wildfly 10 security domains defined in standalone.xml: it does not execute LoginModules defined in my security-domain, actually only thing it seems to find is ClientLoginModule defined in auth.conf of wildfly 10.0.0 picketbox-4.9.4.jar (which comes as default).
My security domain configuration is as follows:
<security-domain name="mysecdomain" cache-type="default">
<authentication>
<login-module code="LdapExtended" flag="sufficient">
<module-options.../>
</login-module>
</authentication>
</security-domain>
And my JaasAuthenticationProvider in my application context of the deployed application:
<bean id="jaasAuthenticationProvider" class=org.springframework.security.authentication.jaas.JaasAuthenticationProvider">
<property name="loginConfig" value="WEB-INF/login.conf" />
<property name="loginContextName" value="mysecdomain"/>
<property name="callbackHandlers">
<list>
<bean class="org.springframework.security.authentication.jaas.JaasNameCallbackHandler" />
<bean class="org.springframework.security.authentication.jaas.JaasPasswordCallbackHandler" />
</list>
</property>
<property name="authorityGranters">
<list>
<bean class="com.my.MyAuthorityGranter" />
</list>
</property>
</bean>
But when I execute defined jaasAuthenticationProvider, it outputs the following to Wildfly's server.log:
2016-04-27 03:37:18,367 TRACE [org.jboss.security] (default task-4) PBOX00221: Begin getAppConfigurationEntry(mysecdomain), size: 1
2016-04-27 03:37:18,368 TRACE [org.jboss.security] (default task-4) PBOX00222: getAppConfigurationEntry(mysecdomain), no entry found, trying parent config null
2016-04-27 03:37:18,368 TRACE [org.jboss.security] (default task-4) PBOX00223: getAppConfigurationEntry(mysecdomain), no entry in parent config, trying default other
2016-04-27 03:37:18,368 TRACE [org.jboss.security] (default task-4) PBOX00224: End getAppConfigurationEntry(mysecdomain), AuthInfo: AppConfigurationEntry[]:
[0]
LoginModule Class: org.jboss.security.ClientLoginModule
ControlFlag: LoginModuleControlFlag: required
Options:
2016-04-27 03:37:18,374 DEBUG [org.jboss.security] (default task-4) PBOX00350: Module option: jboss.security.security_domain, value: other
2016-04-27 03:37:18,374 DEBUG [org.jboss.security] (default task-4) PBOX00350: Module option: restore-login-identity, value: null
2016-04-27 03:37:18,374 DEBUG [org.jboss.security] (default task-4) PBOX00350: Module option: password-stacking, value: null
2016-04-27 03:37:18,376 TRACE [org.jboss.security] (default task-4) PBOX00240: Begin login method
2016-04-27 03:37:18,387 TRACE [org.jboss.security] (default task-4) PBOX00351: Obtained auth info from handler, principal: xxxxx, credential class: class [C
2016-04-27 03:37:18,388 TRACE [org.jboss.security] (default task-4) PBOX00241: End login method, isValid: true
2016-04-27 03:37:18,388 TRACE [org.jboss.security] (default task-4) PBOX00242: Begin commit method, overall result: true
So obviously, I'm doing something wrong but cannot figure out what? Above worked nicely in JBoss 4.2.1 and application-policies defined in login-config.xml, but not anymore

Found the solution: in new Spring Security (4.0.4 was version here) one needs to add following property to JaasConfigurationProvider, otherwise it will remove already uploaded configurations (security-domains) and replace them with picketbox default configuration:
<property name="refreshConfigurationOnStartup" value="false"/>
Now it works like charm and provider can see all defined security-domains

Related

log4j2 stops writing to file after few logs

I am working with log4j2. The logger initializes and creates output logfile. After writing few logs logger stops and does not write anything. The logger logs are as below:
`DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Converter' found 45 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger Starting LoggerContext[name=3bb8aabc, org.apache.logging.log4j.core.LoggerContext#73010765]...
DEBUG StatusLogger Reconfiguration started for context[name=3bb8aabc] at URI null (org.apache.logging.log4j.core.LoggerContext#73010765) with optional ClassLoader: null
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'ConfigurationFactory' found 4 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Missing dependencies for Yaml support, ConfigurationFactory org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory is inactive
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Missing dependencies for Json support, ConfigurationFactory org.apache.logging.log4j.core.config.json.JsonConfigurationFactory is inactive
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory#26b95b0b
WARN StatusLogger Error parsing URI C:\myApplication\config\logger-config.xml
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Closing FileInputStream java.io.FileInputStream#245ec1a6
DEBUG StatusLogger Apache Log4j Core 2.18.0 initializing configuration XmlConfiguration[location=C:\myApplication\config\logger-config.xml]
DEBUG StatusLogger PluginManager 'Core' found 130 plugins
DEBUG StatusLogger PluginManager 'Level' found 0 plugins
DEBUG StatusLogger PluginManager 'Lookup' found 16 plugins
DEBUG StatusLogger Building Plugin[name=layout, class=org.apache.logging.log4j.core.layout.PatternLayout].
TRACE StatusLogger TypeConverterRegistry initializing.
DEBUG StatusLogger PluginManager 'TypeConverter' found 26 plugins
DEBUG StatusLogger PatternLayout$Builder(pattern="[%d] [%t] [%-5p] [%l][%M] %m%n", PatternSelector=null, Configuration(C:\myApplication\config\logger-config.xml), Replace=null, charset="null", alwaysWriteExceptions="null", disableAnsi="null", noConsoleNoAnsi="null", header="null", footer="null")
DEBUG StatusLogger PluginManager 'Converter' found 45 plugins
DEBUG StatusLogger Building Plugin[name=TimeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy].
DEBUG StatusLogger TimeBasedTriggeringPolicy$Builder(interval="null", modulate="null", maxRandomDelay="null")
DEBUG StatusLogger Building Plugin[name=SizeBasedTriggeringPolicy, class=org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy].
DEBUG StatusLogger createPolicy(size="1000KB")
DEBUG StatusLogger Building Plugin[name=Policies, class=org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy].
DEBUG StatusLogger createPolicy(={TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1024000)})
DEBUG StatusLogger Building Plugin[name=DefaultRolloverStrategy, class=org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy].
DEBUG StatusLogger DefaultRolloverStrategy$Builder(max="5", min="null", fileIndex="null", compressionLevel="null", ={}, stopCustomActionsOnError="null", tempCompressedFilePattern="null", Configuration(C:\myApplication\config\logger-config.xml))
DEBUG StatusLogger Building Plugin[name=appender, class=org.apache.logging.log4j.core.appender.RollingFileAppender].
DEBUG StatusLogger RollingFileAppender$Builder(fileName="C:/logs/applicationLogs.log", filePattern="C:/logs_backup/${date:yyyy-MM}/applicationLogs-%d{MM-dd-yyyy}-%i.log.gz", append="null", locking="null", Policies(CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1024000)])), DefaultRolloverStrategy(DefaultRolloverStrategy(min=1, max=5, useMax=true)), advertise="null", advertiseUri="null", createOnDemand="null", filePermissions="null", fileOwner="null", fileGroup="null", bufferedIo="null", bufferSize="null", immediateFlush="null", ignoreExceptions="null", PatternLayout([%d] [%t] [%-5p] [%l][%M] %m%n), name="CASRollingfileAppender", Configuration(C:\myApplication\config\logger-config.xml), Filter=null, ={})
TRACE StatusLogger New file 'C:/logs/applicationLogs.log' created = true
DEBUG StatusLogger Returning file creation time for C:\logs\applicationLogs.log
DEBUG StatusLogger Starting RollingFileManager C:/logs/applicationLogs.log
DEBUG StatusLogger PluginManager 'FileConverter' found 2 plugins
DEBUG StatusLogger Setting prev file time to 2022-12-06T23:48:23.928-0800
DEBUG StatusLogger Initializing triggering policy CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false), SizeBasedTriggeringPolicy(size=1024000)])
DEBUG StatusLogger Initializing triggering policy TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=false)
TRACE StatusLogger PatternProcessor.getNextTime returning 2022/12/07-00:00:00.000, nextFileTime=2022/12/06-00:00:00.000, prevFileTime=1969/12/31-16:00:00.000, current=2022/12/06-23:48:23.959, freq=DAILY
TRACE StatusLogger PatternProcessor.getNextTime returning 2022/12/07-00:00:00.000, nextFileTime=2022/12/06-00:00:00.000, prevFileTime=2022/12/06-00:00:00.000, current=2022/12/06-23:48:23.959, freq=DAILY
DEBUG StatusLogger Initializing triggering policy SizeBasedTriggeringPolicy(size=1024000)
DEBUG StatusLogger Building Plugin[name=appenders, class=org.apache.logging.log4j.core.config.AppendersPlugin].
DEBUG StatusLogger createAppenders(={CASRollingfileAppender})
DEBUG StatusLogger Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
DEBUG StatusLogger createAppenderRef(ref="CASRollingfileAppender", level="null", Filter=null)
DEBUG StatusLogger Building Plugin[name=logger, class=org.apache.logging.log4j.core.config.LoggerConfig].
DEBUG StatusLogger LoggerConfig$Builder(additivity="false", level="DEBUG", levelAndRefs="null", name="com.test.myApplication.logging", includeLocation="null", ={CASRollingfileAppender}, ={}, Configuration(C:\myApplication\config\logger-config.xml), Filter=null)
DEBUG StatusLogger Building Plugin[name=AppenderRef, class=org.apache.logging.log4j.core.config.AppenderRef].
DEBUG StatusLogger createAppenderRef(ref="CASRollingfileAppender", level="null", Filter=null)
DEBUG StatusLogger Building Plugin[name=root, class=org.apache.logging.log4j.core.config.LoggerConfig$RootLogger].
DEBUG StatusLogger LoggerConfig$RootLogger$Builder(additivity="null", level="WARN", levelAndRefs="null", includeLocation="null", ={CASRollingfileAppender}, ={}, Configuration(C:\myApplication\config\logger-config.xml), Filter=null)
DEBUG StatusLogger Building Plugin[name=loggers, class=org.apache.logging.log4j.core.config.LoggersPlugin].
DEBUG StatusLogger createLoggers(={com.test.myApplication.logging, root})
DEBUG StatusLogger Configuration XmlConfiguration[location=C:\myApplication\config\logger-config.xml] initialized
DEBUG StatusLogger Starting configuration XmlConfiguration[location=C:\myApplication\config\logger-config.xml]
DEBUG StatusLogger Started configuration XmlConfiguration[location=C:\myApplication\config\logger-config.xml] OK.
TRACE StatusLogger Stopping org.apache.logging.log4j.core.config.DefaultConfiguration#608bc8f8...
TRACE StatusLogger DefaultConfiguration notified 1 ReliabilityStrategies that config will be stopped.
TRACE StatusLogger DefaultConfiguration stopping root LoggerConfig.
TRACE StatusLogger DefaultConfiguration notifying ReliabilityStrategies that appenders will be stopped.
TRACE StatusLogger DefaultConfiguration stopping remaining Appenders.
DEBUG StatusLogger Shutting down OutputStreamManager SYSTEM_OUT.false.false-1
DEBUG StatusLogger OutputStream closed
DEBUG StatusLogger Shut down OutputStreamManager SYSTEM_OUT.false.false-1, all resources released: true
DEBUG StatusLogger Appender DefaultConsole-1 stopped with status true
TRACE StatusLogger DefaultConfiguration stopped 1 remaining Appenders.
TRACE StatusLogger DefaultConfiguration cleaning Appenders from 1 LoggerConfigs.
DEBUG StatusLogger Stopped org.apache.logging.log4j.core.config.DefaultConfiguration#608bc8f8 OK
TRACE StatusLogger Reregistering MBeans after reconfigure. Selector=org.apache.logging.log4j.core.selector.ClassLoaderContextSelector#2a3194c6
TRACE StatusLogger Reregistering context (1/1): '3bb8aabc' org.apache.logging.log4j.core.LoggerContext#73010765
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=StatusLogger'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=ContextSelector'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=Loggers,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=Appenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=AsyncAppenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=AsyncLoggerRingBuffer'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=3bb8aabc,component=Loggers,name=*,subtype=RingBuffer'
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc,component=StatusLogger
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc,component=ContextSelector
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc,component=Loggers,name=
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc,component=Loggers,name=com.test.myApplication.logging
DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=3bb8aabc,component=Appenders,name=CASRollingfileAppender
TRACE StatusLogger Using default SystemClock for timestamps.
DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
TRACE StatusLogger Using DummyNanoClock for nanosecond timestamps.
DEBUG StatusLogger Reconfiguration complete for context[name=3bb8aabc] at URI C:\myApplication\config\logger-config.xml (org.apache.logging.log4j.core.LoggerContext#73010765) with optional ClassLoader: null
DEBUG StatusLogger Shutdown hook enabled. Registering a new one.
DEBUG StatusLogger LoggerContext[name=3bb8aabc, org.apache.logging.log4j.core.LoggerContext#73010765] started OK.
DEBUG StatusLogger AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
TRACE StatusLogger Using default SystemClock for timestamps.
DEBUG StatusLogger org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
and the logger config file as:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<RollingFile name="CASRollingfileAppender"
fileName="C:/logs/applicationLogs.log"
filePattern="C:/logs_backup/$${date:yyyy-MM}/applicationLogs-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout pattern="[%d] [%t] [%-5p] [%l][%M] %m%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="1000KB" />
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
</Appenders>
<Loggers>
<Logger
name="com.test.myApplication.logging"
level="DEBUG" additivity="false">
<AppenderRef ref="CASRollingfileAppender" />
</Logger>
<Root level="WARN">
<AppenderRef ref="CASRollingfileAppender" />
</Root>
</Loggers>
</Configuration>
Any suggestions on what is going wrong here?
In logs it shows a warning as:
WARN StatusLogger Error parsing URI C:\myApplication\config\logger-config.xml
However, I think the config file is working properly. Why does the logger stop writing after it writes a few logs?

Log4j2 Async logger

This is my log4j2.xml file (abbreviated, there are 4 more appenders and loggers, but all of them with exactly the same format):
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace" name="ventusproxy" packages="">
<Appenders>
<RollingFile name="ACCESS_LOG"
filePattern="${sys:log.dir}vproxy_access.%d{yyyy-MM-dd}"
append="true"
immediateFlush="false">
<PatternLayout>
<Pattern>%m%d{yyyy-MM-dd HH:mm:ss}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="off" additivity="false" />
<Logger name="LOGGER_ACCESS" level="info" includeLocation="true" additivity="false">
<AppenderRef ref="ACCESS_LOG"/>
</Logger>
</Loggers>
</Configuration>
We start tomcat with the option:
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
So we enable full async logging. That's why we are simply using Logger and Root instead of AsyncLogger and AsyncRoot.
When tomcat starts, we can see:
2018-08-07 21:03:56,535 localhost-startStop-1 TRACE Using default SystemClock for timestamps.
2018-08-07 21:03:56,536 localhost-startStop-1 TRACE Using DummyNanoClock for nanosecond timestamps.
2018-08-07 21:03:56,536 localhost-startStop-1 DEBUG Reconfiguration complete for context[name=AsyncContext#4d8d549e] at URI /home/ventusproxy/app/ROOT/WEB-INF/log4j.xml (org.apache.logging.log4j.core.async.AsyncLoggerContext#2c9ae56e) with optional ClassLoader: null
2018-08-07 21:03:56,536 localhost-startStop-1 DEBUG Shutdown hook enabled. Registering a new one.
2018-08-07 21:03:56,537 localhost-startStop-1 DEBUG LoggerContext[name=AsyncContext#4d8d549e, org.apache.logging.log4j.core.async.AsyncLoggerContext#2c9ae56e] started OK.
2018-08-07 21:03:56,538 localhost-startStop-1 TRACE Using default SystemClock for timestamps.
2018-08-07 21:03:56,539 localhost-startStop-1 DEBUG AsyncLogger.ThreadNameStrategy=CACHED
2018-08-07 21:03:56,556 Log4j2-TF-1-AsyncLogger[AsyncContext#4d8d549e]-1 DEBUG Now writing to /home/ventusproxy/logs/vproxy_system.2018-08-07 at 2018-08-07T21:03:56.556-0400
2018-08-07 21:03:57,081 localhost-startStop-1 DEBUG PluginManager 'Converter' found 42 plugins
2018-08-07 21:03:57,082 localhost-startStop-1 DEBUG Starting OutputStreamManager SYSTEM_OUT.false.false-2
2018-08-07 21:03:57,083 localhost-startStop-1 TRACE [DefaultAsyncContext#localhost-startStop-1] AsyncLoggerDisruptor creating new disruptor for this context.
2018-08-07 21:03:57,083 localhost-startStop-1 TRACE property AsyncLogger.WaitStrategy=TIMEOUT
2018-08-07 21:03:57,092 localhost-startStop-1 DEBUG [DefaultAsyncContext#localhost-startStop-1] Starting AsyncLogger disruptor for this context with ringbufferSize=262144, waitStrategy=TimeoutBlockingWaitStrategy, exceptionHandler=org.apache.logging.log4j.core.async.AsyncLoggerDefaultExceptionHandler#71fd86cb...
2018-08-07 21:03:57,093 localhost-startStop-1 TRACE [DefaultAsyncContext#localhost-startStop-1] AsyncLoggers use a threadlocal translator
2018-08-07 21:03:57,093 localhost-startStop-1 DEBUG Starting LoggerContext[name=DefaultAsyncContext#localhost-startStop-1, org.apache.logging.log4j.core.async.AsyncLoggerContext#77ae266d]...
2018-08-07 21:03:57,094 localhost-startStop-1 DEBUG Reconfiguration started for context[name=DefaultAsyncContext#localhost-startStop-1] at URI null (org.apache.logging.log4j.core.async.AsyncLoggerContext#77ae266d) with optional ClassLoader: null
2018-08-07 21:03:57,094 localhost-startStop-1 DEBUG Using configurationFactory org.apache.logging.log4j.core.config.ConfigurationFactory$Factory#4b6e6fdf
2018-08-07 21:03:57,133 localhost-startStop-1 DEBUG Initializing configuration XmlConfiguration[location=/home/ventusproxy/app/ROOT/WEB-INF/log4j.xml]
And finally (last debug line):
2018-08-07 21:03:57,200 localhost-startStop-1 DEBUG LoggerContext[name=DefaultAsyncContext#localhost-startStop-1, org.apache.logging.log4j.core.async.AsyncLoggerContext#77ae266d] started OK.
But when we perform a thread dump with JStack, instead of seeing one thread we see 2 threads:
"Log4j2-TF-7-AsyncLogger[DefaultAsyncContext#localhost-startStop-1]-2" #23 daemon prio=5 os_prio=0 tid=0x00007f1ee8ad9800 nid=0x625d runnable [0x00007f1f05817000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000925d3ad8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at com.lmax.disruptor.TimeoutBlockingWaitStrategy.waitFor(TimeoutBlockingWaitStrategy.java:38)
at com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:56)
at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:124)
at java.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- None
"Log4j2-TF-1-AsyncLogger[AsyncContext#4d8d549e]-1" #21 daemon prio=5 os_prio=0 tid=0x00007f1ee88d8800 nid=0x625c runnable [0x00007f1f06073000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000093099540> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at com.lmax.disruptor.TimeoutBlockingWaitStrategy.waitFor(TimeoutBlockingWaitStrategy.java:38)
at com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:56)
at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:124)
at java.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- None
And when we stop tomcat, all these errors are logged:
07-Aug-2018 21:07:29.991 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Log4j2-TF-7-AsyncLogger[DefaultAsyncContext#localhost-startStop-1]-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
com.lmax.disruptor.TimeoutBlockingWaitStrategy.waitFor(TimeoutBlockingWaitStrategy.java:38)
com.lmax.disruptor.ProcessingSequenceBarrier.waitFor(ProcessingSequenceBarrier.java:56)
com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:124)
java.lang.Thread.run(Thread.java:748)
07-Aug-2018 21:07:29.993 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#494a6bc6]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#46d89786]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.993 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#494a6bc6]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#7fca5b63]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.994 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#7d2c87bb]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#316c8d06]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.994 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#74afa5d5]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#5913f960]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.994 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#401baca6]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#154a0d1e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.995 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#1cc2936f]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#5a5ca16e]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
07-Aug-2018 21:07:29.995 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#473f581f]) and a value of type [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator] (value [org.apache.logging.log4j.core.async.RingBufferLogEventTranslator#2d89f1b]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
So just 3 questions because now I'm not sure if I'm using asynchronous logging here:
With these traces can I confirm I'm using full asynchronous logging?
I've read that async logging starts just one thread, but here I see 2 (like when we mix sync and async logging). Is this true?
How can I remove these errors from the catalina.out? The application stops correctly so these messages are not really a problem, but I'd prefer to remove them if it's possible.

Error occurred running Grails CLI: Unknown Host (504)

I got an error Unknown Host (504) when I tried to start grails 3.3.2, and the details shows below:
$ grails --stacktrace --verbose
| Error Error occurred running Grails CLI: Unknown Host (504)
org.apache.http.client.HttpResponseException: Unknown Host (504)
at org.eclipse.aether.transport.http.HttpTransporter.handleStatus(HttpTransporter.java:466)
at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:291)
at org.eclipse.aether.transport.http.HttpTransporter.implPeek(HttpTransporter.java:231)
at org.eclipse.aether.spi.connector.transport.AbstractTransporter.peek(AbstractTransporter.java:43)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PeekTaskRunner.runTask(BasicRepositoryConnector.java:376)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:320)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:341)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:319)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:301)
at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:293)
at org.grails.cli.boot.GrailsDependencyVersions.<init>(GrailsDependencyVersions.groovy:53)
at org.grails.cli.boot.GrailsDependencyVersions.<init>(GrailsDependencyVersions.groovy:49)
at org.grails.cli.profile.repository.MavenProfileRepository.<init>(MavenProfileRepository.groovy:53)
at org.grails.cli.GrailsCli.createMavenProfileRepository(GrailsCli.groovy:334)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:235)
at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
| Error Error occurred running Grails CLI: Unknown Host (504)
Here is my version info:
$ grails -v
| Grails Version: 3.3.2
| Groovy Version: 2.4.13
| JVM Version: 1.8.0_121
Extra info: I am running it on Mac behind a proxy network. I've added the following statement into my bin/grails (/Users/foouser/.sdkman/candidates/grails/current/bin/grails) script:
export GRAILS_OPTS="-Dhttp.proxyHost=myHttpProxy -Dhttp.proxyPort=8000 -Dhttps.proxyHost=myHttpsProxy -Dhttps.proxyPort=443"
After few trials and errors, I found this org.eclipse.aether.internal.impl.DefaultRepositorySystem is actually trying to read and parse my $HOME/.m2/settings.xml. And below it was my original settings.xml:
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<proxies>
<proxy>
<id>proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>myHttpProxy</host>
<port>8000</port>
</proxy>
<proxy>
<id>httpsproxy</id>
<active>true</active>
<protocol>https</protocol>
<host>myHttpProxy</host>
<port>443</port>
</proxy>
</proxies>
<servers>
<server>
<username>myname</username>
<password>mypassword</password>
<id>Artifactory</id>
</server>
</servers>
<mirrors>
<mirror>
<id>Artifactory</id>
<!-- Drive all repositories through the Artifactory mirror -->
<mirrorOf>*</mirrorOf>
<url>http://myartifactoryurl</url>
</mirror>
</mirrors>
</settings>
Unfortunately, it wasn't parsed well...
The current workaround (a bad one though) I have is to change this settings.xml to the default one from maven, which has nothing setup there.

Spring Webflow: Error Rendering view java.lang.UnsupportedOperationException at javax.faces.context.ExternalContext.getClientWindow

I'm using mojarra 2.2, gf4, swf 2.3.2.
The problem comes during loading of the pages in webflow. the error comes when webflow (i think) is sending the pages to faces for rendering. I have tried with swf2.0.8 upto the current swf2.3.2.
INFO: 2013-07-12 09:46:09 DEBUG RequestLoggingPhaseListener:42 - Entering JSF Phase: RENDER_RESPONSE 6
INFO: 2013-07-12 09:46:09 DEBUG RequestLoggingPhaseListener:42 - Entering JSF Phase: RENDER_RESPONSE 6
SEVERE: Error Rendering View[/WEB-INF/pages/index/index.xhtml]
java.lang.UnsupportedOperationException
at javax.faces.context.ExternalContext.getClientWindow(ExternalContext.java:1500)
at com.sun.faces.context.ExternalContextImpl.encodeActionURL(ExternalContextImpl.java:562)
at org.springframework.faces.webflow.ExternalContextWrapper.encodeActionURL(ExternalContextWrapper.java:29)
at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:234)
at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:134)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:869)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:443)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80)
at org.springframework.faces.webflow.JsfView.render(JsfView.java:89)
at org.springframework.webflow.engine.ViewState.render(ViewState.java:296)
at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:221)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:724)
INFO: 2013-07-12 09:46:09 DEBUG JsfView:98 - View rendering complete
on the flow for a page i have
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd"
parent="parent-views">
<view-state id="index" view="index.xhtml"/>
the webflow configuration is
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/faces
http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">
<bean class="org.springframework.webflow.scope.ScopeRegistrar"/>
<!-- Spring Webflow central configuration component -->
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
<webflow:flow-execution-listeners>
<webflow:listener ref="facesContextListener"/>
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- Installs a listener that creates and releases the FacesContext for each request. -->
<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" base-path="/WEB-INF/pages" >
<webflow:flow-location-pattern value="/**/*-views.xml" />
</webflow:flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator"/>
<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry"/>
<property name="order" value="1"/>
</bean>
which i borrowed from somewhere
whenever i try to open the page i get this error
I have the same problem on Tomcat 6. The current stable releases of Spring WebFlow does not implement the JSF 2.2 API correctly. Thats why the invoke of javax.faces.context.ExternalContext.getClientWindow(...) fails. The source of the problem seems to be the clientWindowId feature.
The only solution for this is to update your Spring Webflow libraries to 2.4 SNAPSHOT. I grabbed the library files from http://maven.springframework.org/snapshot/org/springframework/webflow . My Spring Framework is the latest stable release.
A note for Tomcat users. Spring Webflow 2.4 requires some Java EE features now. You need to have an implementation for the CDI specification in your project. The Weld library suits very well to implement this specification on servers that aren't Java EE compatible (see http://www.seamframework.org/Weld for more information).
This is a bug in SWF 2.3.2: it doesn't support JSF 2.2
Here's the bug report: https://jira.spring.io/browse/SWF-1613
Starting from 2.3.3 it is fixed.

Java EE 6 embedded glassfish embedded derby EJB unit test

questing is about javaee6 with embedded glassfish and embedded derby jndi lookup for data source at the time of deployment before unit test is executed....
Please find the persistence.xml here...
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="mymodulePU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:C:/myappDB;create=true" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.file" value="./target/eclipselink.logs" />
</properties>
</persistence-unit>
</persistence>
Please find the server console log here when the unit test is executed....
Jan 24, 2011 5:12:44 PM com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator createResource
WARNING: poolmgr.create_resource_error
Jan 24, 2011 5:12:44 PM com.sun.enterprise.connectors.ConnectionManagerImpl internalGetConnection
WARNING: poolmgr.get_connection_failure
Jan 24, 2011 5:12:44 PM com.sun.gjc.spi.base.DataSource getConnection
WARNING: jdbc.exc_get_conn
Jan 24, 2011 5:12:44 PM org.eclipse.persistence.session.file:/C:/DD/WORKSPACES/lean-soa-arch/entities/target/classes/_mymodulePU.ejb
SEVERE:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
......
.......
......
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.
at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:112)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126)
... 44 more
Jan 24, 2011 5:12:44 PM org.eclipse.persistence.session.file:/C:/DD/WORKSPACES/lean-soa-arch/entities/target/classes/_mymodulePU.properties
FINEST: End deploying Persistence Unit mymodulePU; session file:/C:/DD/WORKSPACES/lean-soa-arch/entities/target/classes/_mymodulePU; state Deployed; factoryCount 1
#Bryan He's not trying to run Derby in network server mode, he wants to run it in embedded mode so I don't think your suggestion will help in that case.
The problem he is seeing is because he has a JTA datasource called jdbc/_default defined in his persistence.xml. When embedded glassfish sees this it tries to look it up in its JNDI context and when it does it finds the jdbc/_default resource which is defined in the domain.xml it is using. This by default is a network based Derby resource as defined in the domain.xml.
What Digambar needs to do is to start GF and create a new connection pool which uses embedded derby and create a new jdbc resource which uses that pool for the domain.
I used the glassfish web admin console but you can also use the asadmin command if you know all the command line switches for the various parameters. Either way your domain.xml will then have the new resources. Once you do that simply change your persistence.xml so that the jta-datasource references this new jdbc resource and you should be all set. You can also remove the two javax.persistence properties from your persistence.xml because they are not needed at this point (those settings set when you configure the new connection pool resource).
Make sure to set ;create=true to the ConnectionAttributes property when you configure your embedded connection pool.
After creating the connection pool and jdbc resources my domain.xml had the following. Yours may look slightly different based on the settings you need for your specific application.
<jdbc-connection-pool connection-validation-method="auto-commit" validation-table-name="SYS.SYSALIASES" allow-non-component-callers="true" connection-leak-reclaim="true" lazy-connection-association="true" connection-creation-retry-attempts="90" lazy-connection-enlistment="true" validate-atmost-once-period-in-seconds="120" driver-classname="" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource40" res-type="javax.sql.DataSource" connection-leak-timeout-in-seconds="60" description="" name="GFEmbeddedPool" is-connection-validation-required="true">
<property name="DatabaseName" value="C:\tmp\db\unit-test"></property>
<property name="ConnectionAttributes" value=";create=true"></property>
<property name="AttributesAsPassword" value="false"></property>
<property name="LoginTimeout" value="0"></property>
</jdbc-connection-pool>
<jdbc-resource pool-name="GFEmbeddedPool" description="" jndi-name="jdbc/__embeddedGF"></jdbc-resource>
The message "java.net.ConnectException : Error connecting to server localhost on port 1527" means that the Derby network server is not up and running. You need to start the Derby network server in order to connect to it. Here's how to start the server: http://db.apache.org/derby/docs/10.6/adminguide/tadmincbdjhhfd.html

Resources