what the console prints, I am trying to run a java web application on netbeans and I do not understand very well why it gives me that error.
Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.4/xstream-1.4.4.jar (483 kB at 33 kB/s)
Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.ExceptionInInitializerError
at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
while locating org.apache.maven.plugin.war.WarMojo
1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException (InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1053)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project primera_web: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Unable to load the mojo ‘war’ in the plugin ‘org.apache.maven.plugins:maven-war-plugin:2.3’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null
realm = plugin>org.apache.maven.plugins:maven-war-plugin:2.3
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/HP/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.3/maven-war-plugin-2.3.jar
urls[1] = file:/C:/Users/HP/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar
urls[2] = file:/C:/Users/HP/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar
urls[3] = file:/C:/Users/HP/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
: ExceptionInInitializerError: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @5c82031b
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
file 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>primera_web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>primera_web</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
suggestions to solve the problem ??
asked Apr 2, 2021 at 14:08
2
I had the same problem. I am using Eclipse Jun 2021 release. The problem got resolved after manually configuring one of the recent war plug-ins in POM.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
answered Jul 11, 2021 at 16:21
VikramVikram
8814 silver badges8 bronze badges
4
I experienced the same issue after upgrading from JDK 1.8 to JDK 17 and I solved it by upgrading the plugin version.
Before:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
After:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
Laurel
5,98514 gold badges31 silver badges58 bronze badges
answered Jun 13, 2022 at 7:44
0
if you want to deploy the war. what worked for me is both
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
and
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
Please note the versions.
Dharman♦
31.1k25 gold badges87 silver badges137 bronze badges
answered Aug 24, 2021 at 21:25
You can fix it by changing the JDK in your projects to JDK 14. Left-click on your project and go to properties -> build -> compile . Change the JDK to version 14. If you don’t have JDK 14, you can manage it there by clicking Manage Java Platforms. The download of the JDK is here.
answered Apr 11, 2021 at 12:22
PhillipPhillip
871 silver badge12 bronze badges
Your pom.xml
like this will work.
<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>com.example</groupId>
<artifactId>vysample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>vysample-1.0-SNAPSHOT</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>9.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Focus at
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
answered Jul 13, 2022 at 13:44
Vy DoVy Do
46.9k60 gold badges215 silver badges318 bronze badges
I resolved this error by adding following part in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
apart from that i added maven configuration properties
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
and here is my entire file as following
<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>com.groupId</groupId>
<artifactId>com.artifactId</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
answered Jan 12 at 6:58
ParameshwarParameshwar
8568 silver badges16 bronze badges
My problem got resolved after manually configuring war plug-in in POM.xml and then do clean install
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
Then in the terminal, do a clean install, as:
mvn clean install
This should give you the war file (javaj22ee.war) status like:
[INFO] Building war: /Users/my_proj/java/javaj2ee/target/javaj2ee.war
[INFO]
[INFO] --- install:3.1.1:install (default-install) @ javaj2ee ---
[INFO] Installing /Users/my_proj/java/javaj2ee/pom.xml to
/Users/.m2/repository/org/example/javaj2ee/1.0-SNAPSHOT/javaj2ee-1.0-
SNAPSHOT.pom
[INFO] Installing /Users/my_proj/java/javaj2ee/target/javaj2ee.war to
/Users/.m2/repository/org/example/javaj2ee/1.0-SNAPSHOT/javaj2ee-1.0-
SNAPSHOT.war
[INFO] -----------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -----------------------------------------------------------------
[INFO] Total time: 8.506 s
[INFO] Finished at: 2023-09-04T18:37:31+05:30
[INFO] -----------------------------------------------------------------
answered Sep 4 at 13:20
VidzVidz
5551 gold badge6 silver badges16 bronze badges
I have solved this by simply going in the Jenkins global tool configuration and changing the path of JDK to /usr/local/Cellar/openjdk@11/11.0.10
.
Previously it was /usr/local/Cellar/openjdk/16.0.1
in my local machine MAC.
Click here to see
This was the error :
Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar (431 kB at 529 kB/s)
11:52:49 [WARNING] Error injecting: org.apache.maven.plugin.war.WarMojo
11:52:49 com.google.inject.ProvisionException: Unable to provision, see the following errors:
11:52:49
11:52:49 1) Error injecting constructor, java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties
11:52:49 at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
Sanket Singh
1,2661 gold badge10 silver badges26 bronze badges
answered Jul 18, 2021 at 6:40
Eclipse 2021-06 release by default JDK will be set to 16. So changed to your preferred JDK version. or configure your default JDK to run
maven-war-plugin:3.0.0:war (default-war) @ projectname
--- [WARNING] Error injecting: org.apache.maven.plugins.war.WarMojo
com.google.inject.ProvisionException: Unable to provision,
see the following errors: 1) Error injecting constructor,
java.lang.ExceptionInInitializerError
at org.apache.maven.plugins.war.WarMojo.<init>(Unknown Source)
answered Jul 31, 2021 at 17:34
Nɪsʜᴀɴᴛʜ ॐNɪsʜᴀɴᴛʜ ॐ
2,7764 gold badges33 silver badges57 bronze badges
I had this exact same issue. After updating the POM file, I needed to delete my .m2/repository
folder before running mvn install
for the project.
answered May 19, 2022 at 16:54
I had the same problems and I resolved changed the version 2.3 to 3.3.1
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
enter image description here
enter image description here
answered May 27, 2022 at 22:41
Problem has been resolved by stopping the Tomcat server
sudo systemctl stop tomcat
so as to allow Netbeans to run it. If the server is already running when Netbeans tries to deploy an app Netbeans will display the delopy failed message.
answered Nov 13, 2022 at 23:34
hi @amitmaurya1024
I’m facing this issue when i run this cmd «yarn run watch:venia» in windows
kindly help me in resolving this issue Thanks
Emitting no ServiceWorker in development mode.
i 「wdm」: wait until bundle finished:
i 「wds」: Project is running at http://0.0.0.0:10000/
i 「wds」: webpack output is served from /
17% [0] building 60/65 modules 5 active C:\Users\jai.narayan\eclipse-workspace\PWA\pwa\pwa-studio\node_modules\html-entities\lib\index.js
warn — You have enabled the JIT engine which is currently in preview.
warn — Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
Child client-config:
2112 modules
ERROR in (webpack)-inject-plugin/dist/webpack-inject-plugin.loader.js?id=webpack-inject-module-2
Module not found: Error: Can't resolve 'C:Usersjai.narayaneclipse-workspacePWApwa-studiopackages
enia-concepten_US.json' in 'C:\Users\jai.narayan\eclipse-workspace\PWA\pwa-studio\packages\venia-concept'
i 「wdm」: Failed to compile.
I’m experiencing the same issue when combined with file-loader
+ oneOf
.
Simplified repro on webpack 5, modified example/webpack.config.js
to:
const InjectPlugin = require('..').default; module.exports = { entry: './entry.js', mode: 'development', plugins: [ new InjectPlugin(() => `console.log('hello world');`), new InjectPlugin(() => `console.log('second injected code');`) ], module: { rules: [ { oneOf: [ { exclude: [/webpack-inject/], loader: require.resolve('file-loader'), } ] } ] } };
Seems like now its trying to use file-loader
on webpack-inject-plugin.loader.js?id=webpack-inject-module-1
. Tried excluding it but haven’t been able to get it to work yet.
Will try to investigate a bit more, lmk if you have any ideas @adierkens 🙏
Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to run my java application but I am facing following error Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision in Java. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
Contents
- How This Error Occurs ?
- How To Solve Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision Error ?
- Solution 1: configure war plugin
- Solution 2: Change JDK for your project
- Summary
How This Error Occurs ?
I am trying to run my java application but I am facing following error.
Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision, see the following errors:
Error injecting constructor, java.lang.ExceptionInInitializerError at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source) while locating org.apache.maven.plugin.war.WarMojo
-
How To Solve Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision Error ?
To Solve Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision Error Just configure war plugin in your POM.xml. Second one is Just Change your JDK for particular Project. Follow this step. First of all Left-click on your project.Then, Select Properties.now, Select Build.Select compile.Change the JDK to version 14.If you don’t have JDK 14 then The download of the JDK is here.Now, Your issue will be fix.
-
Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision
To Solve Error injecting: org.apache.maven.plugin.war.WarMojo com.google.inject.ProvisionException: Unable to provision Error Just configure war plugin in your POM.xml. Second one is Just Change your JDK for particular Project. Follow this step. First of all Left-click on your project.Then, Select Properties.now, Select Build.Select compile.Change the JDK to version 14.If you don’t have JDK 14 then The download of the JDK is here.Now, Your issue will be fix.
Solution 1: configure war plugin
Just configure war plugin in your POM.xml like this.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>
Solution 2: Change JDK for your project
Just Change your JDK for particular Project. Follow this step.
- First of all Left-click on your project.
- Then, Select Properties.
- now, Select Build.
- Select compile.
- Change the JDK to version 14.
- If you don’t have JDK 14 then The download of the JDK is here.
- Now, Your issue will be fix.
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
- java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class
Issue
I created a controller
plugin to be used global in every component, but I can’t make it work with Vue 3 + TypeScript + Composition API I get a TypeScript error
ui/plugins/controllers.ts
import { App } from 'vue'
import { provider, IProvider } from '@/core/presentation/provider'
export default {
install: (app: App) => {
const controllers: IProvider = provider()
app.provide('controllers', controllers)
}
}
main.ts
import { createApp } from 'vue'
import { controllers } from './ui'
createApp(App)
.use(controllers)
.mount('#app')
@/core/presentation/provider/provider.ts
import { UserController } from '../controllers'
import { IProvider } from './provider.types'
export const provider = (): IProvider => ({
users: new UserController()
})
ui/views/Component.vue
import { onMounted, ref, inject, defineComponent } from 'vue'
export default defineComponent({
setup() {
const controllers = inject('controllers')
const user = ref()
const getUser = async () => {
const result = await controllers.users.getById(1)
if (result) {
user.value = result.toJson()
}
}
onMounted(getUser)
return {
user,
getUser
}
}
})
Here I get a typescript error when I try to use the controller at this line
const result = await controllers.users.getById(1)
Error:
const controllers: unknown Object is of type 'unknown'.Vetur(2571)
If I set the type with my interface like this I get another typescript error
import { IProvider } from '@/core'
...
const controllers: IProvider = inject('controllers')
Error:
type 'IProvider | undefined' is not assignable to type 'IProvider'. Type 'undefined' is not assignable to type 'IProvider'.Vetur(2322)
I can only make it work like this but I think it’s weird:
const controllers: IProvider | undefined = inject('controllers')
...
const result = await controllers?.users.getById(1)
Solution
I managed to solve my problem with post Type-safe Vue.js Injections
One thing to note is that the inject function produces the resolved type in union with
undefined
. This is because there is the possibility that the injection is not resolved. It’s up to you how you want to handle it.
So to deal with undefined
I followed his advice and create an injectStrict
function. Here is my final code:
Component.vue
import { IProvider } from '@/core'
import { injectStrict } from '@/ui/utils'
import { onMounted, ref, defineComponent } from 'vue'
export default defineComponent({
setup() {
const controllers: IProvider = injectStrict('controllers')
const user = ref()
const getUser = async () => {
const result = await controllers.users.getById(1)
if (result) {
user.value = result.toObj()
}
}
onMounted(getUser)
return {
user,
getUser
}
}
})
@/utils/injections.ts
import { inject } from 'vue'
function injectStrict<T>(key: string, fallback?: T) {
const resolved = inject(key, fallback)
if (!resolved) {
throw new Error(`Could not resolve ${key}`)
}
return resolved
}
export { injectStrict }
Answered By – ocordova
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0