I´m trying to deploy my maven ear project but I´m getting this error while doing, mvn install in the pom proyect(my IDE is eclipse)
C:\temp\eat>mvn clean install -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] eat application
[INFO] eat utility module
[INFO] eat EJB module
[INFO] eat Web module
[INFO] eat EAR module
[INFO] eat integration tests module
[INFO] ------------------------------------------------------------------------
[INFO] Building eat application
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
-----------------------------------------------------
this realm = app0.child-container[org.apache.maven.plugins:maven-site-plugin:2.0
-beta-7]
urls[0] = file:/C:/Users/luis.cabezas/.m2/repository/org/apache/maven/plugins/ma
ven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.jar
urls[1] = file:/C:/Users/luis.cabezas/.m2/repository/org/codehaus/plexus/plexus-
utils/1.1/plexus-utils-1.1.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry#a6c57a42
import: org.codehaus.classworlds.Entry#12f43f3b
import: org.codehaus.classworlds.Entry#20025374
import: org.codehaus.classworlds.Entry#f8e44ca4
import: org.codehaus.classworlds.Entry#92758522
import: org.codehaus.classworlds.Entry#ebf2705b
import: org.codehaus.classworlds.Entry#bb25e54
import: org.codehaus.classworlds.Entry#bece5185
import: org.codehaus.classworlds.Entry#3fee8e37
import: org.codehaus.classworlds.Entry#3fee19d8
this realm = plexus.core
urls[0] = file:/C:/apache-maven-2.2.1/bin/../lib/maven-2.2.1-uber.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry#a6c57a42
import: org.codehaus.classworlds.Entry#12f43f3b
import: org.codehaus.classworlds.Entry#20025374
import: org.codehaus.classworlds.Entry#f8e44ca4
import: org.codehaus.classworlds.Entry#92758522
import: org.codehaus.classworlds.Entry#ebf2705b
import: org.codehaus.classworlds.Entry#bb25e54
import: org.codehaus.classworlds.Entry#bece5185
import: org.codehaus.classworlds.Entry#3fee8e37
import: org.codehaus.classworlds.Entry#3fee19d8
----------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager executing goal 'org.apache.maven.plu
gins:maven-site-plugin:2.0-beta-7:attach-descriptor': Unable to load the mojo 'o
rg.apache.maven.plugins:maven-site-plugin:2.0-beta-7:attach-descriptor' in the p
lugin 'org.apache.maven.plugins:maven-site-plugin'. A required class is missing:
org/apache/maven/doxia/tools/SiteToolException
org.apache.maven.doxia.tools.SiteToolException
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the pl
ugin manager executing goal 'org.apache.maven.plugins:maven-site-plugin:2.0-beta
-7:attach-descriptor': Unable to load the mojo 'org.apache.maven.plugins:maven-s
ite-plugin:2.0-beta-7:attach-descriptor' in the plugin 'org.apache.maven.plugins
:maven-site-plugin'. A required class is missing: org/apache/maven/doxia/tools/S
iteToolException
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:698)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginManagerException: Unable to load the mo
jo 'org.apache.maven.plugins:maven-site-plugin:2.0-beta-7:attach-descriptor' in
the plugin 'org.apache.maven.plugins:maven-site-plugin'. A required class is mis
sing: org/apache/maven/doxia/tools/SiteToolException
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(Defaul
tPluginManager.java:669)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:468)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:694)
... 17 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupExc
eption: Unable to lookup component 'org.apache.maven.plugin.Mojoorg.apache.maven
.plugins:maven-site-plugin:2.0-beta-7:attach-descriptor', it could not be created at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContai
ner.java:335)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:440)
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(Defaul
tPluginManager.java:652)
... 19 more
Caused by: org.codehaus.plexus.component.factory.ComponentInstantiationException
: Could not instanciate component: role: 'null', implementation: 'org.apache.mav
en.plugins.site.SiteDescriptorAttachMojo'
at org.codehaus.plexus.component.factory.java.JavaComponentFactory.makeE
xception(JavaComponentFactory.java:77)
at org.codehaus.plexus.component.factory.java.JavaComponentFactory.newIn
stance(JavaComponentFactory.java:62)
at org.codehaus.plexus.DefaultPlexusContainer.createComponentInstance(De
faultPlexusContainer.java:1464)
at org.codehaus.plexus.component.manager.AbstractComponentManager.create
ComponentInstance(AbstractComponentManager.java:93)
at org.codehaus.plexus.component.manager.PerLookupComponentManager.getCo
mponent(PerLookupComponentManager.java:48)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContai
ner.java:331)
... 21 more
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/doxia/tools/SiteTool
Exception
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at org.codehaus.plexus.component.factory.java.JavaComponentFactory.newIn
stance(JavaComponentFactory.java:44)
... 25 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.doxia.tools.SiteTo
olException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassL
oader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassReal
m.java:255)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassReal
m.java:274)
at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.
java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 31 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Mar 04 16:01:47 CET 2013
[INFO] Final Memory: 4M/15M
this is my parent.pom
<modelVersion>4.0.0</modelVersion>
<groupId>com.eat</groupId>
<artifactId>eat</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>eat application</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2.SP1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<excludedGroups>${tests.excludedGroups}</excludedGroups>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>eat-util</module>
<module>eat-ejb</module>
<module>eat-web</module>
<module>eat-ear</module>
<module>eat-tests</module>
</modules>
ear.pom
<parent>
<artifactId>eat</artifactId>
<groupId>com.eat</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.eat</groupId>
<artifactId>eat-ear</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>ear</packaging>
<name>eat EAR module</name>
<build>
<finalName>eat-ear</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceExcludes>**/application.xml, **/jboss-app.xml</earSourceExcludes>
<generateApplicationXml>true</generateApplicationXml>
<jboss>
<version>4.2.3</version>
<loader-repository>seam.jboss.org:loader=eat-ear.ear</loader-repository>
</jboss>
<modules>
<webModule>
<groupId>com.eat</groupId>
<artifactId>eat-web</artifactId>
<contextRoot>/eat</contextRoot>
<bundleFileName>eat-web.war</bundleFileName>
</webModule>
<ejbModule>
<groupId>com.eat</groupId>
<artifactId>eat-ejb</artifactId>
<bundleFileName>eat-ejb.jar</bundleFileName>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
war.pom
<parent>
<artifactId>eat</artifactId>
<groupId>com.eat</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.eat</groupId>
<artifactId>eat-web</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>eat Web module</name>
ejb.pom
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>eat</artifactId>
<groupId>com.eat</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.eat</groupId>
<artifactId>eat-ejb</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>ejb</packaging>
<name>eat EJB module</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.2</version>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
I don´t know if this is enough information. if is not, tell me.
Thanks.
Related
Am sorry as this is my first question in stack-overflow so i hope i can explain the problem correctly...
Am using spring boot 3.0.1
and GraalVM CE 22.3.0
and spring cloud 2022.0.0
Am trying to build native-image of my service that using netflix eureka client.
it shows me the following error when i run my native service:
2023-01-01T16:33:42.098+08:00 INFO 16106 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-01-01T16:33:42.099+08:00 ERROR 16106 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeDiscoveryClient': Unsatisfied dependency expressed through method 'compositeDiscov at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:351) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:271) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:206) ~[na:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[order-service:6.0.3]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[order-service:6.0.3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[order-service:6.0.3]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[order-service:3.0.1]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[order-service:3.0.1]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[order-service:3.0.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[order-service:3.0.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[order-service:3.0.1]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[order-service:3.0.1]
at com.alammar.orderservice.OrderServiceApplication.main(OrderServiceApplication.java:15) ~[order-service:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'discoveryClient': Unsatisfied dependency expressed through method 'discoveryClient' parameter 0: No qualifying bean of type 'com.netflix.discovery.EurekaClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:351) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArguments(BeanInstanceSupplier.java:271) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:206) ~[na:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1225) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1210) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1157) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[order-service:6.0.3]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1621) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1585) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1476) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1363) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[order-service:6.0.3]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:334) ~[na:na]
... 21 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.netflix.discovery.EurekaClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1812) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1371) ~[order-service:6.0.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[order-service:6.0.3]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.resolveArgument(BeanInstanceSupplier.java:334) ~[na:na]
... 39 common frames omitted
here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.alammar</groupId>
<artifactId>order-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>order-service</name>
<description>Order service</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2022.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-lra-starter</artifactId>
<!-- use the same version as your Camel core version -->
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-kafka-starter</artifactId>
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-undertow-starter</artifactId>
<!-- use the same version as your Camel core version -->
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<repositories>
<repository>
<id>netflix-candidates</id>
<name>Netflix Candidates</name>
<url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
i was expecting to run successfully after i run my native service image
solved by adding spring.cloud.refresh.enabled=false
I am trying to test a Hello World example of BPMN on Eclipse. I have followed the section "24.1. jBPM Eclipse Plugin" on https://docs.jbpm.org/7.67.0.Final/jbpm-docs/html_single where I select to use a simple "Hello World" process and to include a JUnit test class that will be used to test the process.
However, I am facing an error when I am running the ProcessTest.java as a JUnit Test.
Here is the full error :
java.lang.ExceptionInInitializerError
at org.drools.dynamic.DynamicServiceRegistrySupplier.get(DynamicServiceRegistrySupplier.java:32)
at org.drools.dynamic.DynamicServiceRegistrySupplier.get(DynamicServiceRegistrySupplier.java:23)
at org.kie.api.internal.utils.ServiceRegistry$Impl.getServiceRegistry(ServiceRegistry.java:90)
at org.kie.api.internal.utils.ServiceRegistry$ServiceRegistryHolder.<clinit>(ServiceRegistry.java:49)
at org.kie.api.internal.utils.ServiceRegistry.getInstance(ServiceRegistry.java:41)
at org.kie.api.internal.utils.ServiceRegistry.getService(ServiceRegistry.java:37)
at org.kie.internal.builder.KnowledgeBuilderFactory$FactoryServiceHolder.<clinit>(KnowledgeBuilderFactory.java:39)
at org.kie.internal.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:52)
at org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment.<init>(SimpleRuntimeEnvironment.java:99)
at org.jbpm.runtime.manager.impl.SimpleRuntimeEnvironment.<init>(SimpleRuntimeEnvironment.java:93)
at org.jbpm.runtime.manager.impl.RuntimeEnvironmentBuilder.<init>(RuntimeEnvironmentBuilder.java:84)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.kie.api.runtime.manager.RuntimeEnvironmentBuilder$Factory.<clinit>(RuntimeEnvironmentBuilder.java:61)
at org.jbpm.test.JbpmJUnitBaseTestCase.createRuntimeManager(JbpmJUnitBaseTestCase.java:351)
at org.jbpm.test.JbpmJUnitBaseTestCase.createRuntimeManager(JbpmJUnitBaseTestCase.java:293)
at org.jbpm.test.JbpmJUnitBaseTestCase.createRuntimeManager(JbpmJUnitBaseTestCase.java:275)
at com.sample.ProcessTest.testProcess(ProcessTest.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.RuntimeException: Unable to build kie service url = jar:file:/C:/Users/lucie/.m2/repository/org/kie/kie-internal/7.71.0.Final/kie-internal-7.71.0.Final.jar!/META-INF/kie/kie-internal/kie.conf
at org.kie.api.internal.utils.ServiceDiscoveryImpl.registerConfs(ServiceDiscoveryImpl.java:127)
at org.kie.api.internal.utils.ServiceDiscoveryImpl.lambda$getServices$1(ServiceDiscoveryImpl.java:105)
at java.util.Optional.ifPresent(Unknown Source)
at org.kie.api.internal.utils.ServiceDiscoveryImpl.getServices(ServiceDiscoveryImpl.java:103)
at org.kie.api.internal.utils.ServiceRegistry$Impl.<init>(ServiceRegistry.java:62)
at org.drools.dynamic.DynamicServiceRegistrySupplier$LazyHolder.<clinit>(DynamicServiceRegistrySupplier.java:27)
... 51 more
Caused by: java.lang.RuntimeException: There already exists an implementation for service org.kie.api.internal.assembler.KieAssemblers with same priority 0
at org.kie.api.internal.utils.ServiceDiscoveryImpl$PriorityMap.put(ServiceDiscoveryImpl.java:244)
at org.kie.api.internal.utils.ServiceDiscoveryImpl.processKieService(ServiceDiscoveryImpl.java:146)
at org.kie.api.internal.utils.ServiceDiscoveryImpl.registerConfs(ServiceDiscoveryImpl.java:123)
... 56 more
Here is my pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>msc</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-test</artifactId>
<version>7.71.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-runtime-manager</artifactId>
<version>7.71.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
<version>7.71.0.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.27.Final</version>
</dependency>
</dependencies>
</project>
I have tried to clear the Maven cache but the error is still here. I don't know how I could try to resolve it, so I was wondering if anyone has an idea ? Thanks a lot for the help !
Here is the ProcessTest.java :
package com.sample;
import org.jbpm.test.JbpmJUnitBaseTestCase;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.RuntimeEngine;
import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.api.runtime.process.ProcessInstance;
/**
* This is a sample file to test a process.
*/
public class ProcessTest extends JbpmJUnitBaseTestCase {
#SuppressWarnings("deprecation")
#Test
public void testProcess() {
RuntimeManager manager = createRuntimeManager("sample.bpmn");
RuntimeEngine engine = getRuntimeEngine(null);
KieSession ksession = engine.getKieSession();
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello");
// check whether the process instance has completed successfully
assertProcessInstanceCompleted(processInstance.getId(), ksession);
assertNodeTriggered(processInstance.getId(), "Hello");
manager.disposeRuntimeEngine(engine);
manager.close();
}
}
I tried to start scala application in jar.
The following code:
object Starter {
def main(args: Array[String]): Unit = {
args.foreach(path => {
val (minX, maxX, minY, maxY) = MainStage.run(path)
println(minX)
println(maxX)
println(minY)
println(maxY)
})
}
}
induces an error on same computer (though it works inside Intellij Idea):
$ java -cp foo-1.0-SNAPSHOT.jar ogr.bar.system.Starter
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1
at ogr.bar.system.Starter.main(Starter.scala)
Caused by: java.lang.ClassNotFoundException: scala.Function1
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Then I tried to make a simple hello world application:
object Starter {
def main(args: Array[String]): Unit = {
println("hello world")
//args.foreach(path => {
// val (minX, maxX, minY, maxY) = MainStage.run(path)
// println(minX)
// println(maxX)
// println(minY)
// println(maxY)
//})
}
}
And it raises exception:
$ java -cp foo-1.0-SNAPSHOT.jar ogr.bar.system.Starter
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
at ogr.bar.system.Starter$.main(Starter.scala:7)
at ogr.bar.system.Starter.main(Starter.scala)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
The following is a fragment of my pom.xml
<properties>
<javaVersion>1.8</javaVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
</dependency>
<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-xml_2.11</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${javaVersion}</source>
<target>${javaVersion}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>src/main/scala</sourceDir>
<testSourceDir>src/test/scala</testSourceDir>
</configuration>
</plugin>
</plugins>
</build>
What should I do to make my app work?
The problem is that you probably build a thin version of your application.
It does not contain all dependencies, like scala-library. Thus the error
java.lang.NoClassDefFoundError: scala/Predef$
Check this on how to do build fat jars in maven.
After upgrading the Jasper Version to 5.5.0, I am getting error while compiling the report from server/Jenkins. In my local machine it is working fine. Any idea what can be the reason. Below is the log:
[WARNING] POM for 'commons-logging:commons-logging:pom:99.0-does-not-exist:runtime' is invalid.
Its dependencies (if any) will NOT be available to the current build.
[INFO] [jasperreports:compile-reports {execution: default}]
[INFO] Compiling 29 report design files.
[INFO] Compiling report file: interfaceConfiguration\processConf.jrxml
[FATAL ERROR] org.codehaus.mojo.jasperreports.JasperReportsMojo#execute() caused a linkage error (java.lang.NoClassDefFoundError) and may be out-of-date. Check the realms:
[FATAL ERROR] Plugin realm = app0.child-container[org.codehaus.mojo:jasperreports-maven-plugin:1.0-beta-2]
urls[0] = file:/d:/maven/maven-2.0.9/org/codehaus/mojo/jasperreports-maven-plugin/1.0-beta-2/jasperreports-maven-plugin-1.0-beta-2.jar
urls[1] = file:/d:/maven/maven-2.0.9/net/sf/jasperreports/jasperreports/5.5.0/jasperreports-5.5.0.jar
urls[2] = file:/d:/maven/maven-2.0.9/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar
urls[3] = file:/d:/maven/maven-2.0.9/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
urls[4] = file:/d:/maven/maven-2.0.9/commons-collections/commons-collections/2.1/commons-collections-2.1.jar
urls[5] = file:/d:/maven/maven-2.0.9/commons-digester/commons-digester/2.1/commons-digester-2.1.jar
urls[6] = file:/d:/maven/maven-2.0.9/com/lowagie/itext/2.1.7.js2/itext-2.1.7.js2.jar
urls[7] = file:/d:/maven/maven-2.0.9/jfree/jcommon/1.0.15/jcommon-1.0.15.jar
urls[8] = file:/d:/maven/maven-2.0.9/jfree/jfreechart/1.0.12/jfreechart-1.0.12.jar
urls[9] = file:/d:/maven/maven-2.0.9/xml-apis/xml-apis/1.3.02/xml-apis-1.3.02.jar
urls[10] = file:/d:/maven/maven-2.0.9/eclipse/jdtcore/3.1.0/jdtcore-3.1.0.jar
urls[11] = file:/d:/maven/maven-2.0.9/org/codehaus/castor/castor/1.2/castor-1.2.jar
urls[12] = file:/d:/maven/maven-2.0.9/com/fasterxml/jackson/core/jackson-core/2.1.4/jackson-core-2.1.4.jar
urls[13] = file:/d:/maven/maven-2.0.9/com/fasterxml/jackson/core/jackson-databind/2.1.4/jackson-databind-2.1.4.jar
urls[14] = file:/d:/maven/maven-2.0.9/com/fasterxml/jackson/core/jackson-annotations/2.1.4/jackson-annotations-2.1.4.jar
urls[15] = file:/d:/maven/maven-2.0.9/jasperreports/jasperreports/1.2.0/jasperreports-1.2.0.jar
urls[16] = file:/d:/maven/maven-2.0.9/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
urls[17] = file:/d:/maven/maven-2.0.9/org/codehaus/plexus/plexus-compiler-api/1.5.3/plexus-compiler-api-1.5.3.jar
[FATAL ERROR] Container realm = plexus.core
urls[0] = file:/C:/APPS/DCSCM/tool/Maven2.2.1/lib/maven-2.2.1-uber.jar
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] javax/servlet/ServletOutputStream
javax.servlet.ServletOutputStream
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
at net.sf.jasperreports.web.util.WebResourceHandlersExtensionRegistryFactory.<clinit>(WebResourceHandlersExtensionRegistryFactory.java:47)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)
at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:53)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.instantiateRegistry(DefaultExtensionsRegistry.java:237)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:214)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.loadRegistries(DefaultExtensionsRegistry.java:162)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getRegistries(DefaultExtensionsRegistry.java:133)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:105)
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:246)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.findBundles(ComponentsEnvironment.java:119)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getCachedBundles(ComponentsEnvironment.java:109)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getBundles(ComponentsEnvironment.java:97)
at net.sf.jasperreports.engine.component.ComponentsEnvironment.getComponentBundles(ComponentsEnvironment.java:179)
at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.getSchemaLocations(JRReportSaxParserFactory.java:84)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.configureParser(BaseSaxParserFactory.java:131)
at net.sf.jasperreports.engine.xml.BaseSaxParserFactory.createParser(BaseSaxParserFactory.java:94)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1439)
at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1415)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:254)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:210)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:185)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:176)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:137)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:438)
at org.codehaus.mojo.jasperreports.JasperReportsMojo.compile(JasperReportsMojo.java:249)
at org.codehaus.mojo.jasperreports.JasperReportsMojo.execute(JasperReportsMojo.java:187)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletOutputStream
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 48 more
Try adding the servlet API as a plugin dependency. For example:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<dependencies>
<!--note this must be repeated here to pick up correct xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</plugin>
I'm having issues with EJB 3.1 singletons. I created a simple project to see if I could even get them to instantiate correctly, however, due to a long Glassfish 3.1.2.2 exception, it looks like I'm doing starting something off wrong.
I'm using maven to compile this into a WAR (with no web.xml descriptor). I'm using jax-rs w/ Jersey to handle rest calls.
It looks like I can't instantiate SingletonA (it fails when I try to deploy the app). SingletonB isn't injected/created by the time the method marked with #PostConstruct is called.
Any help on this would be greatly appreciated.
Here's my POM
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyGroup</groupId>
<artifactId>myartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>myproject</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
</dependencies>
Here is RestApp
package main;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
#ApplicationPath("/rest/")
public class RestApp extends Application {
}
Here is my SingletonA
package main;
import javax.annotation.PostConstruct;
import javax.ejb.DependsOn;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
#Singleton
#Startup
#DependsOn("SingletonB")
public class SingletonA {
#Inject SingletonB sb;
#PostConstruct
public void init()
{
System.out.println("\n\n>In SingletonA's startup\n");
sb.doSomethingCool();
}
public String test()
{
return sb.getIt();
}
}
Here is SingletonB
package main;
import javax.ejb.Singleton;
#Singleton
public class SingletonB {
public void doSomethingCool()
{
System.out.println("\n\n\n>>Singleton B did something cool!\n\n\n");
}
public String getIt()
{
return "my string";
}
}
Rest Service:
package main;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
#Path("")
#Stateless
public class RestSvc {
#Inject SingletonA sa;
#Path("/get")
#GET
public String asdf()
{
return sa.test();
}
}
And finally here's the stacktrace from the server:
[#|2012-12-07T10:21:42.934-0700|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=156;_ThreadName=Thread-2;|Exception while loading the app : javax.ejb.CreateException: Initialization failed for Singleton SingletonA
javax.ejb.CreateException: Initialization failed for Singleton SingletonA
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:547)
at com.sun.ejb.containers.AbstractSingletonContainer.access$100(AbstractSingletonContainer.java:79)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:719)
at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:451)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:216)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:177)
at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:155)
at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:177)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207)
at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
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:722)
Caused by: java.lang.NullPointerException
at main.SingletonA.init(SingletonA.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1009)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:113)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:138)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:538)
... 62 more
|#]
If your EJBs are injected using #EJB, but are not using #Inject, it probably means you forgot to add a beans.xml file (even empty), in the WEB-INF directory. See http://docs.oracle.com/javaee/6/tutorial/doc/gjbnz.html.
The answer was in the pom dependencies. I couldn't give anything more than speculation why this fixed it, but it did. If someone knows why this worked, please leave a comment why.
Here's my new POM file (I changed the dependencies. Removed the javaee-api v6 and used glassfish javax.ejb instead.
There is no web.xml or beans.xml in this project (I had read that with EE 6, these files were optional)
I couldn't use #Inject anymore, so all my injections were changed to #EJB. With this I was able to successfully instantiate both singletons, and inject them without issue.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyGroup</groupId>
<artifactId>myartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>myproject</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>3.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>