Eclipse Neon, Vaadin version 7.3.6. Java 1.8.
I want to show QR code on page , created by Vaadin. So I add dependency in pom.xml
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>qrcode</artifactId>
<version>2.0.1</version>
</dependency>
In my code in Vaadin I use this:
QRCode code = new QRCode();
code.setValue("The quick brown fox jumps over the lazy dog");
code.setWidth("400px");
code.setHeight("400px");
addComponent(code);
It's compile and run success. But when I try to load html page with QR code I get the next error:
Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for fi.jasoft.qrcode.QRCode.
Check its component connector's #Connect mapping, widgetsets GWT module description file and re-compile your widgetset.
In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.
What is wrong? Thanks.
You need to re-compile the widgetset for your application. Actually there is a maven plugin for that. You can find the detailed instructions how to create&comiple custom wigetset here:
https://vaadin.com/directory/help/using-vaadin-add-ons/maven
It's a bit tricky to set everything up, but once it's done, it's only about running
mvn vaadin:update-widgetset install
You'll have to add some plugins to the pom.xml in order to make this work, the best way how to find out how to add the plugin is to generate the official archetype for the Vaadin application and copy&paste the plugin info from there:
mvn archetype:generate \
-DarchetypeGroupId=com.vaadin \
-DarchetypeArtifactId=vaadin-archetype-clean \
-DarchetypeVersion=LATEST \
-DgroupId=your.company \
-DartifactId=project-name \
-Dversion=1.0 \
-Dpackaging=war
Note that if you are using spring-boot then there'll be no web.xml where to define the widgetset, but you can actually follow info from this forum:
https://vaadin.com/forum#!/thread/9587133
Related
I am new to java and maven. I am learning and trying to make a system to help me build up JSON data by GOOGLE's gson and maven. This is my using command order:
mvn -f my-app\pom xml clean compile
mvn -f my-app\pom xml install
cd my-app\target
java -jar my-app-1.0.jar
After I run it it show me this error.
in GSONExample.java Line 13:
Gson gson = new Gson();
The following is my using software/IDE version.
Source Editor: VS Code
JDK: JDK-19
apache-maven: 3.8.6
Gson: 2.10 (https://github.com/google/gson/releases)
I have already gone through other websites and StackOverflow to find solutions.
GSON is not being imported into the maven project Changed scope role and still crash
error even though it is defined in my classpath /WEB-INF/lib can't find in my situation
Now below a part of my pom.xml
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10</version>
</dependency>
I also had try to import it(Gson) to local and try to fix it out.
mvn install:install-file -Dfile=C:\gson-2.10.jar -DgroupId=com.myself.gson -DartifactId=example-gson -Dversion=2.10 -f my-app\pom.xml
After I use the command, I changed pom.xml as follow. It can compile and install. But still show me "NoClassDefFound"
<dependency>
<groupId>com.myself.gson</groupId>
<artifactId>example-gson</artifactId>
<version>2.10</version>
</dependency>
May anyone provide any solution to this? Thanks in advance.
I had tried
changed scope to provided in pom.xml
put Gson in src\main\resources\lib and change pom.xml
Local gson-2.10.jar and change pom.xml
put gson-2.10.jar in C:\Program Files\apache-maven-3.8.6\lib
The problem is this command:
java -jar my-app-1.0.jar
Most likely your current Maven pom.xml creates a JAR file which contains only the classes of your project, but not the classes of dependencies, such as Gson. This is also not specific to Gson but applies to any dependencies you are trying to use. You can either:
use java -cp and specify the path to your JAR as well as the paths to all the JARs of dependencies you are using, for example java -cp gson-2.10.jar;my-app-1.0.jar com.mycompany.app.GSONExample
configure Maven to build a "JAR with dependencies", see this question whose answers describe multiple ways of how this can be achieved
We are using Jenkins maven plugin for building and deploying war applications. In the jenkinsfile we have the command (I removed the list of profiles for the sake of simplicity):
mvn release:clean release:prepare -P<profiles> -U -DautoVersionSubmodules="true" -Darguments="-T 1C -DskipTests=true" -V --batch-mode --errors
The built war artifact has MANIFEST.MF file with field Release-Name set to main.
Release-Name: main
In the parent pom.xml there are some extra settings for customize MANIFEST.MF but it seems to me that "Release-Name" is added by default because it is not listed below:
<manifestEntries>
<Version>${project.version}</Version>
<Revision-Number>${buildNumber}</Revision-Number>
<Branch>${GIT_BRANCH}</Branch>
<Local-Branch>${scmBranch}</Local-Branch>
</manifestEntries>
So I tried to look into the maven release plugin source code from this repository but I couldn't find anything helpful.
Then the main question is how the field "Release-Name" is filled because I'd like to change it into some more meaningful value.
The problem, as it turned out, was in another module of the project, which was downloaded from remote repository, while building the entire artifact. In this extra module, there was a definition in pom used to set the value of Release-Name in the manifestEntries section.
<Release-Name>${releaseName}</Release-Name>
I was trying to test this maven plugin on a simple spring-boot project. But I'm facing an issue with mojo parameters, when I use parameter containing a "-" along with goals it doesn't seem to work:
$ mvn clean install fabric8:build fabric8:resource \
> -Dfabric8.openshift.enableAutomaticTrigger=false \
> -Dfabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll=true
But when I put these parameters as system properties in project's pom.xml. They seem to be picked by maven plugin and work as they are supposed to do. I added this to pom like this:
<properties>
<fabric8.openshift.enableAutomaticTrigger>false</fabric8.openshift.enableAutomaticTrigger>
<fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>true</fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>
</properties>
I'm a big confused here. Can anyone please tell me why it's not working in former case? Is there some kind of naming convention for mojo parameters that we're supposed to follow?
I suggest you to use a workaround (seems to me a faster solution than debug maven) :
<properties>
<f8.autoTrigger>your_default_here</f8.autoTrigger>
<f8.enrichAll>your_other_default_here<f8.enrichAll>
<fabric8.openshift.enableAutomaticTrigger>${f8.autoTrigger}</fabric8.openshift.enableAutomaticTrigger>
<fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>${f8.enrichAll}</fabric8.enricher.fmp-openshift-imageChangeTrigger.enrichAll>
</properties>
And if you want to override your defaults you can invoke maven like :
$ mvn clean install fabric8:build fabric8:resource \
> -Df8.autoTrigger=false \
> -Df8.enrichAll=true
It is even shorter :)
According to Oracle documentation the schemagen tool is removed from the JDK as part of JEP 320 (http://openjdk.java.net/jeps/320).
That JEP points to Maven artifacts that now supply the missing tools. The coordinates of the artifacts are wrong in the JEP, updated coordinates are found in an answer to this question:
Which artifacts should I use for JAXB RI in my Maven project?
What is missing however is how to invoke the tools. There are shell scripts pointed to in the JEP that are in the JAXB-RI Git repository. However those scripts remain undocumented and difficult to invoke. The build instructions in that git repo indicated it is built with a standard "mvn clean install", however that does not produce an output structure that matches the 'bin' folder used in the documentation here: https://javaee.github.io/jaxb-v2/doc/user-guide/ch04.html#tools-schemagen
Ideally I would like to run schemagen from Gradle, avoiding the shell scripts as they are not obtained from the maven dependency.
My current attempt, adapted from a working version that called the old schemagen.exe, looks like this:
(There is more in the 'real' build.gradle file to specify my application's dependencies, etc.)
configurations {
schemagenTool
}
dependencies {
schemagenTool "org.glassfish.jaxb:jaxb-jxc:${jaxbVersion}"
}
task schemaGen(type: Exec, dependsOn: [compileJava,configurations.schemaGenTool]) {
workingDir projectDir
executable 'java'
doFirst {
file('build/Schemas').mkdirs()
args '--module-path', "${configurations.schemaGenTool.asPath}",
'-m', 'jaxb.jxc/com.sun.tools.jxc.SchemaGeneratorFacade',
// Note: automatic module name is NOT com.sun.tool.jxc
// as documented
// Args to schemagen (these worked for the schemagen.exe)
'-d', 'build/Schemas',
'-classpath', "${compileJava.destinationDir}${File.pathSeparator}${configurations.compile.asPath}",
"src/main/java/path/to/my/ModelClass.java"
//println "\nschemagen: ${args.join(' ')}\n"
}
doLast {
// Above creates "build/Schemas/schema1.xsd" (despite printing a different path!)
// Rename it
def destFile = file('build/Schemas/model.xsd')
destFile.delete()
if (!file('build/Schemas/schema1.xsd').renameTo(destFile)) {
throw new GradleException("Failed to write new build/Schemas/model.xsd")
}
}
}
However, that results in an error:
Error occurred during initialization of boot layer
java.lang.module.ResolutionException: Modules jaxb.runtime and jaxb.core export package com.sun.xml.bind.marshaller to module relaxngDatatype
The issue seems to be known with the jaxb-*:2.3.0 version - #jaxb-v2/issues/1168. Additionally, this would be resolved with a future release as marked in the known issues of jaxb running over java-9.
You can resolve this following the comment -
Please try 2.4.0-b180725.0644 - this is JPMS modularized RI working on
JDKs with java.xml.bind module (9,10) and those without it (11-ea)
or try downloading the binary distribution from the same link.
Schemagen and xjc shell scripts are only put into binary distribution in ./bin directory.
For build tools there are plugins out there (Maven / Gradle) which does invoke schemagen and xjc APIs, providing user with simple configuration.
Your attempt to invoke com.sun.tools.jxc.SchemaGeneratorFacade manually is also correct, here is similar example for Maven. However you are probably putting 2.3.0 on module path, which has a split package problem. Putting on classpath will resolve the issue for 2.3.0. Next release of JAXB will be JPMS ready and have module descriptors declared. You can try the beta build (2.4.0-b180725.0644), here is a correct set of dependencies:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId> <!--jaxb runtime-->
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId> <!--java generation-->
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-jxc</artifactId> <!--schema generation-->
</dependency>
If trying to use the schemagen in the jaxb-ri download directly, note the JAXB_PATH in schemagen.bat is inconsistent with the mod directory in the jaxb-ri.zip file.
E.g. to use schemagen.bat:
As at now, download jaxb-ri-2.3.1.zip from https://maven.java.net/content/repositories/releases/com/sun/xml/bind/jaxb-ri/2.3.1/ (the 2.4.0-betas also had the mod/javax.activation-api.jar missing)
Use these steps to run schemagen.bat, setting JAXB_HOME as appropriate:
set JAXB_HOME=C:\Java\jaxb-ri-2.3.1
set CLASSPATH=%JAXB_HOME%/mod/relaxng-datatype.jar;%JAXB_HOME%/mod/javax.activation-api.jar
%JAXB_HOME%\bin\schemagen.bat -cp myjar1.jar;myjar2.jar -d target com.company.ClassName1 com.company.ClassName2
(This was against JDK 11)
I am working with Bndtools in Eclipse. I am trying to add Apache Thrift as dependency to a project. My build.bnd has this code for adding the Maven Central as well as our Nexus repository:
-plugin.5.Nexus = \
aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
releaseUrls=https://<NEXUS_URL>:8081/content/groups/public/ ; \
snapshotUrls=https://<NEXUS_URL>:8081/content/groups/public/ ; \
index=${.}/release.maven; \
pom = ${workspace}/cnf/maven-nexus.xml; \
name="Nexus"
-plugin.6.MavenCentral: \
aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
releaseUrls = https://repo1.maven.org/maven2/; \
pom = ${workspace}/cnf/maven-central.xml; \
name = Maven Central
I tried to add the dependency to both xml files like this:
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.10.0</version>
</dependency>
Other dependencies like Gson work just fine. The bnd.bnd file of the project where I want to use Thrift only has this content:
-buildpath: \
org.apache.thrift
I also tried org.apache.libthrift, but I found out that this should be the correct OSGi bundle name. I always get
Cannot find /error/org.apache.thrift;version=0 Not found
Am I missing something here? I am new to OSGi and so I might miss something really obvious. I am also not sure if my configurations of the repositories are correct. Still, other dependencies work just fine. Thanks for any advice!
EDIT:
Maybe as additional information: In Eclipse the build.bnd file is shown empty in the GUI view. Does this mean, that my project is somehow corrupted or is this normal?
EDIT2: For testing (didn't help) I also added the Maven Central using the MavenBndRepository Plugin additionally to the BndPomRepository:
-plugin.7.MavenCentralAlternative = \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
index=${.}/central.maven; \
name="Maven Central Alternative"
EDIT3: The problem has to be Thrift related. All other packages work just fine, only Thrift is not found. My current workaround is to add the Thrift jar to the project manually and reference its dependencies as OSGi bundle just like I tried to add Thrift in the first place. Obviously I get now this warning:
Bndtools: The .classpath contains a library that will not be available
during continuous integration