0

我正在使用 procrun ( Apache JSVC ) 创建一个操作系统后台服务。我想使用WELD作为容器。

应用程序本身(gradle run)工作正常。我可以看到所需的行为。但是当我尝试将它作为 Windows 服务运行时,我会看到以下错误:

PS C:\Users\szdud\Documents\Projects\Java\logreader\build\windows-service> .\LogReader.exe //TS//LogReader start
System coudn't find path given.
Unable to create logger at ''
Exception in thread "main" java.lang.NoClassDefFoundError: com/netps/build/LogReaderService
Caused by: java.lang.ClassNotFoundException: com.netps.build.LogReaderService
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
[2018-03-03 23:42:11] [error] [13612] FindClass com/netps/build/LogReaderService failed
[2018-03-03 23:42:11] [error] [ 3724] Failed to start Java
[2018-03-03 23:42:11] [error] [ 3724] ServiceStart returned 4
[2018-03-03 23:42:11] [error] [ 3724] Commons Daemon procrun failed with exit value: 3 (Failed to run service as console application)

Failed to run service as console application

看起来 WELD 丢失了它的上下文和类路径位置。但我不知道为什么以及如何解决它。

你能帮我吗?

如果您想查看代码,可以在这里查看: https ://github.com/sdudziak/logreader

编辑:我在 Linux 操作系统下创建了一个 JAR 文件来检查这是否只是一个 Win 问题。事实并非如此。我在运行时遇到了同样的问题java -jar log-reader-all-1.0.jar

[2018-03-05 10:52:10.226][DEBUG][main] logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
[2018-03-05 10:52:10.230][INFO ][main] Version - WELD-000900: 3.0.3 (Final)
[2018-03-05 10:52:10.251][DEBUG][main] Bootstrap - WELD-ENV-000030: Cannot load class using the ResourceLoader: org.jboss.jandex.Index
[2018-03-05 10:52:10.419][DEBUG][main] DefaultBeanArchiveScanner - Resolved bean archive reference: /var/www/netps/logreader/build/libs/log-
reader-all-1.0.jar for URL: jar:file:/var/www/netps/logreader/build/libs/log-reader-all-1.0.jar!/META-INF/beans.xml
[2018-03-05 10:52:10.420][DEBUG][main] Bootstrap - WELD-ENV-000032: Processing bean archive reference: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
[2018-03-05 10:52:10.420][DEBUG][main] FileSystemBeanArchiveHandler - Handle path: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
[2018-03-05 10:52:10.420][DEBUG][main] FileSystemBeanArchiveHandler - Handle archive file: /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar
[2018-03-05 10:52:10.440][DEBUG][main] Bootstrap - WELD-ENV-000039: Bean archive reference /var/www/netps/logreader/build/libs/log-reader-all-1.0.jar handled by org.jboss.weld.environment.deployment.discovery.File
SystemBeanArchiveHandler@528c868
[2018-03-05 10:52:10.443][DEBUG][main] Bootstrap - WELD-ENV-000024: Archive isolation enabled - creating multiple isolated bean archives if needed
[2018-03-05 10:52:10.446][DEBUG][main] BootstrapTracker - START bootstrap 
[2018-03-05 10:52:10.446][DEBUG][main] BootstrapTracker - START bootstrap > startContainer 
[2018-03-05 10:52:10.454][DEBUG][main] Configuration - WELD-001902: Following configuration was detected and applied: {org.jboss.weld.executor.threadPoolType=COMMON, org.jboss.weld.construction.relaxed=true, org.j
boss.weld.bootstrap.allowOptimizedCleanup=true}
[2018-03-05 10:52:10.455][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > initServices 
[2018-03-05 10:52:10.475][DEBUG][main] Bootstrap - Using Weld modules: []
[2018-03-05 10:52:10.496][DEBUG][main] Bootstrap - Using instantiator: org.jboss.weld.bean.proxy.UnsafeProxyInstantiator
[2018-03-05 10:52:10.510][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > initServices (55 ms)
[2018-03-05 10:52:10.510][INFO ][main] Bootstrap - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
[2018-03-05 10:52:10.537][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > builtinContexts 
[2018-03-05 10:52:10.591][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%ApplicationContext
[2018-03-05 10:52:10.594][DEBUG][main] Reflection - WELD-000601: interface javax.inject.Singleton is missing @Target. Weld will use this annotation, however this may make the application unportable.
[2018-03-05 10:52:10.595][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%SingletonContext
[2018-03-05 10:52:10.597][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundSessionContext
[2018-03-05 10:52:10.599][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundConversationContext
[2018-03-05 10:52:10.600][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%BoundRequestContext
[2018-03-05 10:52:10.600][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%RequestContext
[2018-03-05 10:52:10.602][DEBUG][main] Bootstrap - WELD-000106: Bean: WELD%AbstractBuiltInBean%deployment%DependentContext
[2018-03-05 10:52:10.602][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > builtinContexts (64 ms)
[2018-03-05 10:52:10.605][DEBUG][main] BootstrapTracker - START bootstrap > startContainer > readDeploymentStructure 
[2018-03-05 10:52:10.621][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [javax.enterprise.inject.spi.BeanManager] with qualifiers [@Default]
[2018-03-05 10:52:10.621][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [org.jboss.weld.manager.BeanManagerImpl] with qualifiers [@Default]
[2018-03-05 10:52:10.622][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer > readDeploymentStructure (16 ms)
[2018-03-05 10:52:10.622][DEBUG][main] BootstrapTracker -   END bootstrap > startContainer (176 ms)
[2018-03-05 10:52:10.623][DEBUG][main] BootstrapTracker - START bootstrap > startInitialization 
[2018-03-05 10:52:10.652][DEBUG][main] Bootstrap - WELD-000106: Bean: Extension [class org.jboss.weld.bootstrap.WeldExtension] with qualifiers [@Default]; n/a
[2018-03-05 10:52:10.652][DEBUG][main] Bootstrap - WELD-000168: Extension bean deployed: Extension [class org.jboss.weld.bootstrap.WeldExtension] with qualifiers [@Default]; n/a
[2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Extension [class org.jboss.weld.environment.se.WeldSEBeanRegistrant] with qualifiers [@Default]; jar:file:/var/www/netps/logreader/build/libs/l
og-reader-all-1.0.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998]
[2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000168: Extension bean deployed: Extension [class org.jboss.weld.environment.se.WeldSEBeanRegistrant] with qualifiers [@Default]; jar:file:/var/www/netps/log
reader/build/libs/log-reader-all-1.0.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998]
[2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [javax.enterprise.inject.spi.BeanManager] with qualifiers [@Default]
[2018-03-05 10:52:10.665][DEBUG][main] Bootstrap - WELD-000106: Bean: Built-in Bean [org.jboss.weld.manager.BeanManagerImpl] with qualifiers [@Default]
[2018-03-05 10:52:10.666][DEBUG][main] BootstrapTracker - START bootstrap > startInitialization > BeforeBeanDiscovery 
[2018-03-05 10:52:10.695][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.bootstrap.WeldExtension@d78795 for [BackedAnnotatedType] public @Vetoed @Interceptor 
@ActivateRequestContext @Priority class org.jboss.weld.contexts.activator.ActivateRequestContextInterceptor
[2018-03-05 10:52:10.697][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.bootstrap.WeldExtension@d78795 for [BackedAnnotatedType] public @Vetoed @Interceptor 
@ActivateRequestContext @Priority class org.jboss.weld.contexts.activator.CdiRequestContextActivatorInterceptor
[2018-03-05 10:52:10.701][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Vetoed
 @ApplicationScoped class org.jboss.weld.environment.se.beans.ParametersFactory
[2018-03-05 10:52:10.704][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Decora
tor class org.jboss.weld.environment.se.threading.RunnableDecorator
[2018-03-05 10:52:10.706][DEBUG][main] Bootstrap - WELD-000162: BeforeBeanDiscovery.addAnnotatedType() called by org.jboss.weld.environment.se.WeldSEBeanRegistrant@2cab9998 for [BackedAnnotatedType] public @Vetoed
 @Interceptor @ActivateThreadScope @Priority class org.jboss.weld.environment.se.contexts.activators.ActivateThreadScopeInterceptor
[2018-03-05 10:52:10.706][DEBUG][main] BootstrapTracker -   END bootstrap > startInitialization > BeforeBeanDiscovery (40 ms)
[2018-03-05 10:52:10.799][INFO ][ForkJoinPool.commonPool-worker-15] Bootstrap - WELD-000119: Not generating any bean definitions from org.jboss.weld.servlet.api.helpers.ForwardingServletListener because of underly
ing class loading error: Type javax.servlet.ServletContextListener not found.  If this is unexpected, enable DEBUG logging to see the full error.
[2018-03-05 10:52:10.800][DEBUG][ForkJoinPool.commonPool-worker-15] Bootstrap - Catching
org.jboss.weld.resources.spi.ResourceLoadingException: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
    at org.jboss.weld.environment.deployment.WeldResourceLoader.classForName(WeldResourceLoader.java:44) ~[log-reader-all-1.0.jar:?]
    at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadClass(AnnotatedTypeLoader.java:82) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:62) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:87) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:55) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:52) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62) [log-reader-all-1.0.jar:?]
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55) [log-reader-all-1.0.jar:?]
    at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431) [?:?]
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:283) [?:?]
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603) [?:?]
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175) [?:?]

看起来这不是与操作系统相关的问题,而是 gradle-weld 之间的更多问题:就像@siliarus 写的那样。

4

1 回答 1

1

好的,

所以这里的问题在于 JAR 地狱,而不仅仅是 WELD。我要做的是从头开始项目,每次添加任何依赖于项目的东西时,我都会创建 uber JAR。这将告诉我哪个部分最有问题,并允许我更准确地跟踪问题。

于 2018-03-23T08:03:41.663 回答