Jetty can't find web application file - jetty

I've installed jetty using PKGBUILD from AUR. The configuration was left default.
Note: since makepkg was unable to download jetty v.9.3.2 from offical site, I downloaded it from maven repository
The problem is that when I try to deploy my web application using Jetty Deployable Descriptor XML File, jetty fails to find the war with the following exception:
2016-01-27 17:05:30.265:WARN:oejw.WebInfConfiguration:main: Web application not found /home/pmitrofanov/sample.war
2016-01-27 17:05:30.265:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext#1efbd816{/sample,null,null}{/home/pmitrofanov/sample.war}
java.io.FileNotFoundException: /home/pmitrofanov/sample.war
at org.eclipse.jetty.webapp.WebInfConfiguration.unpack(WebInfConfiguration.java:495)
at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:72)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:474)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:510)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:499)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:147)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:459)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:392)
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:561)
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:405)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:372)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1510)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1435)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:214)
at org.eclipse.jetty.start.Main.start(Main.java:457)
at org.eclipse.jetty.start.Main.main(Main.java:75)
Here is the contents of the xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/sample</Set>
<Set name="war">/home/pmitrofanov/sample.war</Set>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Max Form Size -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="maxFormContentSize">5000000</Set>
</Configure>
It should be mentioned that:
When I manually put the war into the webapps directory instead of using xml, everything goes fine.
All users have rwx access to the war: -rwxrwxrwx 1 pmitrofanov pmitrofanov 25104375 Jan 27 16:37 /home/pmitrofanov/sample.war

A few things to point out...
The Jetty XML format and syntax has changed for Jetty 9.3 it has a new DTD (Highly encouraged you use it)
Jetty 8 is EOL (End of Life)
As of Servlet 3.x, if you are doing file uploads via POST, its better to use #MultipartConfig or <multipart-config> to define locations, sizes, limits, etc. (not the WebAppContext settings)
As of Jetty 9, if you are working with large request headers (hinted at by your 5,000,000 byte max form content setting) you'll probably need to be aware of the Connector's HttpConfiguration which limits the request header sizes more severely then your WebAppContext settings.
In your example, the ${jetty.base}/webapps/sample.xml on startup it will immediately look for the war file, if it cannot find it it will not deploy. (you are using a ${jetty.base} with Jetty 9, right? you shouldn't be modifying/adding/deleting files in the jetty distribution, ever)
Merely replacing the war will NOT redeploy the war file. You'll have to touch the ${jetty.base}/webappps/sample.xml to trigger a redeploy.
There is no provision for monitoring resources referenced in the XML, only the content in ${jetty.base}/webapps/

The problem is that nobody except the owner has read+execute access to /home/pmitrofanov directory.

Related

WSO2 APIM 3.0.0 REFUSED TO START AFTER EDITING master-datasources.xml file

I installed wso2am-3.0.0 as a service on linux machine and i changed the default database to mysql by editing the master-datasources.xml file. However, when i start the service by running sudo service wso2am-3.0.0 start, I got stucked here as shown below:
TID: [2020-02-19 00:16:22,738] INFO {org.wso2.config.mapper.ConfigParser} - Applying Configurations upon new Templates {org.wso2.config.mapper.ConfigParser}
TID: [2020-02-19 00:16:22,739] WARN {org.wso2.config.mapper.ConfigParser} - Configurations Changed in :repository/conf/datasources/master-datasources.xml {org.wso2.config.mapper.ConfigParser}
TID: [2020-02-19 00:16:22,739] WARN {org.wso2.config.mapper.ConfigParser} - Configurations Changed in :repository/conf/carbon.xml {org.wso2.config.mapper.ConfigParser}
TID: [2020-02-19 00:16:22,739] WARN {org.wso2.config.mapper.ConfigParser} - Overriding files in configuration directory /usr/lib/wso2/wso2am/3.0.0 {org.wso2.config.mapper.ConfigParser}
And nothing else happens
From API Manager v3.0.0, we have introduced a new configuration model where now you have a deployment.toml to configure. You don't need to touch any xml config files. deployment.toml can be found in repository/conf location. Although you change the configs in xml files, those will be overridden when server starts up.
Please refer how you can change databases to mysql - https://apim.docs.wso2.com/en/3.0.0/InstallAndSetup/SettingUpDatabases/ChangingDefaultDatabases/changing-to-mysql/

Jetty deployment: Unable to compile class for JSP

I tried to deploy to and run Jetty from an Ant-script, but get the following error:
[jetty.run] 2016-06-25 09:16:54.333: Starting web application null
[jetty.run] [main] WARN org.eclipse.jetty.annotations.ServletContainerInitializersStarter -
[jetty.run] javax.servlet.ServletException: Not running on Jetty, WebSocket+CDI support unavailable
[jetty.run] at org.eclipse.jetty.cdi.websocket.WebSocketCdiInitializer.onStartup(WebSocketCdiInitializer.java:49)
[jetty.run] at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
[jetty.run] at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63)
[jetty.run] at
...
It work without deployment, but with the war-file this happens. What is corrupt?
UPDATE:
Added
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
to web.xml andweld jars to lib. Now I get this:
java.lang.reflect.InvocationTargetException
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[jetty.run] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[jetty.run] at ...
[jetty.run] Caused by: java.lang.IllegalStateException: Nothing to bind for name BeanManager
UPDATE 2:
Ok, I didn't need the extra things in my web.xml. Instead I had forgot to add
<typedef name="webApp" classname="org.eclipse.jetty.ant.AntWebAppContext" classpathref="classpath" loaderref="jetty.loader"/>
to build.xml. I can now deploy and run jetty, but can't process JSP files:
[jetty.run] [qtp1387380406-14] WARN org.eclipse.jetty.servlet.ServletHandler -
[jetty.run] org.apache.jasper.JasperException: Unable to compile class for JSP
[jetty.run] at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600) ...
Why is this so?
Remove the various jetty cdi jar files from your project.
Those are designed specifically for jetty-distribution use, and are inappropriate for embedded-jetty.
Use the weld jars directly in your war file, along with the various recommended configurations that the weld project documentation tell you about.

Can't deploy external app to jetty 9.0.6.v20130930

When I'm deploying my app by copying it inside jetty/webapps it deploys ok. But I want to deploy it from external directory. For that I've created following myconf.xml:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="myapp" class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="server">
<Ref refid="Server" />
</Set>
<Set name="contextPath">/myapp</Set>
<Set name="war">
<SystemProperty name="myapp.war" /><!-- points to the external war -->
</Set>
</Configure>
Then jetty is ran with:
java -XX:-UseSplitVerifier -jar start.jar myconf.xml.
In the console I see that application is being deployed, it accesses db etc, but when I try to reach it I got 404. Any help is highly appreciated :)
Best regards, Eugene.
That's not how you use Jetty.
Option 1: Standard Automatic Deployment
Since you are not customizing anything with the deployment, just delete the myconf.xml entirely.
Copy your myapp.war into the ${jetty.home}/webapps/ directory.
Start Jetty. $ java -jar start.jar
This is known as Automatic Web Application Deployment.
Option 2: Standard Context Deployment
Now, if you want to customize the deployment, (say for example you want to tweak the context path it listens on, or if you want to disable the extractWar process, or you have custom init parameters, or you even want to change the behavior of the Default servlet, etc...), then do the following ...
Copy your existing myconf.xml to ${jetty.home}/webapps/myapp.xml (note the name change)
Copy your myapp.war to ${jetty.home}/webapps/myapp.war (note, the basename for this file should be the same as your XML)
Edit your ${jetty.home}/webapps/myapp.xml to change the deployment behavior (eg: <Set name="contextPath">/app/1</Set>)
Start Jetty. $ java -jar start.jar
This is known as Configuring Specific WebApp Deployment.
Option 3: Customized Context Deployment
If you want to keep your war file somewhere other than ${jetty.home}/webapps/, you will still need to do the following:
Copy your existing myconf.xml to to ${jetty.home}/webapps/myconf.xml.
Leave your myapp.war where you want it. For example /opt/webapps/myapp.war
Edit your ${jetty.home}/webapps/myconf.xml to set the contextPath and war entries.
Start Jetty. $ java -jar start.jar
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="myapp" class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="server">
<Ref refid="Server" />
</Set>
<Set name="contextPath">/myapp</Set>
<Set name="war">
<SystemProperty name="/opt/webapps/myapp.war" />
</Set>
</Configure>
Option 4: Jetty Base Automatic Deployment (Available in Jetty 9.1+)
There is another technique, available starting with Jetty 9.1, using the split ${jetty.home} and ${jetty.base} concepts + the Automatic Deployment from above.
Lets say you have jetty-distribution-9.1.x unpacked into /opt/jetty/ and you have your webapp + configuration in /opt/myapps/. You can do the following commands.
[user]$ cd /opt/myapps
[myapps]$ java -jar /opt/jetty/start.jar --add-to-start=server,deploy,websocket,ext,resources
server initialised in ${jetty.base}/start.ini (appended)
server enabled in ${jetty.base}/start.ini
deploy initialised in ${jetty.base}/start.ini (appended)
deploy enabled in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/webapps
server enabled in ${jetty.base}/start.ini
websocket initialised in ${jetty.base}/start.ini (appended)
websocket enabled in ${jetty.base}/start.ini
server enabled in ${jetty.base}/start.ini
ext initialised in ${jetty.base}/start.ini (appended)
ext enabled in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/lib
MKDIR: ${jetty.base}/lib/ext
resources initialised in ${jetty.base}/start.ini (appended)
resources enabled in ${jetty.base}/start.ini
MKDIR: ${jetty.base}/resources
[myapps]$ ls -l
total 16
drwxrwxr-x 3 user group 4096 Oct 31 08:32 lib/
drwxrwxr-x 2 user group 4096 Oct 31 08:32 resources/
-rw-rw-r-- 1 user group 369 Oct 31 08:30 start.ini
drwxrwxr-x 2 user group 4096 Oct 31 08:30 webapps/
[myapps]$ cat start.ini
--module=server
threads.min=10
threads.max=200
threads.timeout=60000
jetty.dump.start=false
jetty.dump.stop=false
--module=deploy
--module=websocket
--module=ext
--module=resources
[myapps]$ java -jar /opt/jetty/start.jar --list-config | grep -E "jetty.(base|home)="
jetty.home=/opt/jetty
jetty.base=/opt/myapps
[myapps]$ cp /home/user/project/myapp/target/myapp-1.0.war /opt/myapps/webapps/myapp.war
[myapps]$ java -jar /opt/jetty/start.jar
2013-10-31 08:35:58.919:INFO:oejs.Server:main: jetty-9.1.0.RC0
2013-10-31 08:35:58.939:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/opt/myapps/webapps/] at interval 1
2013-10-31 08:35:59.109:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /myapp, did not find org.apache.jasper.servlet.JspServlet
2013-10-31 08:35:59.189:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext#223ff173{/myapp,file:/tmp/jetty-myapp.war-_myapp-any-/webapp/,AVAILABLE}{/myapp.war}
What you'll notice is that you have 2 locations you can work with.
${jetty.home} - where your jetty-distribution is located
${jetty.base} - where your app's specific configuration and wars are located
This is a pretty powerful option, and I've only touched the surface of its capabilities.

jetty 9 symlink to exploded war

I've just upped to Jetty 9 from 8 and have an odd issue. My development environment is an exploded war, so I simply drop a symlink (ROOT) into my jetty/webapps directory pointing to my exploded war. This worked just fine for Jetty 8, but seems to fail for Jetty 9.
First, the symlink is now 'root', per the documentation. But when I hit my server '/' it gives me a 404 and this:
Error 404 - Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:
/war ---> o.e.j.w.WebAppContext#613714d3{/war,file:/home/george/git/s/web_app/war/,AVAILABLE}{/home/george/git/s/web_app/war}
meaning that I can find my application served under '/war' instead of just '/'. Wacky.
This is due to a host of changes, mainly pointing at the use of Java 7 and requirements for the more recent Servlet specs.
Easy enough to fix for your situation tho.
Don't use OS symlinks.
Create a file called ${jetty.home}/webapps/mywebapp.xml with the following contents
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/</Set>
<Set name="war">/home/george/git/s/web_app/war/</Set>
</Configure>
All done, you are now essentially using a Jetty Deployable XML Descriptor which sets the contextPath to / (aka Servlet Spec Root) and pointing to the war that you want to deploy.

setting the ContextPath in Jetty running under ServiceMix (OSGI)

Here is my brief background of environment.
I am trying to convert a myapp WAR to an OSGi compliant by making the MANIFEST.MF as shown below, and wanted to deploy this war in ServiceMix an OSGi based container.
MANIFEST.MF
Manifest-Version: 2.0
Bundle-SymbolicName: myapp
Bundle-Version: 2.1.dev
Bundle-Name: Jetty.myapp
Bundle-Vendor: ABC
Created-By: 1.6.0_25-b06 (Sun Microsystems Inc.)
Bundle-ClassPath: .,WEB-INF/lib, WEB-INF/classes, xforms/xsltforms
Web-ContextPath: myapp
Webapp-Context: myapp
Import-Package: javax.servlet
Built-By: root
Project-Name: ABC_PRJ
Project-Version: 2.1.dev
Project-Build: ${DSTAMP}
SVN-Revision: ${svn.revision}
The ContextPath is getting set to null, where should I set the contextPath and how? You may observe the 'null' string in the FileNotFound Exception.
log:
java.io.FileNotFoundException: null/WEB-INF/myForms-config.xml (No such file or
directory)
My web.xml in myapp is :
<contextPath>/</contextPath>
<context-param>
<param-name>myForms.configfile</param-name>
<param-value>WEB-INF/myForms-config.xml</param-value>
</context-param>
Is it the problem with myapp or jetty or serviceMix? Any Clue?
You need to set the web-contextpath via the Manifest and not via the web.xml
for more information take a look at Pax-Web