Eclipse, WebSphere7.0, Maven: AspectJ does not weave code during hot deployment - websphere

My System Information:
IDE: Eclipse Blue 10.0,
Server: Websphere 7.0
Build Management Tool: Maven 3.0
I perform compile time weaving in my Maven project using below configuration:
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>test-compile</goal> -->
</goals>
</execution>
</executions>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>com.xxx.logger</groupId>
<artifactId>my-aspect-logger</artifactId>
</aspectLibrary>
</aspectLibraries>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
<Xlint>warning</Xlint>
<verbose>true</verbose>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>
During development, I use to add my EAR file in exploded mode in Eclipse itself by following below path:
Windows > Show View > Servers > WebSphere 7 > Right Click > Add Deployment
I am facing one issue that whenever I change my java classes those are compiled and hot deployed in server. But, they are not re-weaved. But if I remove the EAR, build my project from command prompt and re-deploy it then it works properly.
Can somebody please help me to resolve this issue.

I'm not familiar with AspectJ but MyEclipse does not execute maven goals to build and deploy projects (though you can add builders, which may invoke maven externally - note that the Maven Project Builder doesn't execute Maven goals), so processing specified in your pom will not be executed automatically, though, obviously, you can run maven goals from the Run As menu item. So changed Java classes will be recompiled using the configured JRE and redeployed. Any additional processing specified in the pom will not be run. However, you say that removing the deployment and then re-deploying actually works, so I'm not sure how the re-weaving gets done, if you don't execute a maven build before redeployment.

Related

Preventing Maven Modules from being Deployed

I followed this tutorial to created a Maven build that can publish artifacts to Maven Central.
It works, and most of the tutorial is for authentication of some sort, so the only relevant part of it might just be:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
Now I wanted to only deploy two of the seven modules in total, so I added this to the parent POM:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
And <skip>false</skip> to the two modules I actually want to deploy.
This doesn't work. All modules get deployed.
I checked the effective POM, and it clearly shows skip=false for the two modules I want to deploy and skip=true for the other five modules.
Since deploying to Maven Central isn't really a reversible process, I don't want to trial and error my way through this problem, hence the question: How do I prevent Maven modules from deploying to Maven Central?
If you are deploying to Maven Central, it is the Nexus Staging Plugin that is doing the deployment instead of the Deploy plugin, so the configuration of the deploy plugin has no effect. To make the Nexus deploy plugin skip, set skipNexusStagingDeployMojo in its configuration to true.
For a complete example, you can look at one of my projects I deployed to Maven Central with the same problem - I want to deploy everything except the integration test modules.
In the parent POM, the Nexus deploy plugin is defined like normal as described in the tutorial (https://bitbucket.org/prunge/shoelaces/src/2347535282c9f5bb58d33cca22d9dd65c9db2c2b/pom.xml#pom.xml-200):
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
and in the integration tests project (which itself has children that inherit this configuration) the staging plugin is skipped (https://bitbucket.org/prunge/shoelaces/src/2347535282c9f5bb58d33cca22d9dd65c9db2c2b/integration-tests/pom.xml#pom.xml-28):
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
</configuration>
</plugin>
This results in everything by default being deployed to Central except the integration tests project and everything underneath that.

While creating a Maven project using archetype13, I have faced Sling IDE issues for core and test pom.xml

while creating a maven project using archetype13, I have faced Sling IDE issues as below for core and test pom.xml
This is the error that I get:
"Missing m2e incremental build support for generating the bundle manifest, component descriptions and metatype resources.
Please use the provided Quick Fixes on this issue to resolve this. pom.xml /AEMEditable.core line 1 Bundle Project Not Supporting M2E"
Note: Figured out how to solve this.
We need to manually modify the pom.xml for core and test, under maven-bundle plugin.
For both core and test pom.xml add the following code :
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<!-- Configure extra execution of 'manifest' in process-classes phase
to make sure SCR metadata is generated before unit test runs -->
<execution>
<id>scr-metadata</id>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<supportIncrementalBuild>true</supportIncrementalBuild>
</configuration>
</execution>
</executions>
<configuration>
<instructions>
<!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
AEMEditable.core
</Sling-Model-Packages>
<!-- Enable processing of OSGI DS component annotations -->
<_dsannotations>*</_dsannotations>
<!-- Enable processing of OSGI metatype annotations -->
<_metatypeannotations>*</_metatypeannotations>
</instructions>
<exportScr>true</exportScr>
</configuration>
</plugin>
Check image:
Once this is done, select the whole project in eclipse, right click, Click on Maven --> Update Project

maven/apt generated classes in eclipse

Using following configuration in master pom, some classes (metamodel FYI) are generated for all child projects having jpa entities under target/generated-sources, as expected.
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.10.Final</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
This works perfectly from Maven and Netbeans.
Some team members still use Eclipse. There, generated classes aren't found automatically. They can be opened if added manually to the "build path" (whatever it means as this is redundant to pom.xml). However, that's not stable and will be reset whenever they "update the project" (shouldn't even be needed but...) to reflect project's maven configuration.
My question is, how to configure Eclipse to use this project's configuration automatically? I don't want to change the project's pom.xml too much, as they are perfectly legal and work well outside of Eclipse, which I just want to be taught to behave correctly.
UPDATE: M2Eclipse is installed and doesn't solve this, which is basically our problem.
There ist a project/Eclipse-Plugin called M2Eclipse (link).
The plugin includes the following feature:
Dependency management for Eclipse build path based on Maven's pom.xml

Maven: Using different plugin configurations on e.g. deploy

For an android maven project (consisting out of a parent project that consists out of the main apk project and a test project), I would like to be able to use different plugin configurations for building the whole project.
I know that I can do this with profiles, but are there any other options?
The thing I would like to achieve is to execute a deploy with "mvn deploy" and to use a different plugin configuration, that should only be used if a deploy (or release) is taking place.
A concrete example would be to increase the android version code only if a deploy takes place. Binding the increase of the version code directly to the deploy phase does not work as the increased version code is needed before the process-resources phase to work properly.
I'm afraid maven profiles are your only option.
You could add an enforcer check on deploy phase to fail the build if a profile is not active:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>deploy</phase> <!-- enfoce rules on `mvn deploy` -->
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<requireActiveProfile>
<profiles>prod</profiles> <!-- require `-Pprod` -->
</requireActiveProfile>
</rules>
</configuration>
</plugin>

Deploy a web-application on Websphere 8.5 using maven 3

I´m trying to make a Maven Project from an existing web application using JSF. The Project
should be deployed on Web Sphere 8.5.
Since i'm new to Web Sphere, don´t know how to build the "ear" Module, in order to be deployable on Web Sphere 8.5.
Does anyone know, where i can find further Information about deploying a web application on Web Sphere 8.5 using Maven 3.0.3?
Thanking you in anticipation,
Mosen
I've never worked with WebSphere Application Server 8.5; but in the days I was playing with IBM WAS 6.1 the WAS6 Maven plugin worked pretty well (it seems it works with WAS7 too). Here's a POM fragment from the plugin site that allows automatic EAR deployment:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>was6-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>installApp</goal>
</goals>
</execution>
</executions>
<configuration>
<wasHome>${was61home}</wasHome>
<host>deploymentmanager.your.domain</host>
<username>admin</username>
<password>adminpassword</password>
<targetCluster>nameOfCluster</targetCluster>
<profileName>Dmgr01</profileName>
<conntype>SOAP</conntype>
<port>8879</port>
<verbose>true</verbose>
<updateExisting>false</updateExisting>
</configuration>
</plugin>
That plugin is for deployment and other administrative task, for EAR generation you can use the Maven EAR Plugin as described in 20InchMovement answer.
Hope this could helps:
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<applicationName>${project.build.finalName}</applicationName>
<host>${local or remote address}</host>
<server>server01</server>
<node>node01</node>
<virtualHost>default_host</virtualHost>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
From https://github.com/orctom/was-maven-plugin
in order to package an *.ear, you don't need Websphere.
This can be accomplished with maven itself.
pom.xml:
<project>
...
<artifactId>YourApp</
<packaging>ear</packaging>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<jarModule>
<groupId>${project.parent.groupId}</groupId>
<artifactId>configurationApp</artifactId>
</jarModule>
<ejbModule>
<groupId>${project.parent.groupId}</groupId>
<artifactId>AnEjbModule</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>
Then you add your dependencies.
On command line go to your project and run mvn package.
Because of the package defined in you pom.xml, the ear will be created and can be found in the YourApp/target directory.
On the websphere admin console you can simply install the ear.
After login, goto:
Applications->Websphere enterprise applications and install a new application.
Select your YourApp.ear and go for easiness through the fast path to install the app.
The port to check is probably
yourServerName:9080/YourApp.
Good luck.
See http://code.google.com/p/websphere-maven-plugin/
Websphere Maven Plugin provides goals to:
deploy ear on websphere 7
start application
stop application
uninstall
require websphere application client.

Resources