maven-replacer-plugin throws [ERROR] Illegal group reference - java

I use maven replacer plugin to replace some of the json in swagger.json file. This configuration works on other project, done in java 8.
This project is in java 11 and the same configuration, with same regex, doesn't work. Regex needs to match "paths" : {.
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/${project.artifactId}-${project.version}/public/docs/swagger.json</file>
<replacements>
<replacement>
<token>"paths"+\ \:\ \{</token>
<valueFile>${project.basedir}/src/main/resources/swagger/tokenEndpointsPaths.json
</valueFile>
</replacement>
</configuration>
</plugin>
This is error log:
[ERROR] Failed to execute goal com.google.code.maven-replacer-plugin:replacer:1.5.3:replace (default) on project emisiawire-fire-spring-webmvc: Illegal group reference -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.code.maven-replacer-plugin:replacer:1.5.3:replace (default) on project emisiawire-fire-spring-webmvc: Illegal group reference
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Illegal group reference
at com.google.code.maven_replacer_plugin.ReplacerMojo.execute(ReplacerMojo.java:401)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.IllegalArgumentException: Illegal group reference
at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1068)
at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:998)
at java.base/java.util.regex.Matcher.replaceAll(Matcher.java:1182)
at com.google.code.maven_replacer_plugin.TokenReplacer.replaceRegex(TokenReplacer.java:24)
at com.google.code.maven_replacer_plugin.TokenReplacer.replace(TokenReplacer.java:11)
at com.google.code.maven_replacer_plugin.ReplacementProcessor.replaceContent(ReplacementProcessor.java:35)
at com.google.code.maven_replacer_plugin.ReplacementProcessor.replace(ReplacementProcessor.java:23)
at com.google.code.maven_replacer_plugin.ReplacerMojo.replaceContents(ReplacerMojo.java:454)
at com.google.code.maven_replacer_plugin.ReplacerMojo.execute(ReplacerMojo.java:391)
... 22 more
When I use only "paths" : { inside token tabs, then nothing gets replaced.

I found and solved the problem. Regex inside tags was okay (at least regex in example from my question, I haven't tried the other variations after I fixed the problem, probably all of them works). The problem was $ sign inside file I was using for replacement (in my example tokenEndpointsPaths.json contained $ inside). I just used \ to escape char $ and that solved it.

you can replace the regex like so :
<token>"paths"+\ \:\ \{</token>
^ ^ ^ // you have anecassary characters here
By this one :
<token>%regex["paths" : \{]</token>
check the regex demo :
for more details check the documentation, how to use regex in pom :
https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
regex demo

Related

Enforcer rules are getting failed using maven plugin

I have pom.xml with below plugin containing enforcement rule.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<banVersionDeps implementation="com.atlassian.maven.enforcer.BanVersionDeps">
<bannedDependencyVersionRegexp>(?i)^.*-(rc|m)-?[0-9]+(-.+)?$</bannedDependencyVersionRegexp>
<noFailReactorVersionRegexp>(?i)^.*-m-?[0-9]+(-.+)?$</noFailReactorVersionRegexp>
<excludes>
<!-- Version being used is an RC with no newer GA release -->
<exclude>com.atlassian.crowd:*</exclude>
<exclude>net.fortuna.ical4j:ical4j</exclude>
<!-- Version being used is a milestone with no newer GA release -->
<exclude>com.atlassian.extension:*</exclude>
<exclude>com.atlassian.jira.plugins.inline-create:*</exclude>
</excludes>
</banVersionDeps>
</rules>
</configuration>
</plugin>
When I start build using this pom.xml I am facing below error.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-versions) on project atlassian-jira-pageobjects: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-versions) on project atlassian-jira-pageobjects: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
at org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:237)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
I am using apache-maven-3.2.5 and Java 8.
Can someone guide me what is wrong in this configuration.
I was getting error for atlassian-browsers-windows I excluded that package and its working fine.
<excludes>
<exclude>com.atlassian.browsers:atlassian-browsers-windows:*</exclude>
</excludes>

Launch4j redirect to download java version

I used Launch4j plugin in my Java project with Maven. When I compile project to exe and run on Windows system where there is no Java installed, it redirects (automatically open web browser) to download Java but with 32-bit version. I want to redirect to download 64-bit newest version. Is it possible?
My plugin definition in Maven looks like
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.11</version>
<executions>
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/Project.exe</outfile>
<jar>target/Project.jar</jar>
<priority>high</priority>
<errTitle>project</errTitle>
<classPath>
<mainClass>com.project.Main</mainClass>
<preCp>libs/*.jar</preCp>
</classPath>
<jre>
<minVersion>1.8.0_101</minVersion>
</jre>
<icon>${basedir}/build-resources/win/application-${ENV}.ico</icon>
</configuration>
</execution>
</executions>
</plugin>
I tried to add in <jar>...</jar> the <runtimeBits>64</runtimeBits> and when run exe file pop up shows "The application requries a Java Runtime Environment 1.8.0_101 (64-bit)" and after click OK, it redirect to download 32-bit version, with page address https://java.com/pl/download/
EDIT
I tried also add in <jar>...</jar> the <bundledJre64Bit>true</bundledJre64Bit> but can not end compilation and return error as below
[INFO] --- launch4j-maven-plugin:1.7.11:launch4j (l4j-gui) # stockbox-main ---
[INFO] Platform-specific work directory already exists: /Users/Arek/.m2/repository/net/sf/launch4j/launch4j/3.9
[ERROR]
net.sf.launch4j.BuilderException: !Jre.bundled.64bit.invalid!
at net.sf.launch4j.Builder.build(Builder.java:76)
at com.akathist.maven.plugins.launch4j.Launch4jMojo.execute(Launch4jMojo.java:358)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
SOLUTION
Before <jre>...</jre> just add <downloadUrl>https://java.com/en/download/manual.jsp</downloadUrl> and that's it.
Redirect us to page when user can choose the java version according to system and which version must download by adding a <runtimeBits>64</runtimeBits> in <jre>... brackets.
The details are provided here - See if it can help
http://launch4j.sourceforge.net/docs.html
<bundledJre64Bit>true|false</bundledJre64Bit>
<bundledJreAsFallback>true|false</bundledJreAsFallback>
<runtimeBits>64|64/32|32/64|32</runtimeBits>

Maven Jaxb2 plugin throwin error "undefined element declaration 's:schema' "

I am trying to generate the classes using maven jaxb2 plugin . However I am receiving the below exception :
org.xml.sax.SAXParseException; systemId: http://someIP/dummywsdl.asmx?wsdl; lineNumber: 32; columnNumber: 41; undefined element declaration 's:schema'
at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
at com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
at com.sun.xml.xsom.impl.parser.DelayedRef.run(DelayedRef.java:85)
at com.sun.xml.xsom.impl.parser.ParserContext.getResult(ParserContext.java:135)
at com.sun.xml.xsom.parser.XSOMParser.getResult(XSOMParser.java:214)
at com.sun.tools.xjc.ModelLoader.loadWSDL(ModelLoader.java:412)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:170)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.loadModel(XJC22Mojo.java:50)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:40)
at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:488)
at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:311)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
After searching , I came to know that below 2 declaration in wsdl is causing the issue :
<s:element ref="s:schema"/>
<s:any/>
In one of the post , I found that If I change the above 2 lines with the below given line , then plugin is generating the files without any issue :
<s:any minOccurs="2" maxOccurs="2" />
Below is the plugin configuration that I am using :
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.abc</generatePackage>
<schemas>
<schema>
<url>http://someIP/dummywsdl.asmx?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
Is there any other way to resolve the issue without changing the WSDL , as this is a client WSDL , and I don't want to store it at my local with the above changes.
Your schema seems to be invalid. So no, XJC won't compile it unless you fix the error.
As a workaround you can create a local copy of your schema and fix this copy. The you can create a catalog file which would "rewrite" the global URL http://someIP/dummywsdl.asmx?wsdl`` into your localdummywsdl.asmx_wsdl`:
REWRITE_SYSTEM "http://someIP/dummywsdl.asmx?wsdl" "dummywsdl.asmx_wsdl"
See Using catalogs for more info.

MojoFailureException caused by charsetName on Maven Archetype

When I try to run the command mvn archetype:create-from-project for my WAR project, this exception is showed after the reading of a .java file:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project ConfiguradorWAR: charsetName -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:create-from-project (default-cli) on project ConfiguradorWAR: charset
Name
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
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:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: charsetName
at org.apache.maven.archetype.mojos.CreateArchetypeFromProjectMojo.execute(CreateArchetypeFromProjectMojo.java:285)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
The default project encode is Cp1252, I already tried UTF-8 and ISO-8859-1, also edited the encode option from the project and eclipse preferences. On pom.xml:
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
</properties>
and
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.2</version>
<configuration>
<defaultEncoding>${project.build.sourceEncoding}</defaultEncoding>
<encoding>${project.build.sourceEncoding}</encoding>
<archetypeArtifactId>archetype-wsjpa</archetypeArtifactId>
<archetypeGroupId>br.com.example</archetypeGroupId>
<archetypeVersion>1.0</archetypeVersion> <archetypeFilteredExtentions>java,xml</archetypeFilteredExtentions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
The best advice I got from my co-workers was try to replace all the characters with accent in the whole project. I have an EJB project with Cp1252 encode as default that worked on the first try.
Thank you in advance and sorry for my bad english.
After exhaustively exercite every param possible for the command line I found out the right one.
You should create your archetype like this:
mvn archetype:create-from-project -Darchetype.encoding=ISO-8859-1
As you can see on Maven Archetype Plugin Docs you should use the "User property archetype.encoding".
Any other parameter name will fail.
It worked for me!
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<project.resources.sourceEncoding>${project.build.sourceEncoding}</project.resources.sourceEncoding>
I needed to add the above. Also I ran mvn clean before running mvn archetype:create-from-project

jaxb2-maven-plugin is giving me a SAXParseException when trying to generate META-INF\sun-jaxb.episode file

Im getting the following error when trying to generate the episode file using xjc2-maven-plugin. This error seems to be with META-INF folder creation.
Any idea on how to solve this. I have been stuck of this for quite some time.
the command line equivalent xjc command seems to work with the same inputs.
[INFO] parsing a schema...
[INFO] compiling a schema...
[ERROR] null[-1,-1]
org.xml.sax.SAXParseException; Failed to write to src\main\generated\META-INF\sun-jaxb.episode
at com.sun.tools.xjc.addon.episode.PluginImpl.run(PluginImpl.java:209)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:294)
at com.sun.tools.xjc.Driver.run(Driver.java:363)
at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:316)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder
java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.FileNotFoundException: src\main\generated\META-INF\sun-jaxb.episode (The system cannot find the path
specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
at com.sun.tools.xjc.addon.episode.PluginImpl.run(PluginImpl.java:170)
... 24 more
The snippet of pom.xml
<properties>
<jaxb.mojo.version>1.6</jaxb.mojo.version>
</properties>
.
.
.
<plugin>
<!-- xjc -p com.test.framework.contracts ./main/xsd/Framework.xsd -d ./main/generated -episode ./main/generated/META-INF/sun-jaxb.episode -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb.mojo.version}</version>
<executions>
<execution>
<id>xjc-framework</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaFiles>Framework.xsd</schemaFiles>
<arguments>-episode src/main/generated/META-INF/sun-jaxb.episode</arguments>
<outputDirectory>src/main/generated</outputDirectory>
<packageName>com.test.framework.contracts</packageName>
</configuration>
</execution>
</executions>
</plugin>
However changing the line episode argument
<arguments>-episode src/main/generated/sun-jaxb.episode</arguments>
makes the compilation pass.
Please help, i need the episode file to be generated by META-INF.

Categories