Maven War Plugin Websphere - java

I am trying to get a Rational Application Developer project to run on a websphere server. I am trying to get the maven-war-plugin to work. However, when trying to start the server, websphere can not find the UI Files. I have my plugin here:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webXml>/WebContent/WEB-INF/web.xml</webXml>
<webappDirectory>WebContent</webappDirectory>
<source>/codeCoverageUI2/src/</source>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
I feel the issue is with my webappDirectory but I do not know what else to put it to, besides the location of all my UI files.
Anyone have some insight?

I am assuming you are using WebSphere Classic V8 or earlier?
What we recommend because when developing a project in RAD/WDT, WAS Classic requires building the project in a "Single Root" structure. Add the following to your pom:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
...
This will build your source within the Web content folder. (Make sure you do a Project -> "Maven" -> "Update Project...") then rebuild...

Related

maven compiler in intellij

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
What is the point of using maven in intellij if it dose not work without setting the correct JDK under various intellij options?
What I mean is that now with intellij I have to set the JDK in 3 different places.
File->Setting->Build->Compiler
File->Project Structure->Project
File->Project Structure->Modules
While I aspect expect that when i compiler on the right side where are the maven options it works just by watching the pom file.
i think that depends on what type of project you want to make but personally i find maven nice to use because you can set up several actions in the pom file (for example when compiling Less files, excluding them from the build and just using the resulting css files).
another feature would be the easy way to add dependency's from the maven rep http://mvnrepository.com/

Distribute plugin resource files to host project

I have a maven plugin that exposes a Mojo, with a goal that runs at the compile stage. The project was generated using mvn archetype:generate, and the POM contains all the standard stuff that comes with running that, very little deviation. The project includes a couple of resource files, e.g. filea.txt and fileb.txt, that are packaged up as part of the jar.
When the plugin is used in a project, I'd like the files that are included in the jar to be extracted and copied to the target\test-classes directory of the host project. I'm trying to use the plugin jar to both distribute some files + expose some functionality that can then use those files.
Is this a valid approach, and if so, are there settings I can add to the plugin POM to indicate that content from the plugin should be extracted and copied? I want to centralise this logic in the plugin, rather than having to do in the plugin host.
I feel like it's something with maven-dependency-plugin or maven-resources-plugin or build-helper-maven-plugin:attach-artifact, have tried a couple of different approaches but think I'm missing something obvious:
e.g. something like this in plugin POM?
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<outputDirectory>${basedir}/target/test-classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>filea.txt</include>
<include>fileb.txt</include>
</includes>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
// etc etc
Google fu has let me down, keep ending up on maven resources page. Can post directory structure / more information if needed.
Cheers
First I would suggest to put resources which needs to be distributed into src/main/resources which looks like you have done ...but remove the configuration for the maven-resources-plugin and let maven do it's work. This is automatically copied into target/classes/ which in result is packaged into the resulting jar later.
If your plugin needs to get those files those can accessed as a usual resource via this.getClass().getResourcesAsStream("/...") and reading and writing them into a new location preferable into target/...

Converting Eclipse dynamic web project to maven project with modules

so I just started a new project at work where I've gotten some code, really strange code...
So the project structure was as follows:
simple-java-project-1 ---> eclipse java project which holds some database-connectors
simple-java-project-2 ---> holds the logic of converting, formatting etc of the data, uses the connectors from project-1
dynamic-web-project --> just gets the jars from project1 and project2 and offer's a websocket api to send this data etc.
I would like to convert this mess to a well structured maven project. So I created a master maven project with this pom:
......bla bla bla....
<modules>
<module>the-connectors</module>
<module>the-logic</module>
<module>the-dynamic-web-module</module>
</modules>
<dependencies>.....</dependencies/>
And the modules as well. I added the dependencies needed to them.
So now the hard part I didn't get : How can I achive that the whole project is deployed to the local tomcat and runs?
The web.xml and /WEB-INF/ stuff is in the "the-dynamic-web-module" module for now,...
Any ideas or hints?Thanks in advance.
You should add the tomcat7-maven-plugin to your the-dynamic-web-module:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
<systemProperties>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
After building and installing the 2 other modules (mvn install), go to the-dynamic-web-module and launch mvn tomcat7:run. Then with your browser, go to localhost:8080/ and you should get your app.

Deploying spring project in tomcat

I created a sample Maven MVC project using my Spring tool suite but unable to deploy to tomcat.
The problem is when I right click the project and click "Run as" I don't see the "Run on server" option..
I tried changing the project to Dynamic web module after selecting the properties-project facets
but get the error, "Dyanmic web module 3.0 requires Java 1.6 or more"
How do I enable my project to run in Tomcat?
Have your Maven project compile for Java 1.6. Add this to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

maven tomcat plugin configuration

Requirement is to deploy application at tomcat root using maven plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://www.myhost.com:8080/manager</url>
<server>tomcat6</server>
<path>/</path>
<contextFile>src/main/tomcatconf/context.xml</contextFile>
<mode>context</mode>
</configuration>
Above is deploying application at root but the problem is application using images, javascript and other pdf files (of large size) from a folder "static" which is stored outside application.
c:\static\
Please suggest for configuration required in pom.xml to access images like below.
http://www.myhost.com:8080/static/image.js
http://www.myhost.com:8080/static/about.pdf
You can get embedded tomcat7 plugin like this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>

Categories