> 1) Please, take a look at the second table (module overview) here > https://labs.consol.de/development/2017/02/13/getting-started-with-java9-modules.html
Did that, the article looks like there is finally some solid material on modules. > 2) Weld is not unnamed module but automatic module as it is on module path > and I use it by name. Yea, you are right, my bad. I meant automatic module OFC. > 3) From that table (module overview) we see that both automatic and unnamed > modules can read application modules. If so, then why it doesn't? I suppose you already got your answer on StackOverflow[1], right? To add on top of that, if you `exports` package - you only expose public things in there. For Weld to create proxies of your beans, we need to go deeper and allow reflections access which may mean accessing private/protected stuff (such as your @Inject private NewBean bean). Java 9 doesn't like that and requires you to `opens` the package for this kind of work. > And got the following (see below). It seems that Weld can't now work with > JPMS. > What will Weld developers say? From the SO question I guess you got it working in the end. If you have any other questions, feel free to contact us again. I'll try to test some JDK 9 project myself to refresh my memory so that I can be of more help next time :) Matej _________________________________________________________________________- [1] https://stackoverflow.com/questions/46282509 ----- Original Message ----- > From: "Alex Sviridov" <[email protected]> > To: "weld-dev" <[email protected]> > Sent: Monday, September 18, 2017 5:23:30 PM > Subject: Re: [weld-dev] Weld and Java 9 JPMS > > So, here I am. > I changed my.module from > my.module { > requires weld.se.shaded; > exports com.foo; > } > to > my.module { > requires weld.se.shaded; > opens com.foo; > } > > And got the following (see below). It seems that Weld can't now work with > JPMS. > What will Weld developers say? > > Exception in thread "main" org.jboss.weld.exceptions.WeldException: > WELD-001524: Unable to load proxy class for bean Implicit Bean > [javax.enterprise.event.Event] with qualifiers [@Default] with class > interface javax.enterprise.event.Event using classloader > jdk.internal.loader.ClassLoaders$AppClassLoader@6b2fad11 > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) > at > java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:587) > at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:996) > at > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:72) > at > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:58) > at > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:66) > at > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer.doAfterBeanDiscovery(ConcurrentBeanDeployer.java:88) > at > [email protected]/org.jboss.weld.bootstrap.BeanDeployment.afterBeanDiscovery(BeanDeployment.java:268) > at > [email protected]/org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:466) > at > [email protected]/org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83) > at > [email protected]/org.jboss.weld.environment.se.Weld.initialize(Weld.java:789) > at my.module/com.foo.NewMain.main(NewMain.java:47) > Caused by: org.jboss.weld.exceptions.WeldException: WELD-001524: Unable to > load proxy class for bean Implicit Bean [javax.enterprise.event.Event] with > qualifiers [@Default] with class interface javax.enterprise.event.Event > using classloader jdk.internal.loader.ClassLoaders$AppClassLoader@6b2fad11 > at > [email protected]/org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:389) > at > [email protected]/org.jboss.weld.bean.builtin.AbstractFacadeBean.initializeAfterBeanDiscovery(AbstractFacadeBean.java:61) > at > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:111) > at > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:102) > at > [email protected]/org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62) > at > [email protected]/org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55) > at > java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431) > at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:283) > at > java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603) > at > java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) > Caused by: java.lang.ExceptionInInitializerError > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) > at > [email protected]/org.jboss.weld.bean.proxy.ProxyFactory.newClassFile(ProxyFactory.java:496) > at > [email protected]/org.jboss.weld.bean.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:455) > at > [email protected]/org.jboss.weld.bean.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:381) > ... 9 more > Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make > protected final java.lang.Class > java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws > java.lang.ClassFormatError accessible: module java.base does not "opens > java.lang" to module weld.se.shaded > at > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337) > at > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281) > at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198) > at java.base/java.lang.reflect.Method.setAccessible(Method.java:192) > at > [email protected]/org.jboss.classfilewriter.ClassFile$1.run(ClassFile.java:256) > at java.base/java.security.AccessController.doPrivileged(Native Method) > at > [email protected]/org.jboss.classfilewriter.ClassFile.<clinit>(ClassFile.java:251) > ... 16 more > > > > > > > Понедельник, 18 сентября 2017, 16:39 +03:00 от Matej Novotny > <[email protected]>: > > From the exception you are getting, this line is important: > > "Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make > field private com.foo.NewBean com.foo.NewClass.bean accessible: module > my.module does not "opens com.foo" to module weld.se.shaded" > > Basically, Weld is not modularized (== lands in unnamed module) and it needs > access to your module so that it can create beans. E.g. you need to make > sure unnamed module has access to your module. > I think that by default in JDK 9 the access is intended so that all modules > can read unnamed module, but unnamed module can only read itself (simplified > version). > Hence you want to break a few rules and force this to work in the opposite > direction for your module. > > Matej > > > ----- Original Message ----- > > From: "Alex Sviridov" < [email protected] > > > To: "weld-dev" < [email protected] > > > Sent: Monday, September 18, 2017 1:46:36 PM > > Subject: Re: [weld-dev] Weld and Java 9 JPMS > > > > Thank you for your answer. > > > > Could anyone give any suggestion about the following? > > > > I have my named module and weld-se-shaded as unnamed module. > > In my module I have > > > > module my.module { > > requires weld.se.shaded; > > exports com.foo; > > } > > > > ################################# > > package com.foo; > > > > import javax.enterprise.context.ApplicationScoped; > > import javax.inject.Inject; > > > > @ApplicationScoped > > public class NewClass { > > > > @Inject > > private NewBean bean; > > > > public void doIt() { > > bean.doIt(); > > } > > > > } > > > > ################################# > > package com.foo; > > > > import javax.enterprise.context.Dependent; > > > > @Dependent > > public class NewBean { > > > > public void doIt() { > > System.out.println("I am doing it); > > } > > } > > > > And this is the result > > > > Sep 18, 2017 2:33:12 PM org.jboss.weld.bootstrap.WeldStartup <clinit> > > INFO: WELD-000900: 3.0.2 (2017-09-18 08:49) > > Sep 18, 2017 2:33:12 PM > > org.jboss.weld.environment.deployment.discovery.ReflectionDiscoveryStrategy > > processAnnotatedDiscovery > > INFO: WELD-ENV-000014: Falling back to Java Reflection for > > bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the > > classpath to speed-up startup. > > Sep 18, 2017 2:33:12 PM org.jboss.weld.bootstrap.WeldStartup startContainer > > INFO: WELD-000101: Transactional services not available. Injection of > > @Inject > > UserTransaction not available. Transactional observers will be invoked > > synchronously. > > Exception in thread "main" java.lang.reflect.InaccessibleObjectException > > at > > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > > Method) > > at > > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > > at > > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > > at > > java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) > > at > > java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:590) > > at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:996) > > at > > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:72) > > at > > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:58) > > at > > [email protected]/org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:66) > > at > > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createClassBeans(ConcurrentBeanDeployer.java:65) > > at > > [email protected]/org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:256) > > at > > [email protected]/org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:422) > > at > > [email protected]/org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83) > > at > > [email protected]/org.jboss.weld.environment.se.Weld.initialize(Weld.java:789) > > at my.module/com.foo.NewMain.main(NewMain.java:47) > > Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make > > field private com.foo.NewBean com.foo.NewClass.bean accessible: module > > my.module does not "opens com.foo" to module weld.se.shaded > > at > > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337) > > at > > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281) > > at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:176) > > at java.base/java.lang.reflect.Field.setAccessible(Field.java:170) > > at > > [email protected]/org.jboss.weld.security.GetAccessibleCopyOfMember.of(GetAccessibleCopyOfMember.java:38) > > at > > [email protected]/org.jboss.weld.security.GetAccessibleCopyOfMember.run(GetAccessibleCopyOfMember.java:44) > > at > > [email protected]/org.jboss.weld.security.GetAccessibleCopyOfMember.run(GetAccessibleCopyOfMember.java:26) > > at java.base/java.security.AccessController.doPrivileged(Native Method) > > at > > [email protected]/org.jboss.weld.injection.FieldInjectionPoint.<init>(FieldInjectionPoint.java:65) > > at > > [email protected]/org.jboss.weld.injection.InjectionPointFactory.createFieldInjectionPoint(InjectionPointFactory.java:141) > > at > > [email protected]/org.jboss.weld.injection.InjectionPointFactory.addFieldInjectionPoint(InjectionPointFactory.java:226) > > at > > [email protected]/org.jboss.weld.injection.InjectionPointFactory.getFieldInjectionPoints(InjectionPointFactory.java:211) > > at > > [email protected]/org.jboss.weld.injection.producer.DefaultInjector.<init>(DefaultInjector.java:56) > > at > > [email protected]/org.jboss.weld.injection.producer.ResourceInjector.<init>(ResourceInjector.java:57) > > at > > [email protected]/org.jboss.weld.injection.producer.ResourceInjector.of(ResourceInjector.java:48) > > at > > [email protected]/org.jboss.weld.injection.producer.BeanInjectionTarget.<init>(BeanInjectionTarget.java:63) > > at > > [email protected]/org.jboss.weld.injection.producer.BeanInjectionTarget.createDefault(BeanInjectionTarget.java:47) > > at > > [email protected]/org.jboss.weld.manager.InjectionTargetFactoryImpl.chooseInjectionTarget(InjectionTargetFactoryImpl.java:139) > > at > > [email protected]/org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:88) > > at > > [email protected]/org.jboss.weld.bean.ManagedBean.<init>(ManagedBean.java:100) > > at > > [email protected]/org.jboss.weld.bean.ManagedBean.of(ManagedBean.java:80) > > at > > [email protected]/org.jboss.weld.bootstrap.AbstractBeanDeployer.createManagedBean(AbstractBeanDeployer.java:280) > > at > > [email protected]/org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:221) > > at > > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:68) > > at > > [email protected]/org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:65) > > at > > [email protected]/org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62) > > at > > [email protected]/org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55) > > at > > java.base/java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431) > > at > > java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:283) > > at > > java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603) > > at > > java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) > > > > > > > > > > > > > > > > Понедельник, 18 сентября 2017, 14:18 +03:00 от Matej Novotny > > < [email protected] >: > > > > Hi, > > > > if you are in SE, you should only need 'weld-se-shaded' artifact (as a > > JAR). > > As it is "shaded", it brings along all the other parts of Weld you might > > need. > > > > Matej > > > > > > ----- Original Message ----- > > > From: "Alex Sviridov" < [email protected] > > > > To: "weld-dev" < [email protected] > > > > Sent: Monday, September 18, 2017 12:17:28 PM > > > Subject: Re: [weld-dev] Weld and Java 9 JPMS > > > > > > Hi Matej > > > > > > I am just trying to make Weld work in Java 9 (JavaSE + JPMS). > > > > > > I use the following jars as automatic modules: > > > > > > weld-environment-common-3.0.2-SNAPSHOT.jar > > > weld-se-core-3.0.2-SNAPSHOT.jar > > > weld-se-shaded-3.0.2-SNAPSHOT.jar > > > weld-spi-3.0.SP1.jar > > > weld-core-impl-3.0.2-SNAPSHOT.jar > > > > > > Is this right configuration? Or should I add/remove something. > > > > > > Best regards, Alex > > > > > > > > > > > > Понедельник, 18 сентября 2017, 12:41 +03:00 от Matej Novotny > > > < [email protected] >: > > > > > > Uhm, is there anything blocking you from placing it where you would in > > > Java > > > 8? > > > E.g. src/main/resources/META-INF? > > > > > > I don't think I have tried this combination (or I do not recall). > > > From the top of my head I don't know any JDK 9 limitation which would > > > forbid > > > to use XML descriptors in this way. > > > I might be a bit rusty though; been a while since I played with Java 9. > > > > > > Please do report back with how this works for you :) > > > Matej > > > > > > ----- Original Message ----- > > > > From: "Alex Sviridov" < [email protected] > > > > > To: "Matej Novotny" < [email protected] > > > > > Sent: Monday, September 18, 2017 10:28:11 AM > > > > Subject: Re[2]: [weld-dev] Weld and Java 9 JPMS > > > > > > > > Thank you for your answer. I will try. But where should I place > > > > beans.xml > > > > to make Weld read it if I use Java SE+ JPMS? > > > > > > > > Best regards, Alex > > > > > > > > > > > > >Понедельник, 18 сентября 2017, 8:10 +03:00 от Matej Novotny > > > > >< [email protected] >: > > > > > > > > > >Hi Alex > > > > > > > > > >Back there we did some tests with earlier versions of Java 9 and > > > > >eliminated > > > > >some crucial problems. > > > > >I think it should be possible to take *existing* app and run it on > > > > >Java > > > > >9. > > > > > > > > > >However, creating a whole new modular project might present some > > > > >additional > > > > >challenges. > > > > >Weld itself is not modularized (since it needs to run on Java 8), > > > > >therefore > > > > >you would need to list some extra "requires" in module-info.java for > > > > >Weld. > > > > >You also need to have reflection access allowed (we need to > > > > >instantiate > > > > >proxies etc) but last time I checked, it was by default enabled in JDK > > > > >9 > > > > >wi > > > > >th just warning showing up. > > > > >Other than that, it might just work. > > > > > > > > > >To answer your other question - no, there is no tutorial, for there is > > > > >no > > > > >special difference between Weld and many other projects in regard to > > > > >JDK > > > > >9. > > > > > > > > > >Matej > > > > > > > > > >----- Original Message ----- > > > > >> From: "Alex Sviridov" < [email protected] > > > > > >> To: "weld-dev" < [email protected] > > > > > >> Sent: Sunday, September 17, 2017 3:25:49 PM > > > > >> Subject: [weld-dev] Weld and Java 9 JPMS > > > > >> > > > > >> Hi all > > > > >> > > > > >> Could anyone provide information how weld works (if works) with Java > > > > >> 9 > > > > >> JPMS? > > > > >> Is there any tutorial? > > > > >> > > > > >> Best regards, Alex > > > > >> > > > > >> _______________________________________________ > > > > >> weld-dev mailing list > > > > >> [email protected] > > > > >> https://lists.jboss.org/mailman/listinfo/weld-dev > > > > > > > > > > > > -- > > > > Alex Sviridov > > > > > > > > > > > > > -- > > > Alex Sviridov > > > > > > _______________________________________________ > > > weld-dev mailing list > > > [email protected] > > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > > > > -- > > Alex Sviridov > > > > _______________________________________________ > > weld-dev mailing list > > [email protected] > > https://lists.jboss.org/mailman/listinfo/weld-dev > > > -- > Alex Sviridov > > _______________________________________________ > weld-dev mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/weld-dev _______________________________________________ weld-dev mailing list [email protected] https://lists.jboss.org/mailman/listinfo/weld-dev
