Re: [weld-dev] Staring weld container for SE environment makes me load java ee classes.

2018-05-17 Thread Martin Kouba
Dne 17.5.2018 v 12:50 Alex Sviridov napsal(a):
> Hi Martin,
> 
> Could you or someone else explain what is the difference between 
> getResource(String name) and getResources(String name) in 
> ResourceLoader? 

It's similar to java.lang.ClassLoader.getResource(String) and 
java.lang.ClassLoader.getResources(String).

> And, could anyone explain how Weld detects what archives 
> it must scan? For examlpe, if from getResource I return 
> `jar:file:///home/user/../jar/my-archive-0.1.0-SNAPSHOT.jar!/META-INF/beans.xml`
>  
> , does it mean that Weld will scan my-archive-0.1.0-SNAPSHOT.jar as it 
> will get the path to archive from this URL?

Yes, Weld will attempt to process the referenced bean archive (using all 
registered 
org.jboss.weld.environment.deployment.discovery.BeanArchiveHandler 
instances).

> 
> Best regards, Alex
> 
> Четверг, 17 мая 2018, 10:12 +03:00 от Martin Kouba :
> 
> Dne 16.5.2018 v 20:02 Alex Sviridov napsal(a):
>  > Hi Matej
>  >
>  > I followed your answer and run Weld (SE) as auto module in my JPMS
>  > layer. In this layer I have an arhive with beans.xml
>  > This is my code:
>  >    Weld weld = new Weld();
>  >     WeldContainer container = weld.initialize();
>  >
>  > This is what I get:
>  >
>  > INFO: WELD-000900: 3.0.4 (Final)
>  > May 16, 2018 7:00:39 PM
>  >
> 
> org.jboss.weld.environment.deployment.discovery.ReflectionDiscoveryStrategy
> 
>  > processAnnotatedDiscovery
>  > INFO: WELD-ENV-14: Falling back to Java Reflection for
>  > bean-discovery-mode="annotated" discovery. Add org.jboss:jandex
> to the
>  > classpath to speed-up startup.
>  > 2018-05-16 19:00:39:187 [main] ERROR
>  > com.techsenger.webserver.core.internal.Activator - Error starting
> server
>  > java.lang.IllegalStateException: WELD-ENV-002009: Weld SE container
>  > cannot be initialized - no bean archives found
>  >     at
>  >
> 
> weld.se.core@3.0.4.Final/org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:962)
>  >     at
>  >
> 
> weld.se.core@3.0.4.Final/org.jboss.weld.environment.se.Weld.initialize(Weld.java:773)
>  >
>  > Are there any ways to control what modules Weld should scan if we
>  > initialize via Weld class?
> 
> Weld SE does not support JPMS modules atm. By default, the
> TCCL#getResources() is used to find all beans.xml (if set) or the
> ClassLoader which loaded the WeldResourceLoader.class. However, you can
> provide a custom ClassLoader or
> org.jboss.weld.resources.spi.ResourceLoader respectively (see
> Weld#setClassLoader() and Weld#setResourceLoader()).
> 
>  >
>  > By the way: STOP creating packages with the same name in
> different JAR
>  > arhives! JPMS doesn't allow it! I had to merge core-impl, spi and
> api in
>  > one file.
> 
> Which packages are you talking about? We do know about this limitation
> and AFAIK this was fixed in 3.0.0. If there is a duplicit package pls
> create a JIRA issue.
> 
>  >
>  > Best regards, Alex
>  >
>  > Среда, 16 мая 2018, 16:47 +03:00 от Matej Novotny
>  > 
> >:
>  >
>  > Weld 2.x is NOT to be executed with Java 9+.
>  > Use Weld 3, please. Best use latest release of course (3.0.4.Final).
>  >
>  > If you can share the test project on GH, that would be neat as well.
>  > Then we could see how you use weld as auto module (as well as many
>  > other configurations) and go from there.
>  >
>  > As for starting SE container, you shouldn't manually call
>  > `bootstrap.startContainer(Environments.SE, deployment);`
>  > Please see the docs on how to bootstrap Weld in SE, you shouldn't
>  > need to deal with any of the methods you listed below.
>  > Here is a doc link -
>  >
> 
> http://docs.jboss.org/weld/reference/latest-master/en-US/html_single/#_bootstrapping_cdi_se
>  >
>  > Regards
>  > Matej
>  >
>  > - Original Message -
>  > > From: "Alex Sviridov"  
>  > >
>  > > To: "weld-dev"  
>  > >
>  > > Sent: Wednesday, May 16, 2018 1:51:20 PM
>  > > Subject: [weld-dev] Staring weld container for SE environment
>  > makes me load java ee classes.
>  > >
>  > > Hi all
>  > >
>  > > I am trying to start weld container (2.3.5) as auto module in
>  > JPMS. This is
>  > > my code
>  > >
>  > > Deployment deployment = new Deployment() {
>  > > @Override
>  > > public Collection
>  > getBeanDeploymentArchives() {
>  > > List list = new ArrayList<>();
>  > > list.add(archive);
>  > > return list;
>  > > }
>  > >
>  > > 

Re: [weld-dev] Staring weld container for SE environment makes me load java ee classes.

2018-05-17 Thread Alex Sviridov
Hi Martin,

Could you or someone else explain what is the difference between 
getResource(String name) and getResources(String name) in ResourceLoader? And, 
could anyone explain how Weld detects what archives it must scan? For examlpe, 
if from getResource I return 
`jar:file:///home/user/../jar/my-archive-0.1.0-SNAPSHOT.jar!/META-INF/beans.xml`
 , does it mean that Weld will scan my-archive-0.1.0-SNAPSHOT.jar as it will 
get the path to archive from this URL?

Best regards, Alex

>Четверг, 17 мая 2018, 10:12 +03:00 от Martin Kouba :
>
>Dne 16.5.2018 v 20:02 Alex Sviridov napsal(a):
>> Hi Matej
>> 
>> I followed your answer and run Weld (SE) as auto module in my JPMS 
>> layer. In this layer I have an arhive with beans.xml
>> This is my code:
>>     Weld weld = new Weld();
>>      WeldContainer container = weld.initialize();
>> 
>> This is what I get:
>> 
>> INFO: WELD-000900: 3.0.4 (Final)
>> May 16, 2018 7:00:39 PM 
>> org.jboss.weld.environment.deployment.discovery.ReflectionDiscoveryStrategy 
>> processAnnotatedDiscovery
>> INFO: WELD-ENV-14: Falling back to Java Reflection for 
>> bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the 
>> classpath to speed-up startup.
>> 2018-05-16 19:00:39:187 [main] ERROR 
>> com.techsenger.webserver.core.internal.Activator - Error starting server
>> java.lang.IllegalStateException: WELD-ENV-002009: Weld SE container 
>> cannot be initialized - no bean archives found
>>      at 
>> weld.se.core@3.0.4.Final/org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:962)
>>      at 
>> weld.se.core@3.0.4.Final/org.jboss.weld.environment.se.Weld.initialize(Weld.java:773)
>> 
>> Are there any ways to control what modules Weld should scan if we 
>> initialize via Weld class?
>
>Weld SE does not support JPMS modules atm. By default, the 
>TCCL#getResources() is used to find all beans.xml (if set) or the 
>ClassLoader which loaded the WeldResourceLoader.class. However, you can 
>provide a custom ClassLoader or 
>org.jboss.weld.resources.spi.ResourceLoader respectively (see 
>Weld#setClassLoader() and Weld#setResourceLoader()).
>
>> 
>> By the way: STOP creating packages with the same name in different JAR 
>> arhives! JPMS doesn't allow it! I had to merge core-impl, spi and api in 
>> one file.
>
>Which packages are you talking about? We do know about this limitation 
>and AFAIK this was fixed in 3.0.0. If there is a duplicit package pls 
>create a JIRA issue.
>
>> 
>> Best regards, Alex
>> 
>> Среда, 16 мая 2018, 16:47 +03:00 от Matej Novotny
>> < manov...@redhat.com >:
>> 
>> Weld 2.x is NOT to be executed with Java 9+.
>> Use Weld 3, please. Best use latest release of course (3.0.4.Final).
>> 
>> If you can share the test project on GH, that would be neat as well.
>> Then we could see how you use weld as auto module (as well as many
>> other configurations) and go from there.
>> 
>> As for starting SE container, you shouldn't manually call
>> `bootstrap.startContainer(Environments.SE, deployment);`
>> Please see the docs on how to bootstrap Weld in SE, you shouldn't
>> need to deal with any of the methods you listed below.
>> Here is a doc link -
>>  
>> http://docs.jboss.org/weld/reference/latest-master/en-US/html_single/#_bootstrapping_cdi_se
>> 
>> Regards
>> Matej
>> 
>> - Original Message -
>>  > From: "Alex Sviridov" < ooo_satu...@mail.ru
>> >
>>  > To: "weld-dev" < weld-dev@lists.jboss.org
>> >
>>  > Sent: Wednesday, May 16, 2018 1:51:20 PM
>>  > Subject: [weld-dev] Staring weld container for SE environment
>> makes me load java ee classes.
>>  >
>>  > Hi all
>>  >
>>  > I am trying to start weld container (2.3.5) as auto module in
>> JPMS. This is
>>  > my code
>>  >
>>  > Deployment deployment = new Deployment() {
>>  > @Override
>>  > public Collection
>> getBeanDeploymentArchives() {
>>  > List list = new ArrayList<>();
>>  > list.add(archive);
>>  > return list;
>>  > }
>>  >
>>  > @Override
>>  > public BeanDeploymentArchive loadBeanDeploymentArchive(Class
>> beanClass) {
>>  > throw new UnsupportedOperationException("Not supported yet.");
>>  > }
>>  >
>>  > @Override
>>  > public ServiceRegistry getServices() {
>>  > SimpleServiceRegistry simpleServiceRegistry = new
>> SimpleServiceRegistry();
>>  > simpleServiceRegistry.add(ResourceLoader.class, new
>> ResourceLoaderImpl());
>>  > return simpleServiceRegistry;
>>  > }
>>  >
>>  > @Override
>>  > public Iterable getExtensions() {
>>  > return new ArrayList<>();
>>  > }
>>  > };
>>  >
>>  > bootstrap.startContainer(Environments.SE, deployment);
>>  >
>>  > The problem is that in BeanDeployment constructor all services
>> are loaded
>>  > here
>>  >
>>  
>>