I'd like to create an application using the embedded version of Jetty. Unfortunately, I can't find any information on what jar files I would need to do that. There are several in the maven repository (http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/). But what's the difference between jetty-server, jetty-server-all, and jetty-webapp? Are any of these what I want for the embedded use case?
I stopped getting compile errors against the Eclipse embedded code minimal example combining SimplestServer and HelloWorldHandler...
http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
To achieve this I had to include the following from the lib directory in the unzipped distribution from eclipse's jetty mirror...
jetty-server-7.1.4xxxx.jar
jetty-util-7.1.4xxxx.jar
servlet-api.2.5.jar
This document lists the JAR files required for embedding and is pretty complete.
http://docs.codehaus.org/display/JETTY/Embedding+Jetty
I believe you won't need the Ant jar file unless you're invoking Jetty from Ant, even though it says you need it.
Some of the JSP jar files are named differently in the binary bundle than that document calls for, but this document helps figure out which Jetty JSP jars to use:
http://docs.codehaus.org/display/JETTY/JSP+2.0+v+JSP+2.1
I used jetty-webapp.
All the dependencies are very best explained in this diagram : http://wiki.eclipse.org/Jetty/Reference/Dependencies
Based on the diagram,for embedded use case, a minimum of 6 jars are required.
E.g for Jetty 8, try:
jetty-continuation-8..jar
jetty-http-8..jar
jetty-io-8..jar
jetty-server-8..jar
jetty-util-8.*.jar
servlet-api-3.0.jar
For completeness, the xml for jetty-webapp is;
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>8.1.2.v20120308</version>
</dependency>
Related
Trying to execute a Flink job, compiled with Maven, in Amazon Kinesis Data Analytics and I get the following error:
"org.apache.flink.client.program.ProgramInvocationException: Neither a 'Main-Class', nor a 'program-class' entry was found in the jar file."
I have tried several ways of defining the main class in the pom.xml-file.
Right now it looks like this:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.dataductus.maven.time_aggregator.TimeAggregator</Main-Class>
</manifestEntries>
</transformer>
Here is the pom.xml (the code gets weird when I format it in the comment):
https://textuploader.com/1cq7k
Here is the plugin:
https://textuploader.com/1cq7j
I use "mvn package" to package.
Any ideas?
You don't show the entire plugin configuration, or the command that you use to build the JAR, or the contents of the manifest file (if any), so there are many possible causes.
However, my guess is that you're using an older version of the plugin, so that the documentation here (which you seem to be following) may not apply.
The easiest solution is to follow the documentation here, has an explicit mainClass entry. I can assure you that works; I've been using it for at least ten years.
Thank you I will look at that.
Here is the pom.xml (the code gets weird when I format it in the comment):
https://textuploader.com/1cq7k
Here is the plugin:
https://textuploader.com/1cq7j
I use "mvn package" to package.
Problem solved. No idea what was wrong. I created another identical KDA-app which used the exact same jar and now it works. Strange.
I am trying to write a Dropwizard application and its doc tells me that I need to ship everything as an uber jar.
However, in my application I need to support multiple databases and this requires multiple database JDBC driver jars in my classpath, all of which are not expected to be shipped together with my application. Users are expected to place the corresponding JDBC jar like mysql-connector-java-5.1.39.jar in a particular folder by their own.
After reading Dropwizard's documentation I am not sure if this kind of usage is supported. Does anyone have experience making it to work this way?
Since java 6, you can wildcard classpaths.
Using the application plugin, the generated bin folder will have a start script that contains the classpath. What we want to do, is to instead of listing every possible jar in the bin folder, we simply include all of them.
Note: You can also do the same thing with different folders if you want the classpath in a different location.
This can be achieved (in a workaround manner since there are problems with this plugin in my version) in the easiest way as follows. In build.gradle you do:
startScripts {
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=\\$APP_HOME/lib/*')
unixScriptFile.text = unixScriptFile.text.replaceAll('CLASSPATH=.*', 'CLASSPATH=\\$APP_HOME/lib/*')
}
}
This will wildcard your lib folder in the start scripts. When starting up, your classpath will simply be
lib/*
When you drop jars into that folder, they will automatically be picked up (on startup, not on runtime).
I hope this helps,
Artur
I am deveoloping a custom plugin for Pentaho DI / Kettle 4.4 and use custom Validation and XSLT jars as part of it.
Those jars are referenced in plugin.xml along with the plugin's jar itself and deployed in the same location as the plugin's jar.
When I try to load this plugin in Spoon GUI, I can see and run the plugin fine till I reach the reference to the external jars and after that I get ClassNotFOund Exception.
I have tried following so far but has not worked :
Add the expernal Jars to libext folder and expect those to be picked up automatically. - Failed. Jars not loaded.
Add -cp command line option to Spoon.bat and specify the Jar files - Did not work.
Turned on -verbose option and search everywhere in the output but the Jars are ignored.
Deployed the Jars next to the plugin's Jar file in the plugin's folder. - Jars are not recognized.
From Within the plugin, if I dynamically load (using Reflection and URL Class Loader) I am able to force the loading of the Jars and it works that way but I would like a simpler classpath fix.
Any class that I reference in the Jar through XSL externsion (XALAN-J Java Extension) is still not recognized / loaded and XSL terminates at the beginning of Extension call.
Searched Google and this site for something similar but did not find specific answers on why SPoon behaves so differently and avoids external code and content.
A similar issue is reported here though its too old and has not shown final conclusive fix. I tried all that it said. http://forums.pentaho.com/archive/index.php/t-77190.html
Requesting someone to help me identify whats missing. Thanks in advance,
Thanks to this seemingly obscure website and it fixed all pain.
http://www.arulraj.net/2014/09/how-to-access-external-java-libraries-with-in-pentaho.html
Basically, go to the launcher folder and edit the launcher.properties file to include any path, library etc. and it fixes all the issues I reported above. Wish Kettle documentatation had answers like this.
Is there a way to fix the file locking issue caused by jetty entirely from gradle?
Some clarification:
When using the Gradle Jetty plugin by running gradle jettyRun, jetty causes the static resource files (html, css, js, etc.) to be locked when using Windows.
You can see a description of the problem in Files locked on Windows.
The same article also describes how you can fix that. Basically you have to either:
Disable the use of file mapped buffer
Not use NIO at all.
Both things require to add some jetty specific configuration files to the project, which I do not want to do - the jetty plugin is used only for convenience, and maintaining configuration for it does not feel right.
I do not need NIO for testing on the local machine, so any solution works.
Edit:
For now, I picked the option at which you set useFileMappedBuffer to false. This is how to do it:
Specify a path to your webdefault.xml like
[jettyRun, jettyRunWar,jettyStop]*.with {
//other configs
webDefaultXml = file("${project.webAppDir}/WEB-INF/jetty-webdefault.xml")
}
Get file from the latest 6.1.x distribution of jetty. The plugin seems to support only jetty 6. You can localte it at jetty-6.1.26\etc\webdefault.xml. Obviously, you have to place it at the path specified at the previous step.
Change the default servlet init parameter useFileMappedBuffer to false
I will research the option of using embeded jetty insted of the plugin.
I found a plugin that seem to be a better alternative:
https://github.com/akhikhl/gretty
Positives
Does not lock your files and support hot deployment (even something Gretty call "fast reload")
Gretty 1.2.0 uses Jetty 9.2.9.v20150224. Jetty plugin provided by Gradle 2.2.1 uses Jetty 6.1.25.
same task is used jettyRun (or more simply run).
"Press any key to stop the server". Jetty plugin required CTRL+C then Y.
From what I can tell, the documentation seem to be awesome (Gradle's not so much)
Negatives
A bit more bloated code to setup the buildscript's classpath dependency or apply plugin directly from URL (see doc)
Gretty crash unless you explicitly apply plugin: 'war' (Jetty plugin extends the War plugin)
Kiril answered his own question, many thanks. You should follow Kiril's instructions and this will help you find the appropriate webdefault.xml.
To find out what version of Jetty is started by Gradle, execute
gradle jettyRun -i
And you'll see something like this:
...
Tmp directory = determined at runtime
Web defaults = org/mortbay/jetty/webapp/webdefault.xml
Web overrides = none
Webapp directory = C:\dev\my-project\src\main\webapp
Starting jetty 6.1.25 ...
jetty-6.1.25
...
It took me a while to find a copy of Jetty 6.1.25 as it is no longer listed on the Jetty download page (not even in the archive section!).
You can then grab the appropriate copy of webdefault.xml from here, adjusting the version number as appropriate for your needs:
http://grepcode.com/file/repo1.maven.org/maven2/org.mortbay.jetty/jetty/6.1.25/org/mortbay/jetty/webapp/webdefault.xml
I recently "solved" a somewhat common problem in OC4J regarding the use of Xerces rather than OC4J's built-in parser. The problem was solved by adding this line to global-web-application.xml:
<web-app-class-loader search-local-classes-first="true"/>
Unfortunately, this was too much of a big-hammer approach that could cause problems on the app server, so I tried to resolve it via creating the following orion-web.xml file in the WEB-INF directory of the app:
<?xml version="1.0"?>
<orion-web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-web-10_0.xsd">
<web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true"/>
<web-app/>
</orion-web-app>
Unfortunately, it turns out that using global-web-application.xml worked, using orion-web.xml didn't
OC4J version is 10.1.3.5.
Can anyone advise?
Another way is specify at Deploy Time. Take a look:
Specifying search-local-classes-first at Deployment Time
The following example illustrates how to set the search-local-classes-first attribute in the orion-web.xml file generated for the Web module at deployment time, with Application Server Control.
Select Applications>Deploy to launch the Application Server Control deployment wizard.
Supply the path to the application in the first page of the wizard.
Specify the application name and supply any context URI mappings in the second page.
Click Configure Class Loading in the third page of the wizard (Deploy: Deployment Settings).
Under Configure Web Module Class Loaders, check the Search Local Classes First checkbox next to the name of the Web module containing the local JAR file to use.
Optionally click the Save Deployment Plan button, and save the plan for reuse.
I think you could solve this in a different manner. Using properties, and removing libraries.
There are two properties:
xml.driver.property
xml.driver.impl
One define the parser interface and the other the implementation. You can switch this from one implementation from another.
for example we have:
xml.driver.property=org.xml.sax.driver
xml.driver.impl=org.apache.xerces.parsers.SAXParser
As this is a system properties you can load it in many different ways. We use a special servlet installed in all OC4J instances (containers) that loads this an other properties at runtime.
A "little" bit late but hope it helps.
Finally I'm abble run JAXB2 (used by Spring WS 2.1.4) on my OC4J 10.13 (and 10.13.50). JAXB needs xalan lib.
orion-web.xml
<?xml version="1.0"?>
<!DOCTYPE orion-web-app PUBLIC "-//Evermind//DTD Orion Web Application 2.3//EN"
"http://xmlns.oracle.com/ias/dtds/orion-web.dtd">
<orion-web-app
persistence-path=""
jsp-cache-directory="./persistence"
jsp-cache-tlds="standard"
simple-jsp-mapping="false"
temporary-directory="./temp"
servlet-webdir="/servlet/"
>
<web-app-class-loader search-local-classes-first="true"/>
</orion-web-app>
maven pom.xml
<!-- JAXB implemetation by EclipseLink MOXy-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
</dependency>
<!-- Specific dependencies for OC4J v1013 -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>