Importing a maven dependency using Struts 2 in Eclipse - eclipse

I'm using eclipse with maven and I would like to include two struts tags :
<%# taglib prefix="s" uri="/struts-tags" %>
<%# taglib prefix="sj" uri="/struts-jquery-tags" %>
<%# taglib prefix="sb" uri="/struts-bootstrap-tags" %>
The problem is that the compiler says :
Can not find the tag library descriptor for "/struts-jquery-tags"
The library is correctly downloaded by maven through this declaration:
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.5.8</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.bootstrap</groupId>
<artifactId>struts2-bootstrap-plugin</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
The maven dependencies are in the project's build path.
Why the struts-jquery-tags is not imported ?
PS : when I add the struts-jquery-tags's jar manually, I have no errors.
(There is another post dealing with the same problem but the answers are not relevant in my case).

Make sure that your project is maven enabled. Right click on your project select configure and then convert to maven project.
Then make sure you have maven dependencies set correctly.
In the eclipse right click on your project and select Build Path > Configure build path ... The select Libraries tabs. Make sure you have the Maven Dependencies in the list of your libraries. If the it is not there select Add Liberary and then Maven Managed Dependencies

I hope this will be a Eclipse issue.
I guess you've created a Dynamic Web Project and then converted it to a Maven project. When a struts project created in this way there are chances of getting errors which you mentioned.
As long as your project is running smoothly in the deployed server you need not to pay attention towards these.
I suggest to create struts2 project from maven repository. If project created in this way these kind of errors can be avoided.

The jar file is available here. You have the problem of downloading/packaging jar file. struts-jquery-tags is not imported because the plugin is not available on classpath.
If you need additional info you can check docs Building with Maven.

Related

How do I update Itext7 to version 7.1.1

This seems like it should be simple but I cannot find anything on how to upgrade to newer versions of itext7. I am using an Eclipse maven project with itext7 version 7.0.4 and would like to update to 7.1.1. However, I can find nothing that tells me how to do that. Neither the Eclipse update menu or the Maven menu has an option to update itext7. Can someone point me to the documentation on how to do an update? TIA.
After answer:
I am not getting the libraries but instead getting conflicts:
I can't seem to post my pom.xml using code tags (I guess the formatter has a problem with XML code because of the <>) but I will include it if someone tells me how. I've uploaded the pom file to DropBox:
pom.xml
(Turning #mkl's and #amedee's comments into an answer)
In your project there is a file pom.xml which contains the Maven project definition. In there is a dependencies section with entries for the iText artifacts (among others). The version is therein. Well, it could also be in a separate dependencies management section or in a parent pom.xml referenced in your file.
As soon as you update the POM file, you can update the Eclipse project configuration in your Eclipse Maven menu. That will, if necessary, automatically download the jar artifacts. If your Eclipse Maven integration is properly configured, that is, and if your computer has proper internet connectivity.
Old versions will remain in your local repository but won't be in the class path anymore.
Also check out our getting started guide. Which contains an example POM snippet.
https://developers.itextpdf.com/itext7/download-and-install-information/Java
If you put your iText version number in POM properties, then you only have to update the value once when you want to upgrade. Like this:
<properties>
<itext.version>7.1.1</itext.version>
</properties>
and then
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
...
</dependencies>

MILO OPC-UA Download with Maven

I tried to use the milo opc-ua Implementation. At first I download the source with Eclipse/Maven to my local working directory.
File -> Import -> "Checkout Maven Projects"
The Download works fine for me. After this, I tried to update the project files.
Right-Click -> Update Maven Project
The "build-tools" work well for me, everything is done without any errors. But when I try this with the other "folders" (client-examples, ...) I get the following error:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (execution: validate, phase: validate).
The following code shows the pom-file of the client-examples:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent>
<groupId>org.eclipse.milo</groupId>
<artifactId>milo-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>client-examples</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-client</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>server-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
The pom.entries, shown in https://github.com/eclipse/milo, are in the file. I also checked this for the other sources. But whats going wrong?
I'm using eclipse-neon and maven2eclipse.
Thanks for helping,
Andreas
The errors says that the M2Eclipse plugin has no idea how to map the execution of checkstyle into some build step for the IDE. M2Eclipse tries to set up your local IDE project to replicate the behavior of the Maven build.
By default M2Eclipse is missing the support for the checkstyle Maven plugin. Therefore you get this error. There are two ways to handle this:
You can simply make Eclipse ignore those errors
You can install the checkstyle plugin for Eclipse and have checkstyle run the same way the maven build does it, getting all validation information right into your IDE.
In order to install checkstyle do the following:
Locate the location where the error is reported in Eclipse, issue the "Quick fix" command (normally Ctrl-1)
Select "Discover new m2e connectors":
Review the dialog and press "Finish":
Wait and let Eclipse restart
That should be it.

Why does addition of MigLayout still give an error inspite of adding the MigLayout jar file in the libraries in netbeans 8.0?

Though I have configured the classpath and added the jar file in the library of the project , it still gives me an error as "package net.miginfocom.swing. does not exist".
What can I do to avoid this error?
You can use maven to automatically download MigLayout. Just click new project, select and maven from categories, then Java Application. Once created go into the "pom.xml" (within Project Files) and paste this under the properties section:
<dependencies>
<dependency>
<groupId>com.miglayout</groupId>
<artifactId>miglayout</artifactId>
<version>3.7.4</version>
</dependency>
</dependencies>
Then just build the project and maven will download and install MigLayout. Hope this helps.

NetBeans adding external library Vaadin Framework

How can I add external library to Vaadin framework using NetBeans?
I can't find libraries folder there. Additionally I want use pi4j library.
I haven't seen it there like in normal Java Application Libraries folder.
Looks like you are using Maven. In that case you have to edit your pom.xml file (you can find it in the Project Files folder in NetBeans).
Google for the Maven coordinates for the library you want to include and add the corresponding dependency section in the dependencies section. For example, to add Log4j, you must add the following in your pom.xml:
...
<dependencies>
...
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
...
</dependencies>
...
Alternatively, you can right click the Dependencies folder in NetBeans, select Add Dependency..., and add the corresponding Maven coordinates or search for the dependency (keep in mind the Maven Index may be updated the first time you search for a dependency, process that might take some seconds/minutes).

Missing Maven dependencies in Eclipse multi-module project

I’m using STS 2.9.1 (build on Eclipse 3.7.2) with m2e plugin bundled with STS (v1.0.200.20111228-1245).
I have a problem regarding missing dependencies in Eclipse project that contains several modules, or maybe I don’t fully understand how it should work.
It’s a maven project.
In my Project > Properties > Java Build Path > Libraries I have “Maven Dependencies” library, but it's empty (and that’s the problem).
The main POM doesn’t have any dependencies, but it has several modules declared in it.
Adding a dependency to module’s POM doesn’t add it to the “Maven Dependencies” library (what was my expectation) and leads to Eclipse showing errors in source files.
Adding a dependency to the main POM adds it to the “MD” lib, but of course I don’t want to add all of my modules’ dependencies to the main POM just to have it in “MD” lib and adding every single dependency to the Build Path doesn’t seem right nor practical.
I’ve tried:
Project > Clean,
Maven > Update dependencies,
Maven > Update project configuration,
Unchecking the checkbox: Project > Properties > Maven > Resolve dependencies from Workspace projects.
None of the above seems to do the trick.
Example:
Simplified project structure:
simple.project
...
sample-module
...
pom.xml
pom.xml
simple.project/pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>simple.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>sample-module</module>
</modules>
<dependencies>
<dependency><!-- This dependency is present in "MD" lib. -->
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
simple.project/sample-module/pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>simple.project</artifactId>
<groupId>test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>test</groupId>
<artifactId>sample-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency><!-- I've expected this dependency also to appear in "MD" lib. -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
It is not supposed to work. A project only imports a dependency from another one if it depends on that project (using dependency) or if it inherits from it (using parent). The module element only represents an aggregation.
The question is from time ago, but I solved this creating a Maven Project and adding Maven Modules: right click on project and "New > Project... > Maven > Maven Module".
After that, no more errors were shown in code.
First thing that I see is that you're defining dependencies in a pom parent. There I would expect to see a <dependencyManagement> (see here the doc) structure. In this way the submodules will inherit properly those common dependencies.
Aside from that lets start for the most simple test. Try to compile your project from the maven utility in the command line. If it works then you have a problem in your Eclipse configuration, otherwise the problem is in the way you have defined your project.
If your project compiles properly from the command line, lets see what else can be happening.
The fact that the Maven Dependencies Library is empty means that the Eclipse Maven plugin is not resolving properly your poms. I had quite bad experiences with the embedded STS maven plugin. Try to downgrade it to the m2e 0.10 version. You only need to open the STS DashBoard / Find Updates / Install m2e 0.10
I hope some of these tips can help you.