Maven Jetty Plugin - Disable Http Trace - jetty

I have a maven project with a web.xml and run it using mvn jetty:run
How can I disable the http-tracing?
Edit: I looked here but I was unable to identify the relevant tags...
This is the relevant plugin:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<jettyXml>src/jetty.xml</jettyXml>
</configuration>
</plugin>

Two things.
Jetty 9.2 is EOL (End of Life) - consider upgrading to something supported and stable (such as the recently released 9.4.14.v20181114)
The TRACE method in HTTP is disabled by default (via the webdefaults.xml descriptor).
The only way you can use TRACE is to both intentionally configure your webapp to use a custom default descriptor without this constraint (which your <configuration> section doesn't do), and have a Servlet that implements doTrace() or service() methods to support the TRACE method.

Related

What is the best way to save and publish version in Cloud Foundry app?

What is the best way to save and publish git version of Cloud Foundry app?
Is it possible to specify what version string aka git revision should be added to application metadata, and how to get this information outside of app?
If you are using spring boot there are plugins for maven and gradle to git information to the build.
Maven:
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
</plugins>
</build>
Gradle:
plugins {
id "com.gorylenko.gradle-git-properties" version "1.4.17"
}
The information will then be available on /info if you are using actuators
More information:https://docs.pivotal.io/pivotalcf/1-12/console/spring-boot-actuators.html

How do I get deploy-war to work using jetty 9 maven plugin?

In jetty-9 the mvn jetty:deploy-war fails to start the web application. Maven just ends the build, while I expect it to block with a running jetty server. According to the logging output the jetty maven plugin does start a connector on port 8080, and it starts the WebAppContext. It seems to fail binding the port to the context though.
Steps to reproduce:
Create a web app: mvn archetype:generate -DinteractiveMode=false -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=jetty -DartifactId=jetty-demo
Add this plugins-section to the pom:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.10.v20150310</version>
</plugin>
</plugins>
...
</build>
Execute:
mvn package
mvn jetty:deploy-war This should start the web app and then block, but it just ends the build
Using jetty-8 all works fine:
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.16.v20140903</version>
Note: mvn jetty:run-war works as expected in jetty 9. This is the same as deploy-war, but it triggers jetty to build the war before deployment
Reference: the jetty-9 maven plugin manual. And I debugged the jetty startup proces, but without luck so far.
The documentation you linked to tells you why.
Set the daemon parameter to false and it will block

Writing a custom feature

We would like to write our own custom extension (feature) for wso2 carbon. Is there some documentation for authoring features?
We did manage to just "hack" our way into writing a custom feature. But how do we host it? It seems Carbon is looking at some very specific repository descriptors - artifacts.jar and content.jar
How can we generate these descriptors without tying into the Carbon build. Is there some documentation describing how to setup a third party feature repository?
Creating-your-own-wso2-carbon-components webinar discusses creating carbon components, and a feature for those components. It covers quite a lot of basics, and best practices as well.
To host the created features you have written, you need to generate a p2-repository from those features. p2-repo concept comes from the underline Eclipse equinox project that WSO2 products use.
WSO2 have written its own maven plugin called carbon-p2-plugin that helps to generate a p2-repo. Here's how you can do that. Simply create a new maven project (packaging: pom), and then set the features you want to publish under the carbon-p2-plugin plugin configuration. Following is a sample pom.xml that you can use. This was copied from the p2-repo generation pom.xml of carbon 4.1.0, and I simplified it.
I have tested this pom file, it worked for me. There are two sample feature definitions. Replace those featureArtifactDef with your own feature definitions. The format is $groupId:$artifactId:$version.
When you build this via maven, maven creates the target/p2-repo directory. This contains the p2-repository which contains the complete p2-repo including artifacts.jar and content.jar. You can just use this folder to install features, or you can host it somewhere. There're no special requirements on hosting.
<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">
<parent>
<groupId>org.wso2.carbon</groupId>
<artifactId>carbon-features</artifactId>
<version>4.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mysample-feature-repository</artifactId>
<version>4.1.0</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Feature Repository</name>
<build>
<plugins>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<id>2-p2-repo-generation</id>
<phase>package</phase>
<goals>
<goal>p2-repo-gen</goal>
</goals>
<configuration>
<p2AgentLocation>${basedir}/target/p2-agent</p2AgentLocation>
<metadataRepository>file:${basedir}/target/p2-repo</metadataRepository>
<artifactRepository>file:${basedir}/target/p2-repo</artifactRepository>
<publishArtifacts>true</publishArtifacts>
<publishArtifactRepository>true</publishArtifactRepository>
<featureArtifacts>
<!-- change the featureArtifactDef to match your needs -->
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.service.mgt.feature:4.1.0
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.feature:4.1.0
</featureArtifactDef>
</featureArtifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Jetty server best IDE

I want to use Jetty 8.0 Server for my application. Which IDE i will use for simple configuration.
Presently i am using Eclipse. How to configure jetty in Eclipse. Any best example?
I use run-jetty-run, and jetty with maven in eclipse.
http://code.google.com/p/run-jetty-run/
More on jetty maven plugins:
http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
I use run-jetty-run with DCEVM for hotdeploy.
Here's my tutorial, Spring-mvc + Velocity + DCEVM
Most people I know simply write a small embedded usage of jetty for their application. It is dead simple to do and there are a number of examples in the example-jetty-embedded project in jetty git repository. It is also how most of our test cases are written, using jetty itself to test.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/example-jetty-embedded
If your using maven then the jetty-maven-plugin is a pretty simple way of testing and works with the eclipse plugin Webby which streamlines much of the pain and suffered that is called WTP.
https://docs.sonatype.org/display/M2ECLIPSE/Integration+with+Maven+WAR+Plugin
There is also a Jetty WTP plugin that many people use successfully.
http://wiki.eclipse.org/Jetty_WTP_Plugin
I also use run-jetty-run for Eclipse.
I tried the Jetty plugin for NetBeans, but it didn't work.
I think Jetty for Eclipse is better than Tomcat, cause its simpler to use and configure and a fast server.
Assuming you have setup M2Eclipse plugin within Eclipse correctly and your project is configured to use Maven, I've found Jetty Maven Plugin within Eclipse to be particularly useful. The beauty of this approach is that you can do your development really fast, especially if you have 3rd party dependencies. All you have to do is add the following plugin to your pom.xml:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<contextPath>/</contextPath>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
To use this plugin successfully here some additional notes on installation and usage:
Eclipse Integration
Install the following Eclipse Plugins first
Maven Integration for Eclipse (Help > Eclipse Marketplace...)
A patch that makes it possible to debug source code at runtime. Eclipse Plugin Link
Next, create a "Maven Build" Eclipse Launcher
You also need to configure "Maven Build" launcher so that you can run the Jetty Server quickly. Follow the instructions below create this launcher:
Right-click on your current project and select (Run As/Debug As) > Maven Build...
Set Goals As rhubarb:start
Check Resolve Workspace artifacts
Save
Going forward, you can simply do: (Run As/Debug As) > Maven Build, and the goal will execute.

Has anyone successfully run integration tests with Jboss embedded, Seam and Maven?

Have been trying to get integration testing working with my seam project and the Jboss embedded container but am not having much success. Have been doing a lot of reading and have been trying what is mentioned in this JIRA but am not having any luck.
Amy currently just trying to get the 'testproject-master-JBSEAM-2371.zip' project working but am getting the following exception
ERROR [org.jboss.embedded.DeploymentScanner] Failed to deploy
org.jboss.deployers.spi.DeploymentException: No deployer recognised the structure of vfsfile:/Users/aaron/Development/eclipse_workspaces/workspace_pink/testproject-web/target/test-classes/conf/jboss-service.xml
at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.determineStructure(VFSStructuralDeployersImpl.java:219)
at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:77)
Has oneone had any luck with getting the Seam integration tests working using maven and NOT a seam-gen project?
I gave up on the embedded JBoss and switched with using the Maven JBoss Plugin to deploy to a JBoss instance started as a separate process. Not ideal but there were to many conflicts with our code and Maven to get around. Is there a reason you need the embedded version?
You should be able to do something like this to deploy to JBoss in the pre-integration test phase so the integration test could run against. You would still have to launch jboss before maven. Not ideal, but this is working for me.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<jbossHome>/opt/JBoss/current</jbossHome>
<port>8080</port>
</configuration>
</execution>
</executions>
</plugin>