-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No context loaded when using custom jetty.xml #198
Comments
It may be helpful If you can paste your jetty.xml, however I can share you my sample that I am using in my current work to show how to configure jndi support for RJR: <?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="fooDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/fooDataSource</Arg>
<Arg>
<New class="com.mchange.v2.c3p0.ComboPooledDataSource">
<Set name="driverClass">org.postgresql.Driver</Set>
<Set name="jdbcUrl">jdbc:postgresql://foo.local:5432/foo</Set>
<Set name="user">foo</Set>
<Set name="password">foo</Set>
<Set name="initialPoolSize">2</Set>
<Set name="minPoolSize">2</Set>
<Set name="maxPoolSize">2</Set>
</New>
</Arg>
</New>
</Configure> And there is also another important thing you have to do : At the launcher configuration window, where you configure the path of extra jetty.xml file, just above the input box of the path of jetty.xml, there is an checkbox named "JNDI Support", you must check it on. Finally, you do not need to configure the context in the jetty.xml, the RJR will handle it well. |
Ok so i managed to work this issue, based on your jetty.xml with this one:
Now i'm facing a second error regarding Weld:
this seems due to WebAppContext configuration, as defined in jetty-env.xml:
i tried definining solely the jndi ressource in jetty.xml but it seems the classloading is mandatory, any way to do that using RJR? |
I am sorry that I am not familiar with WELD. I don't know how you attach the jetty-env.xml to RJR? It seems that there is no way to do that. Anyway, Since the BeanManager is a jndi resource, I think you can declare it in server scope instead of context scope. And also, once I did something like following in my own project, which may be helpful if you have to do something on WebAppContext rather than Server: <Configure id="Server" class="org.eclipse.jetty.server.Server">
<!--
<Get id="defaultHandler" name="handler">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>xyz</Arg>
</Call>
</Get>
-->
<Set class="com.foo.jetty.hack.StartHacker" name="attr"><Get id="defaultHandler" name="handler"/></Set>
</Configure>
StartHacker is a simple independent java class as following: public class StartHacker {
public final static void setAttr(Object obj) {
if (obj == null) {
return;
}
try {
Method m = obj.getClass().getMethod("setAttribute", String.class, Object.class);
Object[] params = new Object[] { "org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern", "xyz" };
m.invoke(obj, params);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} You should compile it and package it to a independent jar file and then add it to the RJR's runtime classpath, then you can configure the WebAppContext by java code. It is not so beautiful but it works for me. And because the RJR have to configure the context by current java project, it is really difficult to allow developers to customize the context. An jetty expert may be helpful on addressing this issue but I am still waiting for that guy. |
i don't actually attach the jetty-env to RJR, in a "non-embedded" deployement it is just read because it is in the web-inf folder, in this case i understand i don't work. |
got the same result. |
Thanks for your report. I will keep this ticket opening because I think RJR should load the jetty-eny under WEB-INF, which should be considered as a bug. |
I might be missing something.
run jetty run build: nightly
eclipse: neon
jetty: 9.3.6
My webapp need a com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource, provided trough JNDI and a org.eclipse.jetty.security.JDBCLoginService. Therefore i provided the same jetty.xml i use on my production server with WAR deployed on it.
When running the app without the custom jetty.xml the console complain about the missing JNDI ressource, when running it with the custom jetty.xml the server start (really quickly compared to the production server), when i browse to the IP i only get 404 with no context referenced.
I tried adding to jetty.xml
with no luck: still no error in the console, still 404
The text was updated successfully, but these errors were encountered: