Jetty startup is slow with BouncyCastle included in classpath - jetty

I'm using jetty-maven-plugin as a plugin in maven project. Plugin starts up in 2-4 seconds, but when i include org.bouncycastle:bcprov-jdk15on:1.52 as a dependency, the startup time is increased to ~35-60 seconds. What's happening in the background and how can I fix this?

This addition in the web.xml solve my slow startup
<absolute-ordering>
<name>dummy</name>
</absolute-ordering>

I finally could avoid unnecessary scanning by excluding BC inside jetty-web.xml:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>^((?!bcprov).)*$</Arg>
</Call>
</Configure>
with plugin configuration:
<contextXml>src/main/webapp/WEB-INF/jetty-web.xml</contextXml>

Related

AXIS2 not generating all classes for WSDL file

I am new to webservices. I am trying to change the my application webservices from JBOSS(Currently using) to AXIS2. Using JBOSS everything is worked fine but the same WSDL when i gave as input to AXIS2 wsdl2java.bat, it is not creating all the classes and stubs which leads to compile error as the compiler missed many files. Could you please any one tell me that, what could be the reason and solution for the case. My build script mentioned below. I have been doing my R&D since 1 week and didnt find any clue. Hope your answers will lead me to further steps...
<target name="make-server-template">
<!-- Using AXIS2 -->
<echo>Generating and compiling ${service_name}. ${server.def.package}..</echo>
<exec dir="." executable="${wsconsume}">
<arg line=" -o ${server.srcautogen.dir}
-p ${package.name}
-uri ${wsdl.dir}/${wsdl.file}"/>
</exec>
<!-- commented.... Using JBOSS ..Everything is perfect
<exec dir="." executable="${wsconsume}" error="${wsc.logfile}">
<arg line="-s ${server.srcautogen.dir} -o ${serverbuild.dir} -k
-e -p ${package_name} ${wsdl.dir}/${wsdl.file}"/>
</exec> -->
</target>
<target name="make-server-artifacts" depends="clean,prepare">
<antcall target="make-server-template">
<param name="service_name" value="WSDLFILE"/>
<param name="package.name" value="${server.def.package}"/>
</antcall>
Thanks & Regards
Assume that all missing files are related to axis2.
When you generated java files for your web services using axis2, it generates Java classes that related to the WSDL file only. But it refers most of axis2 classes in order to make the communication work with web service.
Therefore, if you want to use those files in your code, you have to include most of axis2 libraries in your project's classpath.
As the first step, include all jar files you can find in axis2/lib folder into your project. It will work.

Create code coverage report starting at root folder

I have just created a new zend framework application to try out unit testing.
I have followed this tutorial and everything seems to be working correctly for testing. There is a problem with the display of the coverage report. It displays the correct information, but the report starts at the root of my hard drive and I need to traverse the tree to my project folder to see useful information.
This means that every time I ran the tests, I need to click 5 folders deep to get to the actual report.
How do I make the report start in my project folder? This is my phpunit config file:
<phpunit bootstrap="./bootstrap.php">
<testsuite name="Application Test Suite">
<directory>./application</directory>
</testsuite>
<testsuite name="Library Test Suite">
<directory>./library</directory>
</testsuite>
<filter>
<whitelist>
<directory>../../library/Zend</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
<file>../application/Bootstrap.php</file>
<file>../application/controllers/ErrorController.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
hightlight="true" lowupperbound="50" highlowerbound="80">
<log type="testdox" target="./log/testdox.html">
</log>
</log>
</logging>
</phpunit>
I fixed the problem...
I needed to explicitly specify my application folder in the whitelist. If it is empty, the code coverage report just starts from 'c:' and tries to find every '.php' file.
After adding the line in the whitelist section:
<directory>../application/</directory>
It works as expected.
Since I don't have any library tests in my test folder, including the Zend library folder probably had no effect and the report must have considered the whitelist empty. And because there is no blacklist, it just started from the root.
The code coverage starts at the most common path for all files included in the report. So if your web root is in /var/www and you include libraries in /usr/local/zend/ the most common path will be the root path.
The solution would be to exclude the library path because usually you don't want to measure the code coverage for external libraries anyway.

ivy report for entire repo?

I'm working on an internal ivy repository with a decent number of projects under it, each with many revisions. I would like to make a dependency report for the entire repository showing which versions of which artifacts depend on which revisions of other artifacts. Obviously it isn't too difficult to make a script to parse the published ivy xml files, but if this functionality exists already I'll use that. Something like the repreport task would be nice, but for a whole repo.
My main goal here is to get a report of artifacts that are not referenced by any other artifacts so as to make a list of candidates for removal from the repo.
So, does ivy have any way to build a dependency report against and entire repository?
Edit: Working through this, it looks like ivy:repreport is the way to go.
Here is my build.xml file:
<project name="Report Build" xmlns:ivy="antlib:org.apache.ivy.ant" basedir=".">
<property name="ivy.version" value="2.2.0"/>
<property name="ivy.home" value="${user.home}/.ivy2"/>
<target name="fetch-ivy" unless="offline" description="Install Ivy if it doesn't already exist">
<mkdir dir="${ivy.home}"/>
<get
src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
dest="${ivy.home}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="fetch-ivy" unless="ivy-initialized">
<path id="ivy.lib.path">
<fileset dir="${ivy.home}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<property name="ivy-initialized" value="yes"/>
</target>
<target name="report" depends="init-ivy">
<ivy:settings file="ivy-settings-report.xml" id="report.ivy.settings"/>
<ivy:repreport settingsref="report.ivy.settings"/>
</target>
</project>
And here is my ivy settings file:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
<settings defaultResolver="main"/>
<resolvers>
<chain name="main">
<url name="internalartifacts" m2compatible="false">
<artifact
pattern="http://internalartifacts.local/[organization]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
<ivy pattern="http://internalartifacts.local/[organization]/[module]/[revision]/ivy-[revision].xml"/>
</url>
</chain>
</resolvers>
</ivy-settings>
The documentation for repreport says:
To generate a xml report for all the latest versions of all the
modules in your repository:
<ivy:repreport />
Limitation: this task requires to be able to browse the repository,
and is thus limited to resolvers supporting repository listing. In
particular, it means it doesn't work to report all organizations in a
repository using m2compatible mode. Moreover, to be able to list
organizations, this task requires an [organisation] token in the
resolver(s) used.
So this should totally work.
As mentioned in the comment:
It is important that your repository has ivy.xml files for the artifacts in it. Otherwise ivy cannot recognize the dependencies between the artifacts and your report will be empty.

How do I create a jetty 6 and jetty 7 compatible jetty-web.xml file in the same war file?

In Jetty 6 I need to create a WEB-INF/jetty-web.xml file which contains this:
<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
But in Jetty 7 I need the same exact file WEB-INF/jetty-web.xml to contain this:
<Configure id="webAppCtx" class="org.eclipse.jetty.webapp.WebAppContext">
Both files differ (org.mortbay vs org.eclipse). How do I create 1 war file which is compatible with both jetty 6 and jetty 7?
I don't know if this can be done in one file, but you could use an ANT build script to create two version-specific WARs (my bad if you're already doing this)
Before calling the war build, have ANT copy your Jetty 6 or 7 WEB-INF/jetty-web.xml file in your war basedir and then call something like:
<target name="buildwar">
<buildnumber />
<war basedir="dist/web" destfile="${warName}-jetty${jettyVersion}.war"
webxml="dist/WEB-INF/web.xml">
<webinf dir="dist/WEB-INF/">
<include name="**/*.jar" />
</webinf>
<manifest>
<attribute name="displayName" value="${warDisplayName} for Jetty ${jettyVersion}" />
<attribute name="Implementation-Version" value="${build.number}" />
</manifest>
</war>
</target>
Poor man's solution: build 2 wars for Jetty.
I am thinking about using maven assembly scripts to build multiple wars, However, I need to completely duplicate the jetty-web.xml file for both versions in my sources.

ant cpptask with ivy

A company I am working for, has some c binaries build with ant using cpptask. They use ivy to retrieve shared c libraries every time we start a build which wastes a significant amount of time comparing the revisions and downloading, when then only need to be download if the header files have changed. I have added a target which sets a var, which causes the build to skip over the ivy steps but I'd like a better solution. I see that cpptask creates a file history.xml and only rebuilds to binary if any of the sources have change. I'd like to know if there is way to independently test if the binary needs to build, and it does, I'd like it fire off the ivy targets. I'd also like for a variable to be set if the binary was rebuilt so that I can conditionally start an rpm generation task
<project name="conditional_compile" default="build">
<condition property="file.modified">
<isfileselected file="test.txt">
<modified/>
</isfileselected>
</condition>
<target name="build" if="file.modified">
<echo message="This is a compile step that depends on the modification of a file"/>
</target>
</project>