Re: [weld-dev] Integrating with Weld Probe

2018-03-26 Thread Martin Kouba
If using Weld SE you can to set Weld.DEV_MODE_SYSTEM_PROPERTY to true 
(using Weld#property() or system property) - this automatically 
registers ProbeExtension. If you also want to expose rest api/html 
client, then register ProbeFilter as a servlet filter mapped to a single 
URL pattern of value "/*".

I'm not sure about the bean-discovery-mode=all issue, but I can't say 
more without the proper knowledge of the app structure. Probe itself 
does not modify anything though.

Martin

Dne 26.3.2018 v 12:48 John D. Ament napsal(a):
> Hi
> 
> I was following the docs online ( 
> https://docs.jboss.org/weld/reference/latest/en-US/html/devmode.html ) 
> to integrate Weld Probe into an SE application.
> 
> It looks like Probe takes care of serving static assets itself via the 
> filter.
> 
> Since this is an SE application, I programmatically register the 
> ProbeFilter (name="WeldProbeFilter",value= new String[]{"/weld-probe/*"},
>              uriPatterns=new String[]{"/weld-probe/*"},
>              dispatcherTypes=Constants.DISPATCHER_TYPES, // short cut 
> for all
>              initParams=new WebInitParam[]{},
>              asyncSupported=true,
>              servletName=null,
>              filterClass=ProbeFilter.class)
> 
> I tried to start the application w/ -Dorg.jboss.weld.development=true 
> and noticed that it seemed to switch to bean-discovery-mode=all (without 
> trim, even though all of my JARs are with trim option).  I then tried to 
> manually enable the extension, but that resulted in
> 
> 21:08:25.149 [main] WARN  org.jboss.weld.probe.Probe - PROBE-08:
> =
>   Weld Development Mode: ENABLED
>   
>   Disable this mode in production - it may have negative impact on 
> performance and/or represent a potential security risk
> =
> 21:08:25.767 [ForkJoinPool.commonPool-worker-7] WARN  
> org.jboss.weld.Validator - WELD-001473: javax.enterprise.inject.spi.Bean 
> implementation org.apache.cxf.cdi.CdiBusBean@74cadd41 declared a normal 
> scope but does not implement 
> javax.enterprise.inject.spi.PassivationCapable. It won't be possible to 
> inject this bean into a bean with a passivating scope (@SessionScoped, 
> @ConversationScoped). This can be fixed by assigning the Bean 
> implementation a unique id by implementing the PassivationCapable interface.
> Exception in thread "main" 
> org.jboss.weld.exceptions.DeploymentException: PROBE-05: Probe is 
> not properly initialized
> at 
> org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
> at 
> org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
> at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:489)
> at 
> org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
> at org.jboss.weld.environment.se.Weld.initialize(Weld.java:800)
> at org.jboss.weld.environment.se.Weld.initialize(Weld.java:175)
> at 
> ws.ament.hammock.bootstrap.weld3.Weld3Bootstrapper.start(Weld3Bootstrapper.java:58)
> at ws.ament.hammock.Bootstrap.main(Bootstrap.java:41)
> at 
> ws.ament.hammock.example.canonical.RestApplication.main(RestApplication.java:31)
> Caused by: org.jboss.weld.exceptions.IllegalStateException: 
> PROBE-05: Probe is not properly initialized
> at org.jboss.weld.probe.InvocationMonitor.init(InvocationMonitor.java:148)
> at 
> org.jboss.weld.probe.InvocationMonitor.monitorCreation(InvocationMonitor.java:103)
> 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.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
> at 
> org.jboss.weld.interceptor.proxy.WeldInvocationContextImpl.invokeNext(WeldInvocationContextImpl.java:92)
> at 
> org.jboss.weld.interceptor.proxy.WeldInvocationContextImpl.proceed(WeldInvocationContextImpl.java:124)
> at 
> org.jboss.weld.injection.producer.ConstructorInterceptionInstantiator$1.aroundConstruct(ConstructorInterceptionInstantiator.java:100)
> at 
> org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallback(ConstructorInjectionPoint.java:109)
> at 
> org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:95)
> at 
> org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
> at 
> org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
> at 
> org.jboss.weld.injection.producer.InterceptorApplyingInstantiator.newInstance(InterceptorApplyingInstantiator.java:62)
> at 
> 

[weld-dev] Integrating with Weld Probe

2018-03-26 Thread John D. Ament
Hi

I was following the docs online (
https://docs.jboss.org/weld/reference/latest/en-US/html/devmode.html ) to
integrate Weld Probe into an SE application.

It looks like Probe takes care of serving static assets itself via the
filter.

Since this is an SE application, I programmatically register the
ProbeFilter (name="WeldProbeFilter",value= new String[]{"/weld-probe/*"},
uriPatterns=new String[]{"/weld-probe/*"},
dispatcherTypes=Constants.DISPATCHER_TYPES, // short cut for all
initParams=new WebInitParam[]{},
asyncSupported=true,
servletName=null,
filterClass=ProbeFilter.class)

I tried to start the application w/ -Dorg.jboss.weld.development=true and
noticed that it seemed to switch to bean-discovery-mode=all (without trim,
even though all of my JARs are with trim option).  I then tried to manually
enable the extension, but that resulted in

21:08:25.149 [main] WARN  org.jboss.weld.probe.Probe - PROBE-08:
=
 Weld Development Mode: ENABLED
 
 Disable this mode in production - it may have negative impact on
performance and/or represent a potential security risk
=
21:08:25.767 [ForkJoinPool.commonPool-worker-7] WARN
org.jboss.weld.Validator - WELD-001473: javax.enterprise.inject.spi.Bean
implementation org.apache.cxf.cdi.CdiBusBean@74cadd41 declared a normal
scope but does not implement
javax.enterprise.inject.spi.PassivationCapable. It won't be possible to
inject this bean into a bean with a passivating scope (@SessionScoped,
@ConversationScoped). This can be fixed by assigning the Bean
implementation a unique id by implementing the PassivationCapable interface.
Exception in thread "main" org.jboss.weld.exceptions.DeploymentException:
PROBE-05: Probe is not properly initialized
at
org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
at
org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:489)
at
org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:800)
at org.jboss.weld.environment.se.Weld.initialize(Weld.java:175)
at
ws.ament.hammock.bootstrap.weld3.Weld3Bootstrapper.start(Weld3Bootstrapper.java:58)
at ws.ament.hammock.Bootstrap.main(Bootstrap.java:41)
at
ws.ament.hammock.example.canonical.RestApplication.main(RestApplication.java:31)
Caused by: org.jboss.weld.exceptions.IllegalStateException: PROBE-05:
Probe is not properly initialized
at org.jboss.weld.probe.InvocationMonitor.init(InvocationMonitor.java:148)
at
org.jboss.weld.probe.InvocationMonitor.monitorCreation(InvocationMonitor.java:103)
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.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
at
org.jboss.weld.interceptor.proxy.WeldInvocationContextImpl.invokeNext(WeldInvocationContextImpl.java:92)
at
org.jboss.weld.interceptor.proxy.WeldInvocationContextImpl.proceed(WeldInvocationContextImpl.java:124)
at
org.jboss.weld.injection.producer.ConstructorInterceptionInstantiator$1.aroundConstruct(ConstructorInterceptionInstantiator.java:100)
at
org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallback(ConstructorInjectionPoint.java:109)
at
org.jboss.weld.injection.ConstructorInjectionPoint.invokeAroundConstructCallbacks(ConstructorInjectionPoint.java:95)
at
org.jboss.weld.injection.ConstructorInjectionPoint.newInstance(ConstructorInjectionPoint.java:78)
at
org.jboss.weld.injection.producer.AbstractInstantiator.newInstance(AbstractInstantiator.java:28)
at
org.jboss.weld.injection.producer.InterceptorApplyingInstantiator.newInstance(InterceptorApplyingInstantiator.java:62)
at
org.jboss.weld.injection.producer.ConstructorInterceptionInstantiator.newInstance(ConstructorInterceptionInstantiator.java:66)
at
org.jboss.weld.injection.producer.BasicInjectionTarget.produce(BasicInjectionTarget.java:112)
at
org.jboss.weld.injection.producer.BeanInjectionTarget.produce(BeanInjectionTarget.java:186)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:158)
at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
at
org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at
org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140)
at