Set context root for spring annotation based web app - spring

How can set the context root for a annotation based spring web app? Sample application found in following link,
https://github.com/bkielczewski/example-spring-mvc-initializer
In browser I can access it as,
http://localhost:8080/
I want to change it as,
http://localhost:8080/spring
Thanks,
Charith

Update your pom.xml to include web-app configuration. See below
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.6.v20130930</version>
<configuration>
<webApp>
<contextPath>/spring</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
<host>localhost</host>
</httpConnector>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>

Related

Spring Boot Admin - info.version

We have a service which uses a custom context path. In order to correctly register our Service on Eureka Server, we've set the following:
eureka.instance.statusPageUrl=http://xxx/custom/info
eureka.instance.healthCheckUrl=http://xxx/custom/health
eureka.instance.homePageUrl=http://xxx/custom/
This is working well, our application gets registered. However, although we have set the info.version information, it doesn't get displayed on the Spring Boot Admin homepage. For our application where we don't have a custom context path, it's working:
Any idea which property(ies) is/are eventually missing?
You need to add the following into your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Documentation link

Execution error consuming a soap -web-service from spring+maven

I am trying to access a soap webservice through spring tool suite and maven.
I have done this using the source code from https://spring.io/guides/gs/consuming-web-service/ This works fine .
Dependancy is
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>1.5.8</version>
</dependency>
plugin is
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>Test3.wsdl</generatePackage>
<schemas>
<schema>
<url>http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
Now I have changed the url to a new link with https:
I can access the wsdl from my browser.
I am getting the error
"Execution default of goal
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed.
(org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate:default:generate-sources)"
I searched a lot for an answer.but could not find a soultion. would really appreciate a help.
Thankyou and Regards,
This is an SSLClient related issue, now there's several ways to fix this. From the eclipse IDE configuration perspective please refer : https://db-blog.web.cern.ch/blog/luis-rodriguez-fernandez/2014-07-java-soap-client-certificate-authentication . Now the best approach would be to have maven configuration changes as part of the build. This can be done using the properties-maven-plugin , here's a thread which discusses the same: SSL client certificate in Maven

maven-jetty-plugin does not run application on contextPath

maven-jetty-plugin is always running application on default context path ('/'). I tried running by setting contextpath property to 'test' but it does not work. http://localhost:8080/test is not accessible. It still runs on default context path.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>9.1.0.M0</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/test</contextPath>
</webApp>
<connectors>
<!-- work around file locking on windows -->
<connector implementation="org.mortbay.jetty.bio.SocketConnector">
<port>8080</port><!-- this connector defaults to 1300 for some reason -->
</connector>
</connectors>
</configuration>
</plugin>
using only
<contextPath>/test</contextPath>
instead of
<webApp>
<contextPath>/test</contextPath>
</webApp>
worked for me

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.

How to set display-name in maven-war-plugin for web.xml

How can I define the web.xml display-name via maven using the maven-war-plugin?
In maven-ear-plugin there is an configuration option displayName to set the EAR / application.xml display-name attribute.
Wrong approach? Just set it manually in web.xml?
You need to use Maven's web resource filtering approach. Set the following configuration in your maven-war-plugin :
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/</directory>
<targetPath>WEB-INF</targetPath>
<includes><include>web.xml</include></includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
And in your web.xml, you can use any properties defined in your pom.xml. So you could for instance use :
<display-name>${project.name} - ${project.version}</display-name>
That would be rendered as
<display-name>My Awesome Webapp - 1.0.0-SNAPSHOT</display-name>
If you use Eclipse, you'll need m2e-wtp (look at the web resource filtering screencast in the home page)
Much more simplier...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
see filteringDeploymentDescriptors's documentation. This is available since 2.1 but is disabled per default.

Resources