When I want to start my Jetty8 Server on Windows XP I get an Error:
java.io.FileNotFoundException: No XML configuration files specified in start.con
fig or command line.
at org.eclipse.jetty.start.Main.start(Main.java:502)
at org.eclipse.jetty.start.Main.main(Main.java:96)
Usage: java -jar start.jar [options] [properties] [configs]
java -jar start.jar --help # for more information
I start my Jetty Server like this:
java -jar path/to/jetty/start.jar
I read that I have to specify my Jetty Home somewhere, is this the problem?
I found it out by myself, you have to start the jetty server with
shell> start java -jar start.jar
to load all environment variables correctly.
Related
This is the original running script of burpsuite, and there is no problem in the java8 environment.
java -Dfile.encoding=utf-8 -javaagent:BurpSuiteCn.jar -Xmx1024m -noverify -Xbootclasspath/p:burp-loader-keygen-2.jar -jar burpsuite_pro_v2.1.jar
But it will report an error in java17
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
-Xbootclasspath/p is no longer a supported option.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Now changing to java17, how do I update my startup script?
I have installed tomcat in my PC (Windows 10). Is there anyway that I can find the installation path of tomcat? I thought of making use of the command line with which java used to call the startup.bat file but then I realized that the command line keeps changing depending on how it is called. I have to find the installation path of tomcat programmatically using c++.
Updated : I need to find the installation path only if tomcat is running
You could execute jps -lv and parse the results.
A Tomcat Java process would look like
12345 org.apache.catalina.startup.Bootstrap ... -Dcatalina.base=<some_path> ...
Where 12345 is the PID and <some_path> is the home of Tomcat.
Beware that there could be multiple instances of Tomcat running.
I have a simple JDBC project that fetches data from a database. I have used mysql-connector-java-5.1.12.jar for jdbc connection.
Now I want to create an executable jar of my project from command line (not from eclipse).
I tried using :
jar cfe myJar.jar com/demo/MySqlJDBC com/demo/MySqlJDBC.class
The jar was created, but it doesn't contain mysql-connector jar and so when I run the jar as:
java -jar myJar.jar
I get error like:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
So, my question is how can I pack the mysql-cnnector-jar while creating jar of my project without using maven and eclipse (just from command line)
I have a jetty 9 installed on CentOS in /srv/jetty, and I have a webapp deployed inside jetty.
When I start jetty with java -jar start.jar & then inside the web application I can do this:
File base = new File(".");
System.out.println("Base Dir: " + base.getAbsolutePath());
And it returns me the correct directory of the jetty installation.
But then I add jetty as a linux service, to run with a user called jetty, and start with service jetty start then calling the above code, will allways give me back the home directory of the user, who is running jetty in this case /home/jetty/ or if I run as root then /root/
How can I set up jetty to find the correct directory? I tried with jetty.home in the config files, but nothing seems to work.
You have a few things to worry about.
The noteworthy paths for a WebApp on Jetty:
ServletContext Real Path
Jetty Home
Jetty Base (starting in Jetty 9.1)
ServletContext Real Path
All WebApps that are deployed and started, will occupy either a work directory, or a temp directory (on the whim of the container). The servlet spec mandates that this path should be discoverable via the ServletContext for that webapp. You can find out where your WebApp is, by calling ServletContext.getRealPath("/")
See my prior answer for 5 different ways you can configure this work/temp directory:
https://stackoverflow.com/a/19232771/775715
Jetty Home
By default, all Jetty Distribution instances will have a System Property called jetty.home that will be the path to the Jetty Home location on disk. This is to be assumed to be where the Jetty Binaries and Distribution configurations are found.
Jetty Base
Starting in Jetty 9.1, there is also a mandatory System Property called jetty.base that is where your specific instance of jetty's configuration + libraries + webapps are housed. This is often a different directory than jetty.home.
This separation of binaries vs configuration is a core concept of Jetty 9.1, adopting a clear separation will making upgrading the Jetty binaries easy.
See http://www.eclipse.org/jetty/documentation/current/startup-base-and-home.html
I thing I have found the easy answer:
usermod -m -d /srv/jetty jetty
As it was advised in many places on the internet I created a user jetty to run the jetty service. So whatever I did -even if I set JETTY_LOGS- the log files allways ended up in the users home directory. By modifying the jetty users home directory the File(".") and the logs all end up where I wanted to
I am new to Jetty and client/server architectures.
I managed to write a jetty server in eclipse and it works.
But how I can stop a jetty server? I heard something about stop.jar and start.jar. Where I can find it? Is it integrated in jetty-all-jar?
The various jetty-all.jar artifacts can be used for embedded jetty usage. If you decide to use this jar, you have to manage your own startup / shutdown.
Update: 2015 : As of Jetty 9, the use of jetty-all.jar as a dependency is deprecated. This is because as of Jetty 9, it is now impossible to satisfy "all" of Jetty in a single aggregate jar. There are components of Jetty that cannot be included as they will cause problems with this aggregate jar. The future of Jetty, with HTTP/2 support, also makes this aggregate jar less useful as a dependency.
Typical Embedded Mode usage
The thread that starts the server:
Server server = new Server();
// various server configuration lines
// ...
// Start server (on current thread)
server.start();
// Have current thread wait till server is done running
server.join();
The other thread that tells the server to shutdown
// Have server stop running
server.stop();
At this point the original thread's wait on server.join(); is complete and that thread continues to run.
Standard Distribution Usage
If you use the standard distribution available from download.eclipse.org/jetty/ you have the start.jar that can be used to start/stop jetty itself.
Once you have unpacked your jetty-distribution, you'll find a start.jar in the top most directory. This can be used as the following.
The process that starts jetty:
$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret
The process that stops jetty:
$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret --stop
If jetty as maven plugin, you stop the server by pressing Ctrl+C and press Y to confirm terminate.