Confluence Macro Development in SDK6 - confluence

I am kind of frustrated. I am trying to develop a simple "hello world" macro for confluence. But all the tutorials are not really working anymore for the actual SDK6.
I tried this tutorial:
https://developer.atlassian.com/confdev/tutorials/macro-tutorials-for-confluence/creating-a-new-confluence-macro#CreatingaNewConfluenceMacro-Step1.Createthepluginprojectandtrimtheskeleton
But as you can see the article discussing, it is not working correctly anymore. I think some elements have be modified with SDK6 and the tutorials are not up to date anymore.
I ask at the confluence-forum for help but without any luck. There are several post around this issue without any solution.
The problem is, that the addon / plugin is visible in the system administration panel but I can not use the macro on a page and I can not see the macro in the macro browser.
Now it works - Update
This is what I did:
1) Download SDK
I downloaded sdk-installer-6.2.4.exe and installed it
2) Creating new plugin
I created a new plugin for confluence by typing in
atlas-create-confluence-plugin
with these following group- and artifact ids
groupid : com.example.plugins.tutorial.confluence
artifactid : tutorial-confluence-macro-demo
version : 1.0-SNAPSHOT
package : package com.example.plugins.tutorial.confluence
3) Creating eclipse project
Then I created the eclipse project by typing in
atlas-mvn eclipse:eclipse
4) Modify pom.xml
I modified the pom.xml just like ppasler explained in his answer. I also modified the companyname and the version in order to check in confluence, if the modification will have an effect. The pom looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.plugins.tutorial.confluence</groupId>
<artifactId>tutorial-confluence-macro-demo</artifactId>
<version>4.4-SNAPSHOT</version>
<organization>
<name>Hauke Company</name>
<url>http://www.example.com/</url>
</organization>
<name>tutorial-confluence-macro-demo</name>
<description>This is the com.example.plugins.tutorial.confluence:tutorial-confluence-macro-demo plugin for Atlassian Confluence.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.confluence</groupId>
<artifactId>confluence</artifactId>
<version>${confluence.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-confluence-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${confluence.version}</productVersion>
<productDataVersion>${confluence.data.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.example.plugins.tutorial.confluence.api,
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>1.2.6</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<confluence.version>5.9.7</confluence.version>
<confluence.data.version>5.9.7</confluence.data.version>
<amps.version>6.2.4</amps.version>
<plugin.testrunner.version>1.1.1</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
</properties>
<!--
<properties>
<confluence.version>5.9.7</confluence.version>
<confluence.data.version>5.9.7</confluence.data.version>
<amps.version>6.2.3</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
</properties>
-->
</project>
5) Starting eclipse
I imported the project to Eclilpse
Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200
Java JDK 1.8.0_60
6) ExampleMacro class creating
I created the class "ExampleMacro"
package com.example.plugins.tutorial.confluence;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.content.render.xhtml.XhtmlException;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
import com.atlassian.confluence.xhtml.api.MacroDefinition;
import com.atlassian.confluence.xhtml.api.MacroDefinitionHandler;
import com.atlassian.confluence.xhtml.api.XhtmlContent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ExampleMacro implements Macro
{
private final XhtmlContent xhtmlUtils;
public ExampleMacro(XhtmlContent xhtmlUtils)
{
this.xhtmlUtils = xhtmlUtils;
}
#Override
public String execute(Map<String, String> parameters, String bodyContent, ConversionContext conversionContext) throws MacroExecutionException
{
String body = conversionContext.getEntity().getBodyAsString();
final List<MacroDefinition> macros = new ArrayList<MacroDefinition>();
try
{
xhtmlUtils.handleMacroDefinitions(body, conversionContext, new MacroDefinitionHandler()
{
#Override
public void handle(MacroDefinition macroDefinition)
{
macros.add(macroDefinition);
}
});
}
catch (XhtmlException e)
{
throw new MacroExecutionException(e);
}
StringBuilder builder = new StringBuilder();
builder.append("<p>");
if (!macros.isEmpty())
{
builder.append("<table width=\"50%\">");
builder.append("<tr><th>Macro Name</th><th>Has Body?</th></tr>");
for (MacroDefinition defn : macros)
{
builder.append("<tr>");
builder.append("<td>").append(defn.getName()).append("</td><td>").append(defn.hasBody()).append("</td>");
builder.append("</tr>");
}
builder.append("</table>");
}
else
{
builder.append("You've done built yourself a macro! Nice work.");
}
builder.append("</p>");
return builder.toString();
}
#Override
public BodyType getBodyType()
{
return BodyType.NONE;
}
#Override
public OutputType getOutputType()
{
return OutputType.BLOCK;
}
}
7) Modified the atlassian-plugin.xml file
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="tutorial-confluence-macro-demo"/>
<xhtml-macro name="tutorial-confluence-macro-demo" class="com.example.plugins.tutorial.confluence.ExampleMacro" key="my-macro">
<parameters/>
</xhtml-macro>
<!-- add our web resources -->
<web-resource key="tutorial-confluence-macro-demo-resources" name="tutorial-confluence-macro-demo Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="tutorial-confluence-macro-demo.css" location="/css/tutorial-confluence-macro-demo.css"/>
<resource type="download" name="tutorial-confluence-macro-demo.js" location="/js/tutorial-confluence-macro-demo.js"/>
<resource type="download" name="images/" location="/images"/>
<context>tutorial-confluence-macro-demo</context>
</web-resource>
</atlassian-plugin>
8) Starting confluence
atlas-clean
atlas-package
atlas-debug
9) Logged into confluence
Here the result of the confluence administration page
And now I can find it also in the macro browser and it works
Thanks
Hauke

working with atlassian plugins can be really frustrating :)
I checked out the macro source code from bitbucket and made the following changes in the pom
<properties>
<confluence.version>5.9.7</confluence.version>
<confluence.data.version>5.9.7</confluence.data.version>
<amps.version>6.2.4</amps.version>
<plugin.testrunner.version>1.1.1</plugin.testrunner.version>
</properties>
Then run
atlas-clean
atlas-package
atlas-debug
After that I was able to add the macro with the macro browser (with a confluence 5.8.6 instance).
Unfortunatly I had no time to check the differences between the source code and the tutorial, but my solution will give you a working state to try new stuff.

Your image is displaying ${atlassian.plugin.key}. Is your Macro add-on working properly. It is displayed in the macro browser but can you use it on the page? I also noticed you commented out atlassian.plugin.key in your pom.xml.
The use of <Atlassian-Plugin-Key> here tells the plugin system that you are a transformerless plugin and that it should skip the slow transformation step. This is VERY IMPORTANT. Without this entry in your Manifest, the plugin system will try to transform your plugin, and you will lose the load time speed benefits. You are also likely to see Spring-related errors. Do not forget to specify this entry.
See: Atlassian Spring Scanner
The new way of importing components is to use Atlassian Spring Scanner. It looks like your mixing the old and new way of importing components by commenting out atlassian.plugin.key.
Check out: Build a Macro Add-on
Confluence examples: Confluence Add-on Development examples

Related

why am I able to create wsdl when I took away pluginManagement?

My entire pom.xml is below. With this pom I get this error in Eclipse "Plugin execution not covered by lifecycle configuration: org.apache.cxf:cxf-java2ws-plugin:3.1.8:java2ws (execution: process-classes, phase: process-classes)".
Nevertheless, it does work properly. I mean, if I "mvn clean package install" I get the output wsdl file desired.
If I added pluginManagement, the error in Eclipse desapears but I don't get the wsdl file desired neither I get an error in my console. The two closest discussions I found about it was "Publishing wsdl java M2E plugin execution not covered" and "How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds" but I didn't understand them. As far as I can see, the idea is to change to take advantage of
"<lifecycleMappingMetadata>...<action><execute/>".
My straight question is: why does my below pom works when I take away pluginManagement? I guess, not sure, that I am missing a basic knowledgement about the relantionship between pluginManagement and execution. The most relevant part from my question is not what is worng with Eclipse (I found few people saying to ignore it).
I have been using pluginManagement for while but I have never wondering exactly what extra features it adds to my pom. Since now it is failing with java2ws, I am really interested to understand if there is any extra configuration I should add in my pom in order to get it up and running with pluginManagement and goal>java2ws.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>grp</groupId>
<artifactId>art</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>art Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.8</jdk.version>
<cxf.version>3.1.8</cxf.version>
<spring.version>4.3.4.RELEASE</spring.version>
<!-- <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> -->
</properties>
<dependencies>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Apache cxf dependencies -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- servlet & jsp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>art</finalName>
<!-- <pluginManagement> -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>process-classes</id>
<phase>process-classes</phase>
<configuration>
<className>art.VmxService</className>
<outputFile>${project.basedir}/src/main/resources/VmxService.wsdl</outputFile>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<address>http://localhost:9080/art/VmxService</address>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- </pluginManagement> -->
</build>
</project>
The pluginManagement section serves a similar purpose like the dependencyManagement section. It defines plugins and their version and configuration defaults, without actually adding them to the maven build lifecycle.
Once the plugin is added in a module it will pick up the configuration from the pluginManagement section.
Also see: Maven: What is pluginManagement?
So if a similar configuration of the same plugin is used in multiple modules you can collect them together in one place. If the plugin is only used in one module I prefer to just put it in there directly in the build. But both ways work.
Remember you also need to add the plugin to the build.plugins - simply having them in pluginManagement does nothing.
The warning in eclipse relates more to the life-cycle of your IDE. It differs a bit from the maven lifecycle and in some cases it cannot detect (or could not?) at what moment a plugin is supposed to run. Some plugins also cannot execute without a maven project. So I'm never sure what that lifecycle-mapping plugin tries to solve :/
Anyways: if you generate the classes using a maven build and this works for you (not having that done when telling eclipse to 'build' the project without maven) you're good.
I thought that information (the lifecycle mapping) is nowadays baked into the plugins directly and read by the m2eclipse plugin. I've seen such xml files in some plugins. So the lifecycle-mapping plugin might not be required anymore at all.

ContainerRequestFilter wont run in JavaEE jersey project

Am new to JavaEE and have some issues getting custom ContainerRequestFilter to run in Jersey. I read the jersey documentation some more and created a new clean project straight from the 'jersey-quickstart-webapp', added the filter seen below but no luck (added an empty beans.xml as well).
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
#Provider
#PreMatching
public class MyFilter implements ContainerRequestFilter {
#Override
public void filter(ContainerRequestContext requestContext) throws IOException {
requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).entity("User cannot access the resource.").build());
}
}
Was uncertain if Prematching and Provider was complementary or not so i used both then each separately, but didnt work (MyReasource just served as without filter). Tried throwing an exception in MyFilter but that didnt run either.
So i searched through StackOverflow and found 'http://blog.dejavu.sk/2013/11/19/registering-resources-and-providers-in-jersey-2/' which points to that you actually needs to implement registrations in Application or ResourceConfig class. I tried this (didnt work) but i atleast got a warning for the resource class now, 'No resource methods have been found for resource class a.b.MyFilter'
My Application class now looks like below (tried scan package but didnt make a difference. Without the manual filter registration i didnt get the warning either).
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
import javax.ws.rs.ApplicationPath;
#ApplicationPath("resources")
public class RestApplication extends ResourceConfig {
public RestApplication() {
//packages("a.b");
register(MyFilter.class);
register(MyResource.class);
property(ServerProperties.TRACING, "ALL");
}
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
</web-app>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a.b</groupId>
<artifactId>server</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>server</name>
<build>
<finalName>server</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.22.1</jersey.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
All files lies in the 'a.b' (i.e my package) root. Any ideas on how to get the filter actually running and i would be very greatful ;). I presume it shouldnt be this hard to get this working so i guess im missing something here?
Let me walk you through what's going on. When you first created the jersey-quickstart-webapp archetype, it gave you this
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>a.b</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
What this init-param jersey.config.server.provider.packages does is tell Jersey what package(s) to scan for resource classes annotated with #Path, and provider classes annotated with #Provider.
So from that point, all you needed to do was add the #Provider to the filter, and it would have worked.
But then you decided to clear out the web.xml and use the ResourceConfig with the #ApplicationPath. For this to work Jersey takes advantage of the Servlet 3.0 pluggability mechanism, as mentioned in this answer. For that to work we need to make sure we have the jar that has the JerseyServletContainerInitializer. That's where we need to look at the pom.xml file
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
The comment is telling you that if you don't need Servlet 2.5 support, you should use jersey-container-servlet instead of jersey-container-servlet-core. I don't know, it might be poorly worded. Maybe instead it should say if you want Servlet 3.x support, change it. But in any case, the jersey-container-servlet has the JerseyContainerServletInitializer that we need. So if you want to go web.xml-less, then just switch out the dependency.

MOXy exceptions in JavaEE Jersey 2.0 project

Im trying to implement Json support in a JavaEE project but had issues with MOXy related exceptions being generated. I read on jersey.java.net that MOXy should be autodiscoverable but it doesnt seem to work when i try.
So to make this easy to pinpoint i just generated a new 'jersey-quickstart-webapp' project and changed MyResource as below (my goal is to use an Application class instead of web.xml but this was the simplest way och pinpointing it. The error occurs no matter what).
#Path("myresource")
public class MyResource {
#GET
#Produces(MediaType.APPLICATION_JSON)
public Response getIt() {
return Response.status(Response.Status.ACCEPTED).entity(new TestEntity()).build();
}
}
TestEntity class (in same package):
#XmlRootElement
#XmlAccessorType(XmlAccessType.FIELD)
public class TestEntity {
private String content = "SOME CONTENT";
public String getContent() {
return content;
}
}
POM.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a.b.c</groupId>
<artifactId>server</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>server</name>
<build>
<finalName>server</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.22.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
I deployed this on a clean Glassfish 4.1.1 using IntelliJ.
After this i receive
java.lang.ClassNotFoundException:
javax.xml.parsers.ParserConfigurationException not found by
org.eclipse.persistence.moxy
So i add beans.xml as below (tried empty as well as i saw indicated in Oracle docs)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
And i get this error when deploying
java.lang.NoClassDefFoundError: Could not initialize class
org.eclipse.persistence.jaxb.BeanValidationHelper
I tried , for fun, removing the web.xml, changing the dependency jersey-container-servlet-core to jersey-container-servlet and creating an Application class instead (as discussed in ContainerRequestFilter wont run in JavaEE jersey project) but gives the same error. Infact it gives the same error if publishing a clean javaee-api 7.0 dependant project instead of jersey dependencies and gave same error (i suppose glassfish using jersey anyway).
So i guess im missing something here, any kind soul that could fill me in on what? :)
Downgraded to Glassfish 4.1.0 and then it worked perfectly. Some issue perhaps with the 4.1.1 release? Will try the nightly as well but it works now.
I managed to get past this issue by updating the Manifest in the org.eclipse.persistence.moxy.jar file that comes with Glassfish 4.1.1, rather than downgrading to Glassfish 4.1.0
Steps I took:
Get the updated Manifest.mf file from this post (attached on 2015-03-26 06:08:50 EDT)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=463169
Replace the Manifest.mf file in the org.eclipse.persistence.moxy.jar file with the one you downloaded.
The file is found here:
{c}:\glassfish4\glassfish\modules\org.eclipse.persistence.moxy.jar
Restart Glassfish
Thanks to those who posted and fixed this issue on bugs.eclipse.org
Instead of downgrading to 4.1.0, I found a switch to Payara a good bet.

The maven project generated by gwt-maven-plugin can't be imported into eclipse via import existing maven project

I firstly generated a gwt maven project by executing --
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.7.0
After that, the pom.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.boye.games</groupId>
<artifactId>games-gwt</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwtVersion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see
gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>LineThree.html</runTarget>
<modules>
<module>com.boye.games.linethree.LineThree</module>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then I imported this project into eclipse via built-in eclipse function -- import existing Maven project.
However, the process failed due to several reasons:
GreetingServiceAsync cannot be resolved to a type
Execution default of goal org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync failed:
Plugin org.codehaus.mojo:gwt-maven-plugin:2.7.0 or one of its
dependencies could not be resolved: Failed to collect dependencies for
org.codehaus.mojo:gwt-maven-plugin:jar:2.7.0 ()
(org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync:default:generate-sources)
google plugin can't identify this project as gwt web application automatically.
My environment as follows:
java version 1.7.0_03
eclipse version Kepler Service Release 2
gwt version 2.7.0
Please advice, thanks a lot!
I did another attempt to try in a win32 computer, the problem re-appeared even if I set up the environment as aforementioned working in my win64 computer.
So I really got confused, like Klarki said, I have to do some tweaks to get it work. I generated GreetingServiceAsync via mvn gwt:generateAsync then manually copy GreetingServiceAsync to source folder, then I remove <goal>generateAsync</goal> in pom.xml, then import project via eclipse's existing maven project. It works again!
Sadly see it not working intelligently.
The problem was with generateAsync, which in your case generates GreetingServiceAsync on execution. Eclipse probably wasn't configured to handle it properly and this class was not generated and eclipse reported the missing class warning.
Another thing that could be done to get the project to work was to run mvn package from command line and add the generated dir in target dir as source dir in eclipse (vie right clicking the project and selecting New -> source folder > browsing folder name > target > generated-sources > the right folder)
Also you may run into same issue after you do mvn clean - the generated GreetingServiceAsync will be deleted and the problem may come back.
The problem exists because eclipse isn't tightly integrated with maven and uses its own build system ignoring maven targets that you don't have plugins for. What you could do is to open eclipse preferences > maven > lifecycle mappings and there you can enable generateAsync to execute.
If you copy the generated class manually you have to keep in mind that you need to update it when needed, where as it is intended to generate automatically. So you loose this convenience.
This work for me:
I deleted the local maven gwt repository, in windows 7 it's in C:\Users\.m2\repository\com\google\gwt, and then make a
mvn clean complile
so maven re-import al dependencys.
After I changed my environment as follows:
java version "1.8.0_05"
eclipse Version: Luna Release (4.4.0)
Google plugin for Eclipse 4.4
I works like a charm.
Probably, it's a version incompatibility issue.

Maven, plugins, and JIRA

I've been running through the hello world example from JIRA(https://developer.atlassian.com/display/DOCS/Getting+Started).
Eclipse (Kepler) gives me a large list of errors in the pom for my project. Specifically on the first plugin tag. All of them are some variation of
Plugin execution not covered by lifecycle configuration: com.atlassian.maven.plugins:maven-jira-
plugin:4.2.10:filter-test-plugin-descriptor (execution: default-filter-test-plugin-descriptor, phase: process-test-
resources)
with descriptions after the second colon. I think these are the goals.
I've come across this but it wasn't much help to someone who was completely new to all this.
Here is the pom that was generated by Atlassian:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.tutorial</groupId>
<artifactId>helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<organization>
<name>HelloGoodby Inc.</name>
<url>http://www.helloworldgoodbye.com</url>
</organization>
<name>helloworld</name>
<description>This is the com.atlassian.tutorial:helloworld plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation
classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating
a plugin originally developed against JIRA 4.x -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!-- <dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-amps-plugin</artifactId>
<version>4.2.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!-- <pluginArtifacts> <pluginArtifact> <groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId> <version>${testkit.version}</version>
</pluginArtifact> </pluginArtifacts> -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>6.1.3</jira.version>
<amps.version>4.2.10</amps.version>
<plugin.testrunner.version>1.1.2</plugin.testrunner.version>
<!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x -->
<testkit.version>5.2.26</testkit.version>
</properties>
</project>
And yet, "this" is exactly going to fix your problem for you.
While Maven just bluntly executes whatever plugins are configured, the Maven Integration (m2e) in Eclipse is a bit more reluctant in doing so. Not everything that makes sense for execution on the command-line should also be executed while within Eclipse. Now, some common plugins it will automatically take care of, but when it encounters the Atlassian plugins it seemingly does not know what to do, and wants your help with that.
Depending on the plugin in question, you can either:
Install a m2e connector for that particular plugin (which will know what to do)
Configure what to do within your POM file (pom.xml)
Configure what to do within your local Eclipse
These are given in (my) order of preference. In any case 2. makes a lot of sense, because each developer who imports your POM file will be good to go, think about that. The configuration in the POM file can either tell m2e to ignore or execute the plugin execution, and in the latter case whether to run on incremental builds (runOnIncremental).
"The link" gives examples of this configuration, which is configured as lifecycleMappingMetadata in a plugin configuration under pluginManagement of your POM. The good news is that Eclipse can help you with the three solutions above using a quick fix on the error that you're seeing.