Appengine + Maven + Spring + Eclipse - eclipse

I want to use maven and spring with appengine, but I can't...
I was able to configure maven with appengine (and spring with appengine, but without maven), but when I add spring dependencies and I try to run it I have the following error:
WARNING: Could not instantiate listener org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
[...]
java.lang.ClassNotFoundException: org.springframework.web.filter.CharacterEncodingFilter
how I can solve this problem?
I read tons of information but it seems out to date...
Thanks, and sorry for my english.

It would help if you put more info into your question, but I would say to take a look at the spring artifacts here in maven central : http://search.maven.org/#search%7Cga%7C1%7Corg.springframework and try to choose all a single version that works for you. I think they are on 3.2.2.RELEASE
Sorry I can't be of more help, but since the springframework docs are a bit outdated for maven support these days (http://www.springsource.org/spring-framework), it can be easy to get a mishmash of versions which cause issues with resolving dependencies.
Try also only declaring the minimum set of dependencies you can, and "mvn dependency:tree" can also clue you into where you might be bringing in duplicate dependencies, which can cause this type of problem.

For maven dependancies please have a look at:
https://mvnrepository.com/artifact/org.springframework
Make sure you have spring-web dependancy declared.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
Please read the appengine spring optimization guide, can save you some hassle later on:
https://cloud.google.com/appengine/articles/spring_optimization

Related

Optaplanner - drools file cannot be compiled when project is deployed

We developped a SpringBoot project with Java 11 using optaplanner-core and defining rules in a Drools file. We have no issue for running the app in intelliJ with JDK.
We then deployed the app onto Azure app service where a JRE is installed. We get the following error:
Caused by: org.kie.memorycompiler.KieMemoryCompilerException:
Cannot find the System's Java compiler. Please use JDK instead of JRE or add drools-ecj dependency to use in memory Eclipse compiler
We tried to add the following dependencies but we still get the same error:
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-core</artifactId>
<version>8.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-ecj</artifactId>
<version>7.51.0.Final</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.26.0</version>
</dependency>
Would anyone know how to solve this problem ?
Thank you
Adding drools-ecj won't really fix this. The error message is misleading.
Using a JDK instead of a JRE. The easiest way is to upgrade to Java 11 (or higher), as that only comes with a JDK.
If running optaplanner with a JDK is no option for you, you can change the solver config to
<solver>
<scoreDirectorFactory>
<droolsAlphaNetworkCompilationEnabled>false</droolsAlphaNetworkCompilationEnabled>
</scoreDirectorFactory>
</solver>
and if you're using unit tests for java constraints that use the ConstraintVerifier, instantiate it like this
new DefaultConstraintVerifier<>(new MyConstraints(), SolutionDescriptor.buildSolutionDescriptor(myModelClasses))
.withDroolsAlphaNetworkCompilationEnabled(false)
However: From what I understood, disabling the drools alpha network compiler usually comes with a performance impact.

Cannot resolve import after Maven configuration

I have a web dynamic project on eclipse running on Tomcat.
I need to add the dependency of the JWT library on Maven dependencies. So I configured my project to Maven, and the I added the dependency on the pom.xml.
Now eclipse doesn't resolve my dependency, for example if I import a package of JWT there is a red line that highlights my import.
But there is another problem:
all the library that I imported like hibernate, apache-common (that I previously copied in WEB-Lib) that before worked, now are unresolved.
How may I face this problem? This is the first time using Maven, so if I'm wrong in something, please tell me.
Thanks in advice.
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
</dependency>
This dependency worked for me

Maven - Suppress Overriding managed version warning in Eclipse

I am using spring-boot, and experienced an error similar to the one described here. I added the following to my pom.xml.
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId><!--$NO-MVN-MAN-VER$-->
<version>1.1.0.Final</version>
</dependency>
I am overriding the validation-api 1.0.0 dependency defined in my parent pom.xml, by way of Spring boot, and this gives the pesky warning message:
Overriding managed version 1.0.0.GA for validation-api
How can I permanently suppress this warning message in Eclipse? It shows up both in my pom.xml and my problems view.
When that warning shows up, you can open the Quick-Fix menu on the warning (Ctrl+1) and select
Ignore this warning
This will add the comment on the version line, like :
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version><!--$NO-MVN-MAN-VER$-->
</dependency>
Your problem is you manually added that comment on the wrong line.
Since the project is using spring-boot, a more proper answer could be found here: https://stackoverflow.com/a/35385268/1568658
(And since I got the same issue, and the above answer also is not very complete. I would add an answer here.)
Reason of issue:
spring-boot has defined many dependencies & their versions, when you use spring-boot as parent, these dependencies got inherited, and overriding one of the dependency with a different version would get the warning, because it might break other libraries' dependencies.
Solution:
Define a property for that dependency between <properties></properties>, to specify the version.
e.g
<properties>
<reactor.version>2.5.0.BUILD-SNAPSHOT</reactor.version>
</properties>
How to find the property name:
Open your pom.xml in IDEA or Eclipse.
Ctrl + Click on the <parent> tag to open pom of parent, and need to click twice recursively to finally get to the pom file with artifactId as spring-boot-dependencies.
Once you have opened that pom, search for your dependency, e.g servlet-api, and you can see the default version.
There is a document from spring explains it better: https://spring.io/blog/2016/04/13/overriding-dependency-versions-with-spring-boot
Enter version that you need in main pom.
This warning means that you are trying to override artifact version that is defined in your main (top level) pom. Just enter version that you need in main pom and you don't even need to use <version /> in other poms for this dependency.
My issue is with lombok.jar version. I do have multiple lombok versions and eclipse somehow taking a version but it detected more versions so unable to pick it's version. So I went to maven folder (.m2) and deleted the extra versions of lombok, did maven update on project, error gone.
But I haven't provided lombok version anywhere, eclipse choose a version, don't know how.
useful ! I resolve the problem. As the module pom file declare 9.2.12.M0 while the spring-boot refer to the V9.3 . I overwrite the V9.2 in the parent pom file. follow by "Eric Wang"

Is there a procedure to be followed to add external jars to a custom confluence plugin development environment

I added this dependency chunk in my pom.xml
<dependency>
<groupId>freeway</groupId>
<artifactId>axis</artifactId>
<version>1.0</version>
</dependency>
I have placed my jar file in the folder C:\jarhost\axis-1.0.jar
And i ran the command
mvn install:install-file -Dfile= "C:/jarhost/axis-1.0.jar" -DgroupId=freeway -DartifactId=axis -Dversion=1.0 -Dpackaging=jar
And this is the error i get is this
http://imageshack.us/f/580/cmdimage.png
I also stumbled upon this https://confluence.sakaiproject.org/display/DOC/Adding+JARs+to+an+Application and tried it too. But it was unable to 'download' dependencies.
What am i missing ?Looking for your help on this.
Thanks
A
You can instal your jar with your plugin by adding dependencie in your pom.xml
in your case i think you need to add scope compile
eg.
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
you can read about it here
and another advice if you start create plugin is best practise is to use Confluence atlas-cli , mvn-instal not help you in this way.
Also i advice you to read this very usefull docs here you can find a lot's of nice docs which can help you to develop plugins for confluence much more easier.
Angela,
maybe you run into this bug:
Unfortunately there's a bug in the Atlassian Plugin SDK that prevents
the atlas-* batch files from correctly interpreting command-line
parameters that contain an equals sign
The workaround is to call "%ATLAS_HOME%\apache-maven\bin\mvn" instead of "atlas-mvn".
https://studio.atlassian.com/browse/AMPS-197
https://ecosystem.atlassian.net/browse/AMPS-353
https://answers.atlassian.com/questions/20341/configuring-eclipse-to-use-the-atlassian-plugin-sdk
My solution was the following:
edit %ATLAS_HOME%\bin\atlas-mvn.bat
locate the line if "%1"=="" goto loopend (in my case it was line 69)
change it to:
if `%1`==`` goto loopend
Hope this solves your problem!

Finding missing Maven artifacts

I'm new to Maven, and struggling with adding dependencies. I'm trying to convert an existing project to Maven, and after adding the dependencies for all the jars in my referenced libraries, I'm receiving an error message about missing artifacts:
Missing artifact stax:stax:jar:1.0
Missing artifact clover:clover:jar:1.3-rc4
Missing artifact log4j:log4j:bundle:1.2.16
Missing artifact stax:stax-ri:jar:1.0
From reading this post: How to handle Maven missing artifact errors?, it sounds like I need to manually download these jars and add them to my local maven repository. My question is how do I find these jars? I tried googling them, and I can find jars that have similar names, but not exactly like these, so I'm not sure if they're the right jars.
Any tips for dealing with this problem? The log4j jar is the only one explicitly listed in the referenced libraries of my original project, so I'm guessing the other ones are required by other jars that I have, and I don't know where to find them or what their exact names should be.
Thanks!
Thanks to everyone for responding. The actual cause of the problem is that for each of those 3 missing artifacts, for some reason, when Maven downloaded them into my local repository, .lastUpdated was appended to the end of the jar. For example, stax-1.0.jar.lastUpdated. This is the reason Maven could not find stax-1.0.jar.
So, to fix this problem, I had to manually download stax-1.0.jar, then install it into the local maven repository in the exact same place as the messed up file, so that Maven could find it. (For example, using the command:
mvn install:install-file -Dfile=<path-to-file>/stax-1.0.jar
-DgroupId=stax -DartifactId=stax -Dversion=1.0 -Dpackaging=jar
Using the same exact groupId and artifactId as the existing, incorrect file was crucial in order for maven to find it.
You can find dependency search Sites under maven.apache.org. Go to the left side Navigation MenĂ¼ entry FAQ (official) and Thun to end of page.
It's more likely that your POM definition is not correct for log4j. Everything relating to log4j should be readily available in maven.
Also, if you know the name of the bundle (such as log4j) you can almost always do a quick google search "[bundle name] maven pom" within the first few hits you should either get the maven repo containing a quick snippet on how to include it, or the actual website for the bundled up jar and the maven instructions.
For example log4j:
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
Sometimes though you just need to specify the repository to find the item in (if it's not hosted in the greater maven repositories)
You can specify a new repository like so
<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
Finally when you absolutely cannot find the artifact already maven'd up for you (this is usually true for proprietary jars and or drivers that you cannot include with your project) you can have the user manually install the item via command line
mvn install:install-file -DgroupId=[group-id] -DartifactId=[artifact-id] -Dversion=[version] -Dfile=/path/to/the/file -Dpackaging=[type]
You can then reference it in your maven file using the information described above
For example I have a custom reference for a salesforce.com project
mvn install:install-file -DgroupId=com.salesforce -DartifactId=wsc -Dversion=22 -Dfile=\tsclient\H\development\java\wsc-22.jar -Dpackaging=jar
To access it in maven:
<dependency>
<groupId>com.salesforce</groupId>
<artifactId>wsc</artifactId>
<version>22</version>
</dependency>
Finally, you can find the jars (or their maven info) at their respective websites (please note I'm just basing these links off the jar names, these may not be the actual websites, well sans the log4j which I know to be correct)
Stax
Clover
Log4j
Use maven search or mvnrepository.com. If you can not find use google looking for jar in other public repositories, for example for stax:
maven stax-ri pom
My first result is:
http://maven.nuxeo.org/nexus/content/groups/public/stax/stax-ri/1.0/
Other public repositories:
http://download.java.net/maven/2
http://download.java.net/maven/1
http://repository.codehaus.org
http://repository.jboss.org/nexus/content/groups/public-jboss
http://maven.springframework.org/release
you can try to add new repositories to your pom.xml
<repositories>
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
<repository>
<id>jboss</id>
<url>http://repository.jboss.com/maven2</url>
</repository>
</repositories>
After several days this stupid error bugged me, I found the following article
The author describes that there is a workspace repository, which may out of date. In my case it helped just to import the correct plugins again. The workspace repository has been updated and everything is fine.
Your problem might be something to do with MNG-4142. This bug means that maven will not download a new snapshot if localCopy is set to true in the artifact maven-metadata-local.xml.
Note that the title of this bug is slightly misleading so it is work reading the comments.
You might think that using the -U flag with maven would fix this problem but apparently this is not the case.
The current workaround seems to be searching for all instances of maven-metadata-local.xml and changing the value of localCopy to false.
I solved this problem by changing the log4j version from 1.2.15 to 1.2.16.
It also could be cause by the dom4j. The same error occurred when I use the following settings.
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>20040902.021138</version>
</dependency>
After changing to the following, the error disappeared.
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>