I have trying to generate Javadoc using the maven-javadoc-plugin and a custom doclet. I am using JDK 11 and I have implemented the methods of the Doclet interface. However, in one of the methods, I am trying to unmarshal an XML file. I am receiving the following error:
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been
found on module path or classpath.
I have configured the javadoc-plugin as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<doclint>none</doclint>
<useStandardDocletOptions>false</useStandardDocletOptions>
<outputDirectory>my.output.directory</outputDirectory>
<doclet>my.doclet/doclet>
<docletArtifact>
<groupId>my.group.id</groupId>
<artifactId>myartifact</artifactId>
<version>my.project.version</version>
</docletArtifact>
<show>private</show>
</configuration>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
</plugin>
What should I do to solve this issue?
Related
I am creating Rest client using JAX RS Jersey 2. The client works but only in my IDE (IntellIJ IDEA), when I build it with Maven, using maven-assembly-plugin and run the jar it doesn't work anymore.
I get MessageBodyWriter not found for media type=application/json error.
I have tried adding more dependencies that people suggested in other posts but I don't think a dependency is a problem since it runs in the IDE.
Here is the code that throws the exception
return client.target(uri)
.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(transactions.get(0), MediaType.APPLICATION_JSON));
After debugging, when I replace transactions.get(0) with an empty string "", it works.
Here is the pom.xml for maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>SequencerControllers</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
Am i missing something? Really bothers me that it runs in the IDE but not when built with Maven since I build it with dependencies.
Check if you have class com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in your resulting JAR. If not, add following dependency:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.10.0</version>
</dependency>
there's an ordering issue as the Jackson and Jackson / jersey jars don't play well in an "uber" assembly jar. This is because they have same-named files in their individual jars that contain different values.
The assembly plugin will pick one version as the "winner" that gets included in the uber jar. The losing duplicate will not be included and in your case, you are likely getting the wrong copy included in your uber jar.
To fix this, make sure that these 2 entries are moved to the top of the maven dependencies list
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
I also moved this one at the bottom of the dependencies:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
That combination seemed to fix the uber jar issue in my situation.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
By default this plugin gives Tomcat version 7.0.37, how can we point to Tomcat version 7.0.91?
As our security team came up with some vulnerabilities for 7.0.37, we need to upgrade to 7.0.91.
Is there any way we can configure the dependencies for the plugin?
there is a newer version of tomcat7-maven-plugin which uses the tomcat 7.0.47 version. Maybe you want to give it a try.
if you really want to update the version referenced by the plugin you can try to exclude the particular references in the plugin and add dependencies in the dependencies section for the ones you excluded.
<dependencies>
...
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-util</artifactId>
<version>7.0.91</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<dependencies>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-util</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
<plugins>
<build>
Additional to the answer from aurelius and for documentation reasons:
It's also documented on the plugin page how to replace given tomcat dependencies with new ones:
https://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/adjust-embedded-tomcat-version.html
I wrote a facade for the owl-api paired with the pellet reasoner to easily access an ontology. It worked quiet well. Then I tried to pack it as an OSGi Bundle and use it via an TrackerService from other services. The owl-api bundle needs guava and trove to run. For trove there is no bundle. Even after reloading the target platform, the pellet jars were not recognized as bundle in eclipse (I took them from jpm4j). So I thought about just take all the jar- stuff and squeeze it into the bundle.
I read a lot of how-to's for packaging third-party jars with a bundle. I use the maven-bundle-plugin and after reading some documentation from this plugin and bndtools I decided to use conditional-package, because here it was described that all entries in the pom are passed to the bndtools. After the compilation, no jar was packaged with my bundle :(. Then I used embed-dependencies. It didnt't work because the transient dependiencies were not available at runtime. So I used the embed-transient tag (I already read that this is bad style). The Import-Package part was filled automatically with all transient dependencies, so I overwrote it by hand to ged rid of the errors regarding the unsolved imports. This worked and I was able to use the owl-api to insert new properties,individuals, etc (yeah).
When I tryed to start the pellet reasoner, I got the error message below at runtime. I think it is about the dependency-mess in my project again. I already know that the current way is the wrong one, but I was not able to find a better one. Please help me to get this dependency management in OSGi right.
Cheers,
Stephan
ERROR MESSAGE:
!ENTRY org.apache.felix.configadmin 4 0 2015-11-16 11:28:45.218
!MESSAGE [org.osgi.service.cm.ManagedService, id=28, bundle=7/initial#reference:file:..vdg.iCar.service]: Unexpected problem updating configuration vdg.iCar.service
!STACK 0
java.lang.Error: javax.xml.datatype.DatatypeConfigurationException: Provider for class javax.xml.datatype.DatatypeFactory cannot be found
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:892)
at javax.xml.bind.DatatypeConverter.initConverter(DatatypeConverter.java:140)
at javax.xml.bind.DatatypeConverter.parseFloat(DatatypeConverter.java:243)
at com.clarkparsia.pellet.datatypes.types.floating.XSDFloat.getValue(XSDFloat.java:81)
at com.clarkparsia.pellet.datatypes.types.floating.XSDFloat.getCanonicalRepresentation(XSDFloat.java:58)
at com.clarkparsia.pellet.datatypes.DatatypeReasonerImpl.getCanonicalRepresentation(DatatypeReasonerImpl.java:365)
at org.mindswap.pellet.ABox.createLiteral(ABox.java:1746)
at org.mindswap.pellet.ABox.addLiteral(ABox.java:1725)
at org.mindswap.pellet.KnowledgeBase.addPropertyValue(KnowledgeBase.java:974)
at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:1103)
at uk.ac.manchester.cs.owl.owlapi.OWLDataPropertyAssertionAxiomImpl.accept(OWLDataPropertyAssertionAxiomImpl.java:119)
at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:699)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyImpl.accept(OWLOntologyImpl.java:1516)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.refresh(PelletReasoner.java:967)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:345)
at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:304)
at com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.createReasoner(PelletReasonerFactory.java:71)
at de.dlr.vdg.ontology.osgi.impl.util.ReasonerUtil.getInferredOntology(ReasonerUtil.java:56)
at de.dlr.vdg.ontology.osgi.impl.util.ReasonerUtil.getInferredRelations(ReasonerUtil.java:304)
at de.dlr.vdg.ontology.osgi.impl.OntologyServiceImpl.startReasoning(OntologyServiceImpl.java:106)
at de.dlr.vdg.iCar.osgi.impl.iCarServiceImpl.start(iCarServiceImpl.java:67)
at de.dlr.vdg.iCar.osgi.Activator.updated(Activator.java:65)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1444)
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1400)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider for class javax.xml.datatype.DatatypeFactory cannot be found
at javax.xml.datatype.FactoryFinder.findServiceProvider(FactoryFinder.java:304)
at javax.xml.datatype.FactoryFinder.find(FactoryFinder.java:268)
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:145)
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:890)
... 28 more
Caused by: java.util.ServiceConfigurationError: javax.xml.datatype.DatatypeFactory: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at javax.xml.datatype.FactoryFinder$1.run(FactoryFinder.java:297)
at java.security.AccessController.doPrivileged(Native Method)
at javax.xml.datatype.FactoryFinder.findServiceProvider(FactoryFinder.java:292)
... 31 more
POM-File (important parts):
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Private-Package>${bundle.namespace}.*</Private-Package>
<Export-Package>${bundle.namespaceShared}</Export-Package>
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>${bundle.namespace}.Activator</Bundle-Activator>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Import-Package>org.osgi.framework;version="[1.6,2)",org.osgi.se
rvice.cm;version="[1.4,2)",org.slf4j;version="[1.7,2)"</Import-Package>
<Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>3.5.2</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>com.github.ansell.pellet</groupId>
<artifactId>pellet-owlapiv3</artifactId>
<version>2.3.6-ansell</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.github.ansell.pellet</groupId>
<artifactId>pellet-query</artifactId>
<version>2.3.6-ansell</version>
<type>jar</type>
</dependency>
</dependencies>
After an additional day of research I came across this thread at oracle.
The pellet-api references the xerces and xml-api libs and due to the transient inclusion of dependencies, these libs were included in my bundle. But these libs are already present in the java runtime environment. Therefore I excluded them in the Embed-Dependency section and everything works.
<Embed-Dependency>*;scope=compile|runtime;inline=false;groupId=!xml-apis|xerces</Embed-Dependency>
I am running a maven script which uses maven-jaxb1-plugin version 1.0.rc-11 to generate the jaxb classes from xsd. The script was running successfully in the java version 1.4 and maven version less than 3 . Now the same script when run in java version 1.6 and maven version 3.0.3 environment throws an exception **
A required class was missing while executing
org.jvnet.jaxb1.maven2:maven-jaxb1-plugin:1.0.rc-11:generate:com.sun.msv.grammar.Grammar
**
All the dependencies for this plugin are available in my repository.Still I am getting this error.
Below is my pom.xml
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb1.maven2</groupId>
<artifactId>maven-jaxb1-plugin</artifactId>
<version>1.0.rc-11</version>
<executions>
<execution>
<configuration>
<schemaIncludes>
<include>response.xsd</include>
</schemaIncludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Is it like maven-jaxb1-plugin can not be used in jdk1.6 and maven 3.0.3 environment.Any help is much appreciated,Thanks.
The class that it says it is missing, com.sun.msv.grammar.Grammar, is present in jaxb1-impl.jar according to findjar.com:
http://www.findjar.com/class/com/sun/msv/grammar/Grammar.html
That class does not seem to be present in jaxb-impl.jar:
http://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl/1.0.6
It does seem to be present in jaxb1-impl.jar:
http://mvnrepository.com/artifact/com.sun.xml.bind/jaxb1-impl/2.0
So maybe change your dependency to:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb1-impl</artifactId>
<version>2.0</version>
</dependency>
I use Magnolia CMS and Blossom.
When I add annotations to my classes I get something like this:
annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations)
#Template(value="Blossom Template")*
Spring annotation(like #Controller) doesn't compile too.
Where is my mistake?
My pom.xml dependencies:
<dependencies>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-blossom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-admininterface</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-taglib-cms</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-taglib-utility</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
You have to change your maven.compiler properties to compile with java 1.5.
<properties>
<!-- maven-compiler-plugin configuration -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
Another way to do this (but less discreet) is this :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
Resources :
http://maven.apache.org/ - compile MoJo - Source
On the same topic :
How can I force maven to package my project against 1.5?
I am happy this got answered but encourage you to use the Magnolia community, especially the mailing-list to ask questions about Magnolia in the future. This will benefit you and the community.
See http://www.magnolia-cms.com/home/community/mailing-lists.html
Thanks
- Boris