Import java class to Jsp in Maven project - maven

I have a project in IDE, so I made a new project in Maven. I copy all the files and classes, and I fill the pom.xml.
This is OK, but the problem is in JSP,eclipse dont find the imported clases.
<%#page import="modelos.Mascota"%>
This import for example cant be resolved.
What I'm doing wrong?
All my java classes are in:
\src\main\resources
And jsp files in:
src\main\webapp

Your .java files must be in
\src\main\java

check your dependencies for the class whether it is exist or not
modelos.Mascota

Related

Generate and run Maven Kotlin jar

I'm trying to generate a jar file of my kotlin project.
I read Maven Kotlin and copied the code into my pom.xml but I don't understand what I'm supposed to insert at ${main.class}.
Here is my code architecture with MorisKt.java as my main class.
I tried MorisKt.class, /MorisKt.class, target/Moris.class(container folder of my compiled code)
And nothing worked. The jar is generated but I have Could not find or load main class when I try to run it.
If you can explain me where I'm doing it wrong
You need to put your main class file in a package and then reference it with the fully qualified name.
For instance if you put your Moris.kt in a package named app it would be :
<mainClass>app.MorisKt</mainClass>

How to properly use a referenceJar in Xamarin Android Project?

I have a .aar file that contains a SDK, it needs the gson library to work, so i added the gson.jar file into the project as a ReferenceJar, but it cannot find the reference.
I've already tried to extract the jar from the aar, and use one as InputJar and the gson jar as ReferenceJar, it did not work.
In this case the java code spits this error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson;
I've tried to create a separate project that contains only the gson file as a InputJar and use it as a dependency on the other project.
In this case the gson project does not compile, VS spits errors like
CS0534 "CollectionTypeAdapterFactory.Adapter" does not implement inherited abstract member "TypeAdapter.Read(JsonReader)"
I've also tried to add the gson.jar file into the libs folder inside the .aar file, but gave me the same compiling errors as described above
So, what should I do next?
I figured out.
I had to extract the jar from the .aar and set it as an EmbeddedJar and the gson library as EmbeddedReferenceJar. Somehow it worked. If someone could explain me why, it would be nice.

Vaadin 10 and springboot - How to package a jar?

The question is simple, but I spent the last 2 days trying to deploy my app. And so far it doesn't.
I have a single CSS file for my style, and when I execute the jar, CSS is not found (404) or the jar won't package.
As stated here: Spring Boot Executable jar structure
"Do not use the src/main/webapp folder if your application will be packaged as a jar"
and
"You should place your static resources in src/main/resources instead."
so put the CSS here:
src/main/resources/styles.css
In Vaadin documentation (which is very pour on how to package...) I import the CSS like this:
#StyleSheet("styles.css")
Source : https://vaadin.com/docs/v11/flow/importing-dependencies/tutorial-include-css.html
Then I package my project:
mvn clean package -Pproduction
I get this error:
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project importparcoursup: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: An import that ends with 'styles.css' cannot be resolved: the corresponding file 'C:\Workspace\lasteclipeandjava10\parcoursup\target\frontend\styles.css' was not found.
[ERROR] Double check the corresponding import and verify the following:
[ERROR] * the import string is correct
[ERROR] * the file imported is either present in 'frontend://' directory of the project or in one of the project WebJar dependencies or in one of the regular jar dependencies
[ERROR] * if the file is present in one of the regular jar dependencies, it should be located in META-INF/resources/frontend directory in the jar
Can someone provide a simple example of a 'springboot + Vaadin10' app packaged as a jar with static resources inside ?
I tried so many configurations (put the CSS in META-INF, include webapp resources in the maven build process...) but after 2 days, I still can't deploy my app on the server!
finally the solution
css has to be here:
src/main/resources/META-INF/resources/frontend/styles.css
then declared as:
#StyleSheet("frontend://styles.css")
This could be helpful too even though I still miss an example:
Vaadin 10 makes some changes to the way it loads static resources,
such as application templates, custom styles and any additional
JavaScript files. The gist of it is that such files should be put in
src/main/webapp/frontend/ when building a .war file and
src/main/resources/META-INF/resources/frontend/ when building a .jar
file.
Link to Vaadin Dokumentation: Vaadin 10 and static resources

Unable to import Spring Security #Secured Annotation into Grails 3

I am currently following the Spring Security 3.0.0.M1 plugin tutorial for Grails here and I appear to be stuck on Step 8. Using the statement import grails.plugin.springsecurity.annotation.Secured does not work because Grails cannot resolve the package name. I know that Spring Security for Grails 3 is in its infancy, but has anyone been able to get past this step yet? For reference, here is my SecureController class (with a another import that also does not work):
package ldaptest.controllers
import grails.plugin.springsecurity.annotation.Secured;
import org.springframework.security.access.annotation.Secured;
#Secured('ROLE_ADMIN')
class SecureController {
def index() {
render 'Secure access only'
}
}
I may found a solution:
Create a "lib" folder e.g. inside your "grails-app" directory.
Download the SpringSecurityCore JAR from here and move it into the lib directory
Add gradle dependency:
compile files('lib/spring-security-core-3.0.0.M1.jar')
Hope this helps.
Greetings
I had:3,1,1 the save problem with my application. I solved it by adding as a library to my project. However I had to change import package to make it work.
import org.springframework.security.access.annotation.Secured
I am using IntelliJ IDEA, I just has to search the maven repo for the spring-security-core:3.1.1.
In IntelliJ you do : File > Project Structure > Libraries > Add > From Maven Repository. Then do the search according to the version of "spring-security-core" you want to use.

Buildr Manifest generate class-path from EAR package

I am using (and learning) Buildr to build and package my projects. I would like to auto generate the class-path attribute in an EJB projects MANIFEST file. Currently I am doing:
manifest_cp = compile.dependencies.map { |d|
"#{File.basename(d.name)}"
}.join(" ")
package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)
I am new to Ruby and Buildr so there probably is a better way to do this. However I was actually hoping to be able to generate the jars I define and package in my EAR as opposed to getting the compile dependencies in my JAR.
I package my ear project like:
package(:ear).include(ANTLR, AOP_ALLIANCE, ...
Is it possible in my EJB project build when packaging the jar and modifying the manifest I create the Class-Path attribute with all the dependencies packaged in the EAR? On top of that I would also like to exclude one or two dependencies?
thanks
UPDATE
I tried a different approach that seems better (but still probably there are much better ways than what I have). I created a constant that held all my artifacts I want to include in my EAR and then built up the classpath string:
EARLIBS = [ANTLR, AOP_ALLIANCE, ... ]
manifest_cp = Buildr.artifacts(EARLIBS).each { |artifact| artifact.invoke }.map{ |d|
"#{File.basename(d.to_s)}"
}.join(" ")
When I package the EJB I specify the manifest_cp that was created above:
package(:jar).with :manifest=>manifest.merge('Class-Path'=>manifest_cp)
When I package the EAR I reference the constant declared with all the artifacts:
package(:ear).include(EARLIBS)
Even though this works for what I want I would appreciate it if anyone has a better way of doing it
thanks,
The builds doc for the EarTask contains the solution I believe:
All specified libraries are added to the EAR archive and the Class-Path manifiest entry is modified for each EAR component.

Resources