junit5 throws an unwanted exception - mockito

I am about to write unit testcase with junit5 for my spring integration project. But when i am running a sample testcase, i am getting an exception. the below given code is my sample testcase,
#SpringBootTest
class IntegrationUtilsTest {
#Test
#DisplayName("sample test")
void sample() {
Assert.assertTrue(true);
}
}
and I am getting the following log while running this test,
2020-12-08 18:06:45.780 DEBUG --- [ main] com.tngtech.archunit.ArchConfiguration : No configuration found in classpath at archunit.properties => Using default configuration
██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗
██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝
██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║
╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗
╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝
:: JHipster 🤓 :: Running Spring Boot 2.2.7.RELEASE ::
:: https://www.jhipster.tech ::
2020-12-08 18:06:46.950 INFO 5036 --- [ main] c.m.a.i.service.IntegrationUtilsTest : No active profile set, falling back to default profiles: default
2020-12-08 18:06:50.330 DEBUG 5036 --- [ main] i.m.c.u.i.logging.InternalLoggerFactory : Using SLF4J as the default logging framework
2020-12-08 18:06:51.722 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:51.727 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:51.732 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:53.314 WARN 5036 --- [ main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
2020-12-08 18:06:53.685 INFO 5036 --- [ main] c.m.a.i.service.IntegrationUtilsTest : Started IntegrationUtilsTest in 7.545 seconds (JVM running for 8.789)
2020-12-08 18:06:53.710 DEBUG 5036 --- [ main] reactor.util.Loggers$LoggerFactory : Using Slf4j logging framework
2020-12-08 18:06:53.712 DEBUG 5036 --- [ main] reactor.core.publisher.Hooks : Hooking onLastOperator: org.springframework.security.core.context.SecurityContext
2020-12-08 18:06:53.758 DEBUG 5036 --- [ main] reactor.core.publisher.Hooks : Reset onLastOperator: org.springframework.security.core.context.SecurityContext
2020-12-08 18:06:54.118 WARN 5036 --- [extShutdownHook] i.m.c.i.d.DropwizardMeterRegistry : Failed to apply the value function for the gauge 'spring.integration.channels'. Note that subsequent logs will be logged at debug level.
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'nullChannel': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:623)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:611)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1242)
at org.springframework.integration.config.IntegrationManagementConfigurer.lambda$registerComponentGauges$1(IntegrationManagementConfigurer.java:444)
at io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry.lambda$newGauge$0(DropwizardMeterRegistry.java:87)
at com.codahale.metrics.Slf4jReporter.logGauge(Slf4jReporter.java:342)
at com.codahale.metrics.Slf4jReporter.report(Slf4jReporter.java:258)
at com.codahale.metrics.ScheduledReporter.report(ScheduledReporter.java:253)
at com.codahale.metrics.ScheduledReporter.stop(ScheduledReporter.java:200)
at com.codahale.metrics.ScheduledReporter.close(ScheduledReporter.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:339)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:273)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:579)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:551)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1091)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1084)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1060)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1029)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:948)
Can anyone help me understand this. why this BeanCreationNotAllowedException ?
UPDATE 1
I added the class and created the spring.factories file. But I am not able to start the application. I am getting the following error.
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method metricsWebMvcConfigurer in org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration required a single bean, but 2 were found:
- prometheusMeterRegistry: defined by method 'prometheusMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]
- consoleLoggingRegistry: defined by method 'consoleLoggingRegistry' in class path resource [io/github/jhipster/config/metric/JHipsterLoggingMetricsExportConfiguration.class]
Action:
Consider marking one of the beans as #Primary, updating the consumer to accept multiple beans, or using #Qualifier to identify the bean that should be consumed.
Which bean i should use and how to make it qualified for autowiring?

The fix for this problem is going to be available in the upcoming (December 10th) Spring Boot 2.2.12: https://github.com/spring-projects/spring-boot/pull/24095. That Jhipster has to be upgraded respectively.
If you are not interested in metrics, you may have your own NoopMeterRegistry bean for that test configuration.
As a workaround trick you can use the code from the relevant PR:
#AutoConfigureAfter({ MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
#AutoConfigureBefore(IntegrationAutoConfiguration.class)
#Configuration(proxyBeanMethods = false)
public class IntegrationMetricsAutoConfiguration {
}
and a spring.factories entry for this class against org.springframework.boot.autoconfigure.EnableAutoConfiguration key.
UPDATE
According the error you show about two MeterRegistry beans, it looks like we need to add similar workaround for that JHipsterLoggingMetricsExportConfiguration since it is auto-configured unconditionally and out of order:
#AutoConfigureAfter(JHipsterLoggingMetricsExportConfiguration.class)
#AutoConfigureBefore(CompositeMeterRegistryAutoConfiguration.class)
#Configuration
public class JHipsterLoggingMetricsFixerAutoConfiguration {
}
And add this class as an entry to the same mentioned spring.factories file.

Related

Spring Integration Bridge with poller not working as expected for JMS

Using spring-integration 5.0.7 to throttle the bridging of msgs between two JMS queues.
The docs at: https://docs.spring.io/spring-integration/docs/5.0.7.RELEASE/reference/html/messaging-channels-section.html#bridge-namespace
suggest:
<int:bridge input-channel="pollable" output-channel="subscribable">
<int:poller max-messages-per-poll="10" fixed-rate="5000"/>
</int:bridge>
But schema validator complains "no nested poller allowed for subscribable input channel" on bridge elt.
But, if I put the poller on the input-channel-adapter as in:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:int="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
">
<int:channel id="inChannel" />
<int:channel id="outChannel" />
<int-jms:inbound-channel-adapter id="jmsIn" connection-factory="jmsConnectionFactory" destination-name="_dev.inQueue" channel="inChannel">
<int:poller fixed-delay="5000" max-messages-per-poll="2"/>
</int-jms:inbound-channel-adapter>
<int-jms:outbound-channel-adapter id="jmsOut" connection-factory="jmsConnectionFactory" destination-name="_dev.outQueue" channel="outChannel"/>
<int:bridge input-channel="inChannel" output-channel="outChannel">
</int:bridge>
</beans:beans>
Nothing is ever moved from input to output.
How can I bridge from one JMS queue to another with a rate-limit?
Update:
Turning on logging confirms nothing getting picked up from input channel but otherwise not helpful:
018-08-10 15:36:33.345 DEBUG 112066 --- [ask-scheduler-1] o.s.i.e.SourcePollingChannelAdapter : Received no Message during the poll, returning 'false'
2018-08-10 15:36:38.113 DEBUG 112066 --- [ask-scheduler-2] o.s.integration.jms.DynamicJmsTemplate : Executing callback on JMS Session: ActiveMQSession {id=ID:whitechapel-35247-1533940593148-3:2:1,started=true} java.lang.Object#5c278302
2018-08-10 15:36:38.116 DEBUG 112066 --- [ask-scheduler-2] o.s.i.e.SourcePollingChannelAdapter : Received no Message during the poll, returning 'false'
2018-08-10 15:36:43.115 DEBUG 112066 --- [ask-scheduler-1] o.s.integration.jms.DynamicJmsTemplate : Executing callback on JMS Session: ActiveMQSession {id=ID:whitechapel-35247-1533940593148-3:3:1,started=true} java.lang.Object#1c09a81e
2018-08-10 15:36:43.118 DEBUG 112066 --- [ask-scheduler-1] o.s.i.e.SourcePollingChannelAdapter : Received no Message during the poll, returning 'false'
Here is a Spring Boot app, using Java DSL configuration which is the exact equivalent of what you have in XML (minus the bridge); it works fine.
#SpringBootApplication
public class So51792909Application {
private static final Logger logger = LoggerFactory.getLogger(So51792909Application.class);
public static void main(String[] args) {
SpringApplication.run(So51792909Application.class, args);
}
#Bean
public ApplicationRunner runner(JmsTemplate template) {
return args -> {
for (int i = 0; i < 10; i++) {
template.convertAndSend("foo", "test");
}
};
}
#Bean
public IntegrationFlow flow(ConnectionFactory connectionFactory) {
return IntegrationFlows.from(Jms.inboundAdapter(connectionFactory)
.destination("foo"), e -> e
.poller(Pollers
.fixedDelay(5000)
.maxMessagesPerPoll(2)))
.handle(Jms.outboundAdapter(connectionFactory)
.destination("bar"))
.get();
}
#JmsListener(destination = "bar")
public void listen(String in) {
logger.info(in);
}
}
and
2018-08-10 19:38:52.534 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:38:52.543 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:38:57.566 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:38:57.582 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:02.608 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:02.622 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:07.640 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:07.653 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:12.672 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
2018-08-10 19:39:12.687 INFO 13408 --- [enerContainer-1] com.example.So51792909Application : test
As you can see, the consumer gets 2 messages every 5 seconds.
Your debug log implies there are no messages in the queue.
EDIT
I figured it out; the XML parser sets the JmsTemplate receiveTimeout to nowait (-1). Since you are not using a caching connection factory, we'll never get a message because the ActiveMQ client returns immediately if there's not already a message present in the client (see this answer). Since there's no caching going on, we get a new consumer on every poll (and do a no-wait receive each time).
The DSL leaves the JmsTemplate's default (Infinite wait - which is actually wrong since it blocks the poller thread indefinitely if there are no messages).
To fix the XML version, adding receive-timeout="1000" fixes it.
However, it's better to use a CachingConnectionFactory to avoid creating a new connection/session/consumer on each poll.
Unfortunately, configurating a CachingConnectionFactory turns off Spring Boot's auto-configuration. This is fixed in Boot 2.1.
I have opened an issue to resolve the inconsistency between the DSL and XML here.
If you stick with the DSL, I would recommend setting the receive timeout to something reasonable, rather than indefinite:
#Bean
public IntegrationFlow flow(ConnectionFactory connectionFactory) {
return IntegrationFlows.from(Jms.inboundAdapter(connectionFactory)
.configureJmsTemplate(t -> t.receiveTimeout(1000))
.destination("foo"), e -> e
.poller(Pollers
.fixedDelay(5000)
.maxMessagesPerPoll(2)))
.handle(Jms.outboundAdapter(connectionFactory)
.destination("bar"))
.get();
}
But, the best solution is to use a CachingConnectionFactory.

Can not start jhispster sample application

I'm new in jhipster, I cloned the sample generated Angular 4 application :
https://github.com/jhipster/jhipster-sample-app-ng2.git
I run the project with eclipse, but the application is not working in the browser !!!
I did't make any change in the source, this is my console :
The Class-Path manifest attribute in C:\Users\HATIME\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar referenced one or more files that do not exist: C:\Users\HATIME\.m2\repository\org\liquibase\liquibase-core\3.5.3\lib\snakeyaml-1.13.jar
20:25:21.854 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
20:25:21.860 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
20:25:21.861 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/D:/Work/workspace/jhipster-sample-app-ng2/target/classes/]
██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗
██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝
██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║
╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗
╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝
:: JHipster 🤓 :: Running Spring Boot 1.5.7.RELEASE ::
:: http://www.jhipster.tech ::
2017-10-26 20:25:25.190 INFO 4916 --- [ restartedMain] i.g.j.s.JhipsterSampleApplicationNg2App : Starting JhipsterSampleApplicationNg2App on HATIME-PC with PID 4916 (D:\Work\workspace\jhipster-sample-app-ng2\target\classes started by HATIME in D:\Work\workspace\jhipster-sample-app-ng2)
2017-10-26 20:25:25.192 DEBUG 4916 --- [ restartedMain] i.g.j.s.JhipsterSampleApplicationNg2App : Running with Spring Boot v1.5.7.RELEASE, Spring v4.3.11.RELEASE
2017-10-26 20:25:25.193 INFO 4916 --- [ restartedMain] i.g.j.s.JhipsterSampleApplicationNg2App : The following profiles are active: swagger,dev
2017-10-26 20:25:25.620 DEBUG 4916 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2017-10-26 20:25:31.188 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.AsyncConfiguration : Creating Async Task Executor
2017-10-26 20:25:32.757 DEBUG 4916 --- [ restartedMain] class org.ehcache.core.Ehcache-users : Initialize successful.
2017-10-26 20:25:32.792 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.jhipster.sample.domain.User : Initialize successful.
2017-10-26 20:25:32.800 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.sample.domain.Authority : Initialize successful.
2017-10-26 20:25:32.805 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.s.domain.User.authorities : Initialize successful.
2017-10-26 20:25:32.811 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.sample.domain.BankAccount : Initialize successful.
2017-10-26 20:25:32.816 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.s.d.BankAccount.operations : Initialize successful.
2017-10-26 20:25:32.822 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.jhipster.sample.domain.Label : Initialize successful.
2017-10-26 20:25:32.831 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.s.domain.Label.operations : Initialize successful.
2017-10-26 20:25:32.836 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.sample.domain.Operation : Initialize successful.
2017-10-26 20:25:32.844 DEBUG 4916 --- [ restartedMain] c.e.c.E.g.j.s.domain.Operation.labels : Initialize successful.
2017-10-26 20:25:33.326 DEBUG 4916 --- [ restartedMain] i.g.j.s.config.MetricsConfiguration : Registering JVM gauges
2017-10-26 20:25:33.360 DEBUG 4916 --- [ restartedMain] i.g.j.s.config.MetricsConfiguration : Monitoring the datasource
2017-10-26 20:25:33.361 DEBUG 4916 --- [ restartedMain] i.g.j.s.config.MetricsConfiguration : Initializing Metrics JMX reporting
2017-10-26 20:25:35.101 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Registering CORS filter
2017-10-26 20:25:35.421 INFO 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Web application configuration, using profiles: swagger
2017-10-26 20:25:35.422 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Initializing Metrics registries
2017-10-26 20:25:35.428 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Registering Metrics Filter
2017-10-26 20:25:35.429 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Registering Metrics Servlet
2017-10-26 20:25:35.435 DEBUG 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Initialize H2 console
2017-10-26 20:25:35.436 INFO 4916 --- [ restartedMain] i.g.j.sample.config.WebConfigurer : Web application fully configured
2017-10-26 20:25:36.046 DEBUG 4916 --- [ restartedMain] i.g.j.s.config.DatabaseConfiguration : Configuring Liquibase
2017-10-26 20:25:36.071 WARN 4916 --- [ng-2-Executor-1] i.g.j.c.liquibase.AsyncSpringLiquibase : Starting Liquibase asynchronously, your database might not be ready at startup!
2017-10-26 20:25:38.669 DEBUG 4916 --- [ng-2-Executor-1] i.g.j.c.liquibase.AsyncSpringLiquibase : Liquibase has updated your database in 2596 ms
2017-10-26 20:25:51.678 DEBUG 4916 --- [ restartedMain] i.g.j.c.apidoc.SwaggerConfiguration : Starting Swagger
2017-10-26 20:25:51.690 DEBUG 4916 --- [ restartedMain] i.g.j.c.apidoc.SwaggerConfiguration : Started Swagger in 12 ms
2017-10-26 20:25:54.999 INFO 4916 --- [ restartedMain] i.g.j.s.JhipsterSampleApplicationNg2App : Started JhipsterSampleApplicationNg2App in 33.101 seconds (JVM running for 34.175)
2017-10-26 20:25:55.000 INFO 4916 --- [ restartedMain] i.g.j.s.JhipsterSampleApplicationNg2App :
----------------------------------------------------------
Application 'jhipsterSampleApplicationNG2' is running! Access URLs:
Local: http://localhost:8080
External: http://*.*.*.*:8080
Profile(s): [swagger, dev]
----------------------------------------------------------
Did you launch yarn install to get the node_modules folder, and compile the front ?
Try:
yarn install
yarn run webpack:build
yarn start

Jhipster-registry stop working

My jhipster-registry stopped working a couple of hours ago.
I followd these steps:
removed node_modules/ folder
npm install
./mvnw
When the registry is up and running again I get an error page with the following text:
??error.title_en??
And in the logs find:
2017-08-04 22:58:53.729 DEBUG 3203 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗
██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝
██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║
╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗
╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝
:: JHipster Registry :: Running Spring Boot 1.5.4.RELEASE ::
:: http://jhipster.github.io ::
2017-08-04 22:58:56.117 INFO 3203 --- [ restartedMain] i.g.j.registry.JHipsterRegistryApp : The following profiles are active: dev,native
2017-08-04 22:58:59.313 DEBUG 3203 --- [ restartedMain] i.g.j.r.config.AsyncConfiguration : Creating Async Task Executor
2017-08-04 22:58:59.994 DEBUG 3203 --- [ restartedMain] i.g.j.r.config.MetricsConfiguration : Registering JVM gauges
2017-08-04 22:59:00.274 DEBUG 3203 --- [ restartedMain] i.g.j.r.config.MetricsConfiguration : Initializing Metrics JMX reporting
2017-08-04 22:59:03.135 DEBUG 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Registering CORS filter
2017-08-04 22:59:03.327 WARN 3203 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2017-08-04 22:59:04.102 INFO 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Web application configuration, using profiles: dev
2017-08-04 22:59:04.103 DEBUG 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Initializing Metrics registries
2017-08-04 22:59:04.107 DEBUG 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Registering Metrics Filter
2017-08-04 22:59:04.107 DEBUG 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Registering Metrics Servlet
2017-08-04 22:59:04.113 INFO 3203 --- [ restartedMain] i.g.j.registry.config.WebConfigurer : Web application fully configured
2017-08-04 22:59:12.109 WARN 3203 --- [ restartedMain] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2017-08-04 22:59:12.551 INFO 3203 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2017-08-04 22:59:12.551 INFO 3203 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2017-08-04 22:59:12.571 INFO 3203 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1501880352571 with initial instances count: 0
2017-08-04 22:59:12.941 INFO 3203 --- [ restartedMain] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2017-08-04 22:59:12.941 INFO 3203 --- [ restartedMain] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2017-08-04 22:59:12.942 INFO 3203 --- [ restartedMain] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2017-08-04 22:59:12.942 INFO 3203 --- [ restartedMain] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2017-08-04 22:59:13.809 WARN 3203 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Bean with key 'zuulEndpoint' has been registered as an MBean but has no exposed attributes or operations
2017-08-04 22:59:14.606 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-08-04 22:59:14.614 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with result = null
2017-08-04 22:59:14.740 INFO 3203 --- [ restartedMain] i.g.j.registry.JHipsterRegistryApp : Started JHipsterRegistryApp in 22.799 seconds (JVM running for 23.886)
2017-08-04 22:59:14.741 INFO 3203 --- [ restartedMain] i.g.j.registry.JHipsterRegistryApp :
----------------------------------------------------------
Application 'jhipster-registry' is running! Access URLs:
Local: http://localhost:8761
External: http://xxx.xxx.x.xxx:8761
Profile(s): [dev, native]
----------------------------------------------------------
2017-08-04 22:59:19.615 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-08-04 22:59:19.616 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with result = null
2017-08-04 22:59:24.621 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-08-04 22:59:24.622 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with result = null
2017-08-04 22:59:27.234 WARN 3203 --- [ XNIO-2 task-1] o.s.c.n.zuul.web.ZuulHandlerMapping : No routes found from RouteLocator
2017-08-04 22:59:27.438 DEBUG 3203 --- [ XNIO-2 task-1] freemarker.cache : Couldn't find template in cache for "error.ftl"("en", UTF-8, parsed); will try to load it.
2017-08-04 22:59:27.441 DEBUG 3203 --- [ XNIO-2 task-1] freemarker.cache : TemplateLoader.findTemplateSource("error_en.ftl"): Not found
2017-08-04 22:59:27.444 DEBUG 3203 --- [ XNIO-2 task-1] freemarker.cache : TemplateLoader.findTemplateSource("error.ftl"): Not found
2017-08-04 22:59:29.623 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Enter: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes() with argument[s] = []
2017-08-04 22:59:29.623 DEBUG 3203 --- [pool-4-thread-1] i.g.j.r.aop.logging.LoggingAspect : Exit: io.github.jhipster.registry.service.ZuulUpdaterService.updateZuulRoutes()
I don't know where all this come from.
Edit-----------------------------------
The problem may be when I run npm install and it's postinstall script "postinstall": "yarn run webpack:build" an ERROR is thrown:
ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader/lib/loader.js!./src/main/webapp/content/scss/vendor.scss
Module build failed: TypeError: Invalid PostCSS Plugin found: [0]
at /Users/xxxxxxx/dev/projects/registrytest/node_modules/postcss-load-plugins/lib/plugins.js:32:17
at Array.forEach (native)
at plugins (/Users/xxxxxxx/dev/projects/registrytest/node_modules/postcss-load-plugins/lib/plugins.js:21:15)
at /Users/xxxxxxx/dev/projects/registrytest/node_modules/postcss-load-config/index.js:64:18
at <anonymous>
# ./src/main/webapp/content/scss/vendor.scss 4:14-194
# ./src/main/webapp/app/vendor.ts
# dll vendor
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jhipster-registry#3.1.0 postinstall: `yarn run webpack:build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jhipster-registry#3.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xxxxxx/.npm/_logs/2017-08-05T07_44_08_129Z-debug.log
I run:
OS X 10.11.6
node: 8.2.1
npm: 5.3.0
It was a dependency issue. The solution for me was:
Downgrade node.js from version 8 to 6.11 because node-sass didn't support node.js 8. Then I upgraded sass-loader, node-sass and postcss-loader to latest versions.
I don't know if this is the way to go but it work for me.

Getting ConcurrentModificationException with Kyro/Activiti and Spring Integration

I am trying out to integrate Activiti with Spring Integration. The sample provided by Josh Long works but when i try to change it, specifically MessageChannels part, it starts throwing ConcurrentModificationException.
Josh Longs Activiti/Spring Integration example here.
As per Josh's code, MessageChannels is as follows:
#Configuration
class MessageChannels {
#Bean
DirectChannel requests() {
return new DirectChannel();
}
#Bean
DirectChannel replies() {
return new DirectChannel();
}
}
I changed this to spring integration (With Stream Rabbit) to
#Configuration
public interface MessageChannels {
#Input
SubscribableChannel input();
#Output("cooutput")
MessageChannel createOutput();
}
And my property file contains,
spring.cloud.stream.bindings.cooutput.destination=outputChannel
I am getting following exception, when i am calling "/start".
2016-09-10 16:14:39.087 INFO 73606 --- [ main] c.e.ActivitiIntegrationDemoApplication : Started ActivitiIntegrationDemoApplication in 8.236 seconds (JVM running for 8.759)
2016-09-10 16:15:39.524 INFO 73606 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-09-10 16:15:39.524 INFO 73606 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-09-10 16:15:39.540 INFO 73606 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
2016-09-10 16:15:39.598 INFO 73606 --- [nio-8080-exec-1] o.s.i.codec.kryo.CompositeKryoRegistrar : registering [40, java.io.File] with serializer org.springframework.integration.codec.kryo.FileSerializer
2016-09-10 16:15:39.638 ERROR 73606 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder$SendingHandler#1b59052b]; nested exception is com.esotericsoftware.kryo.KryoException: java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
beanClassLoader (org.springframework.context.event.SimpleApplicationEventMulticaster)
applicationEventMulticaster (org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext)
applicationContext (org.activiti.spring.ApplicationContextElResolver)
resolvers (org.activiti.engine.impl.javax.el.CompositeELResolver)
elResolver (org.activiti.engine.impl.el.ActivitiElContext)
cachedElContext (org.activiti.engine.impl.persistence.entity.ExecutionEntity)] with root cause
java.util.ConcurrentModificationException: null
at java.util.Vector$Itr.checkForComodification(Vector.java:1184) ~[na:1.8.0_102]
at java.util.Vector$Itr.next(Vector.java:1137) ~[na:1.8.0_102]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:92) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
at
Also I have added following annotations to main class.
#SpringBootApplication
#IntegrationComponentScan
#EnableBinding(MessageChannels.class)
Not sure how to help you, because your use-case is fully unclear, but you have problem with serialization for some unserializable object from the Activiti.
And looks like that one is ActivityExecution instance in the execute() method.
That Activiti-Spring Integration sample does something like this:
Start the process via /start REST endpoint.
That process make a delegation to the Spring Integration via gateway bean - ReceiveTaskActivityBehavior. It's JavaDocs says:
* A receive task is a wait state that waits for the receival of some message.
*
* Currently, the only message that is supported is the external trigger,
* given by calling the {#link RuntimeService#signal(String)} operation.
So, that execute() impl just demonstrates that we can call Spring Integration. The main part remains the same - suspend the process until signal() which is done by the MessageChannels.replies() from the /resume REST endpoint.
Now, explain, please, what you would like to achieve with the Spring Cloud Stream there. Actually both those requests()/replies() in this Activiti sample are input. You initiate something in the app via /start and /resume REST APIs.
Not sure how you have modified that sample, but that is really strange that /start initiates the message sending to the RabbitMQ Binder...

Embedded Glassfish, security and Arquillian questions

I want to test my EJBs on an embedded Glassfish using Arquillian.
The important thing is that I have to have security up because my bean logic does some programmatic security checking (sessionContext.isCallerInRole(role)).
Is it possible to simulate a login with Arquillian on an Embedded Glassfish?
How do I setup the Embedded Glassfish to use user and role property files?
[EDIT]
I found a post who's directions I decided to follow (http://community.jboss.org/message/580290) but I still got issues.
1 my arquillian.xml isn't picked up
2 I get warnings concerning #Resource SessionContext
3 I can't get the running server's instance
src/test/resources/arquillian.xml:
<arquillian xmlns="http://jboss.com/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
<glassfish:container>
<glassfish:bindHttpPort>9090</glassfish:bindHttpPort>
<glassfish:instanceRoot>src/test/glassfish</glassfish:instanceRoot>
<glassfish:autoDelete>true</glassfish:autoDelete>
</glassfish:container>
</arquillian>
my test:
#RunWith(Arquillian.class)
public class ArquillianTestCase {
#Deployment
public static JavaArchive createDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(FileBrowser.class, FileBrowserBean.class).addAsResource("META-INF/ejb-jar.xml")
.addAsResource("META-INF/glassfish-ejb-jar.xml");
return jar;
}
#EJB
private FileBrowser fileBrowser;
#Test
public void setupSecurity() throws Exception {
GlassfishTestHelper.createFileUser("user1", "xxx", "role1");
}
#Test
public void testLoadConfiguration() throws Exception {
final boolean loggedIn = GlassfishTestHelper.loginFileUser("user1", "xxx");
Assert.assertEquals(true, loggedIn);
this.fileBrowser.loadConfiguration();
}
my login helper class:
public final class GlassfishTestHelper {
private GlassfishTestHelper() {
}
public static void createFileUser(final String username, final String password, final String groups) throws Exception {
final Server server = Server.getServer(Server.getServerNames().get(0)); // NPE
final String command = "create-file-user";
final ParameterMap params = new ParameterMap();
params.add("userpassword", password);
params.add("groups", groups);
params.add("username", username);
final CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
final ActionReport report = server.getHabitat().getComponent(ActionReport.class);
runner.getCommandInvocation(command, report).parameters(params).execute();
if (report.getMessage() != null) {
throw new Exception(String.format("Failed to create user : %s - message %s", username, report.getMessage()),
report.getFailureCause());
}
}
public static boolean loginFileUser(final String username, final String password) throws Exception {
final ProgrammaticLogin login = new ProgrammaticLogin();
return login.login(username, password.toCharArray(), "fileRealm", true);
}
}
my EJB:
#Stateless
#Local(FileBrowser.class)
public class FileBrowserBean implements FileBrowser {
#Resource
private SessionContext sessionContext;
#Override
public Set<Application> loadConfiguration() throws FileBrowserException {
// ...
}
}
If I run the test, this is the output:
Running com.jnj.gtsc.services.filebrowser.ArquillianTestCase
18-Apr-2011 16:14:30 org.jboss.arquillian.impl.client.container.ContainerRegistryCreator getActivatedConfiguration
INFO: Could not read active container configuration: null
18-Apr-2011 16:14:31 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
18-Apr-2011 16:14:31 org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator null
18-Apr-2011 16:14:31 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
18-Apr-2011 16:14:32 com.sun.enterprise.v3.services.impl.GrizzlyService createNetworkProxy
INFO: Network listener https-listener on port 0 disabled per domain.xml
18-Apr-2011 16:14:32 com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1 (java_re-private) startup time : Embedded (655ms), startup services(395ms), total(1,050ms)
18-Apr-2011 16:14:32 com.sun.enterprise.v3.services.impl.GrizzlyProxy$2$1 onReady
INFO: Grizzly Framework 1.9.31 started in: 121ms - bound to [0.0.0.0:8181]
18-Apr-2011 16:14:32 org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.
18-Apr-2011 16:14:33 com.sun.enterprise.security.SecurityLifecycle <init>
INFO: SEC1002: Security Manager is OFF.
18-Apr-2011 16:14:33 com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1010: Entering Security Startup Service
18-Apr-2011 16:14:33 com.sun.enterprise.security.PolicyLoader loadPolicy
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.jacc.provider.SimplePolicyProvider.
18-Apr-2011 16:14:34 com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
18-Apr-2011 16:14:34 com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
18-Apr-2011 16:14:34 com.sun.enterprise.security.auth.realm.Realm doInstantiate
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
18-Apr-2011 16:14:34 com.sun.enterprise.security.SecurityLifecycle onInitialization
INFO: SEC1011: Security Service(s) Started Successfully
18-Apr-2011 16:14:34 com.sun.enterprise.web.WebContainer createHttpListener
INFO: WEB0169: Created HTTP listener [http-listener] on host/port [0.0.0.0:8181]
18-Apr-2011 16:14:34 com.sun.enterprise.web.WebContainer createHosts
INFO: WEB0171: Created virtual server [server]
18-Apr-2011 16:14:34 com.sun.enterprise.web.WebContainer loadSystemDefaultWebModules
INFO: WEB0172: Virtual server [server] loaded default web module []
18-Apr-2011 16:14:35 org.glassfish.apf.impl.DefaultErrorHandler warning
WARNING: Incorrect #Resource annotation class definition - missing lookup attribute
symbol: FIELD
location: private javax.ejb.SessionContext com.jnj.gtsc.services.filebrowser.ejb.FileBrowserBean.sessionContext
18-Apr-2011 16:14:35 org.glassfish.apf.impl.DefaultErrorHandler warning
WARNING: Incorrect #Resource annotation class definition - missing lookup attribute
symbol: FIELD
location: private javax.ejb.SessionContext com.jnj.gtsc.services.filebrowser.ejb.FileBrowserBean.sessionContext
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7#720f6c
18-Apr-2011 16:14:35 com.sun.ejb.containers.BaseContainer initializeHome
INFO: Portable JNDI names for EJB FileBrowserBean : [java:global/test/FileBrowserBean!com.jnj.gtsc.services.filebrowser.ejb.FileBrowser, java:global/test/FileBrowserBean]
18-Apr-2011 16:14:36 com.sun.enterprise.web.WebApplication start
INFO: WEB0671: Loading application [test] at [/test]
18-Apr-2011 16:14:36 org.glassfish.deployment.admin.DeployCommand execute
PlainTextActionReporterSUCCESSDescription: deploy AdminCommandApplication deployed with name test.
INFO: test was successfully deployed in 2,845 milliseconds.
[name=test
18-Apr-2011 16:14:36 org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher injectClass
INFO: BeanManager cannot be located at java:comp/BeanManager. Either you are using an archive with no beans.xml, or the BeanManager has not been bound to that location in JNDI.
18-Apr-2011 16:14:36 org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher injectClass
INFO: BeanManager cannot be located at java:comp/BeanManager. Either you are using an archive with no beans.xml, or the BeanManager has not been bound to that location in JNDI.
18-Apr-2011 16:14:36 com.sun.appserv.security.ProgrammaticLogin login
SEVERE: SEC9050: Programmatic login failed
com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Unable to locate a login configuration
at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:394)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:240)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:153)
at com.sun.appserv.security.ProgrammaticLogin$1.run(ProgrammaticLogin.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:168)
at com.jnj.gtsc.services.filebrowser.util.GlassfishTestHelper.loginFileUser(GlassfishTestHelper.java:67)
at com.jnj.gtsc.services.filebrowser.ArquillianTestCase.testLoadConfiguration(ArquillianTestCase.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:259)
at org.jboss.arquillian.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)
at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)
at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)
at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:106)
at org.jboss.arquillian.impl.core.EventImpl.fire(EventImpl.java:67)
at org.jboss.arquillian.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)
at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:80)
at org.jboss.arquillian.impl.TestContextHandler.createTestContext(TestContextHandler.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)
at org.jboss.arquillian.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)
at org.jboss.arquillian.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.arquillian.impl.core.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.impl.core.EventContextImpl.proceed(EventContextImpl.java:87)
at org.jboss.arquillian.impl.core.ManagerImpl.fire(ManagerImpl.java:126)
at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:101)
at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:251)
at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:214)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:303)
at org.jboss.arquillian.junit.Arquillian.access$300(Arquillian.java:45)
at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:228)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:173)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:303)
at org.jboss.arquillian.junit.Arquillian.access$300(Arquillian.java:45)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:187)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.jboss.arquillian.junit.JUnitTestRunner.execute(JUnitTestRunner.java:69)
at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.SecurityException: Unable to locate a login configuration
at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.security.auth.login.Configuration$3.run(Configuration.java:247)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:242)
at javax.security.auth.login.LoginContext$1.run(LoginContext.java:237)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.init(LoginContext.java:234)
at javax.security.auth.login.LoginContext.<init>(LoginContext.java:367)
at javax.security.auth.login.LoginContext.<init>(LoginContext.java:444)
at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:381)
... 107 more
Caused by: java.io.IOException: Unable to locate a login configuration
at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:250)
at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:91)
... 122 more
classLoader = WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7#720f6c
PlainTextActionReporterSUCCESSNo monitoring data to report.
Glassfish standalone instance configuration may be used with Arquillian GlassFish Embedded containter adapter. You need to check security in your tests, so you must prepare your GlassFish instance configuration first. This can be achieved also by programmatic configuration (see https://stackoverflow.com/a/20411981/2169124), but for me configuration in test resources looks more natural. To configure users in file realm (used by default) you need to:
Install standalone Glassfish server;
Start Glassfish instance with asadmin command:
$GLASSFISH_HOME/bin/asadmin start-domain
Add users to file realm with asadmin command (stored in file named keyfile):
$GLASSFISH_HOME/bin/asadmin create-file-user --user username
Copy folders
$GLASSFISH_HOME/glassfish/domains/domain1/config
$GLASSFISH_HOME/glassfish/domains/domain1/docroot
to test resources (for example src/test/resources/domain, assuming that you are using maven)
In arquillian.xml define path to glassfish configuration (it will be copied to target/test-classes/domain by maven):
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="glassfish-embedded" default="true">
<configuration>
<property name="instanceRoot">target/test-classes/domain</property>
</configuration>
</container>
Map users to roles in glassfish-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-application PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Java EE Application 6.0//EN" "http://glassfish.org/dtds/glassfish-application_6_0-1.dtd">
<glassfish-application>
<security-role-mapping>
<role-name>admin</role-name>
<principal-name>username</principal-name>
</security-role-mapping>
</glassfish-application>
Add glassfish-application.xml to test artifact:
ShrinkWrap.create(EnterpriseArchive.class)
.addAsModule(ejbJar)
.addAsManifestResource(new File("src/test/resources/glassfish-application.xml"))
In test method use ProgrammaticLogin to handle authentication:
ProgrammaticLogin programmaticLogin = new ProgrammaticLogin();
programmaticLogin.login("username", "password");

Resources