I am attempting to run jetty 9.3.8. I had to change over my Jetty 8 configuration, which was working, but I am now receiving a Config error which prints out the whole XML connector configuration line.
Here is what Jetty doesn't like - jetty.xml
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelecChannelConnector">
<Set name="host">
<Property name="jetty.host" default="localhost"/>
</Set>
<Set name="port">
<Property name="jetty.port" default="7080"/>
</Set>
<Set name="maxIdleTime">60000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="confidentialPort">7443</Set>
</New>
</Arg>
</Call>
Any ideas are great.
You have a typo in SelecChannelConnector => SelectChannelConnector.
Anyway, for Jetty 9 you should prefer the use of org.eclipse.jetty.server.ServerConnector as quoted in Jetty's own documentation:
Prior to Jetty 9, the type of the connector specified both the protocol and the implementation used; for example, selector-based non blocking I/O vs blocking I/O, or SSL connector vs non-SSL connector. Jetty 9 has a single selector-based non-blocking I/O connector, and a collection of ConnectionFactories now configure the protocol on the connector.
Configuring Jetty Connectors
Related
I have a local jetty java project. I would like to run some sql when the server creates any connections. The connections are configured in a jetty-env.xml file. Im hoping there is some oracle jdbc property like "run-sql-on-connect" where I can trigger the sql. Essentially I want to alter the session whenever a connection is established. Is there anything in OracleDataSource.connectionProperties like this?
<New id="OracleDS_local" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/local</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleDataSource">
<Set name="URL">jdbc:oracle:thin:*******</Set>
<Set name="user">*****</Set>
<Set name="password">****</Set>
<Set name="connectionProperties ">
<Set name="run-sql-on-connect" >alter session sql here</Set>
</Set>
</New>
</Arg>
</New>
A possible workaround/solution (depending on the requirements) would be to use a custom context handler and a related event to perform a separate connection and execute the query you want.
I know it's not an optimal solution but it might do the trick.
Reference:
https://www.eclipse.org/jetty/javadoc/jetty-11/org/eclipse/jetty/webapp/WebAppContext.html
<Configure id='oracledbdemo' class="org.eclipse.jetty.webapp.WebAppContext">
<New id="OracleDS_local" class="org.mortbay.jetty.plus.naming.Resource">
...
</Configure>
REPLACE WITH
<Configure id='oracledbdemo' class="<YOUR_CUSTOM_WebAppContext_HERE">
</Configure>
HSTS is not showing up as enabled in Nessus Scans on the port serving Nexus 3.16.1-02
Hello,
First time posting -
I'm trying to get HSTS enabled on Nexus OSS 3.16.1-02
From what I've read, this is enabled by default in the jetty-https.xml file for the application.
I've created an edited jetty-ssl.xml and added it to the /etc/jetty/ directory and the nexus.properties args for which xml files to call.
After rebooting the application and looking at the logs, everything looks good. The application is available, but Nessus scans for the HSTS vulnerability are still coming back positive.
The default https://localhost:443/nexus is currently configured behind an F5 reverse-proxy and HSTS is enabled on the F5, ssl is enabled in the application as well, terminating on port 443.
nexus.properties is calling for the jetty.xml,jetty-https.xml,jetty-ssl.xml,jetty-requestlog.xml when the application starts.
Any additional information on why this might coming up still would be greatly appreciated.
Thank you,
MCarrica
This is the nexus.properties
application-port-ssl=443
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-ssl.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/nexus
This is from the jetty-https.xml for the HSTS enabled
Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
Nessus scans are still showing HSTS is not enabled on port 443 on the server that is serving the application
Here are the contents of the rewrite.xml
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- configure rewrite handler -->
<!-- =========================================================== -->
<Get id="oldhandler" name="handler"/>
<Set name="handler">
<New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Set name="handler"><Ref id="oldhandler"/></Set>
<Set name="rewriteRequestURI">true</Set>
<Set name="rewritePathInfo">true</Set>
<Set name="originalPathAttribute">requestedPath</Set>
<Call name="addRule">
<Arg>
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
<Set name="pattern">/*</Set>
<Set name="name">Strict-Transport-Security</Set>
<Set name="value">max-age=31536000; includeSubDomains</Set>
</New>
</Arg>
</Call>
</New>
</Set>
</Configure>
It would be great if someone was able to help me with the following.
We currently use Jetty to expose our REST interface (Which is setup with Spring) and I want to be able to set the prefix of the threads that are used to process these calls. I believe I have found the change to cxf that will enable this behaviour:
https://issues.apache.org/jira/browse/CXF-5919
It seems to change the initial "qtp" value to whatever you want. (The version we have does include these changes) The problem is that I cannot actually work out how to set it, initially I tried the following:
<Configure id="server" class="org.eclipse.jetty.server.Server">
<Set name="threadPool">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">1000</Set>
<Set name="threadNamePrefix">myname</Set>
</New>
</Set>
</Configure>
http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax#Creating_a_NewObject_and_Setting_It_on_the_Server
But that does not work as it's not the QueuedThreadPool that has the threadNamePrefix value.
I would be great if someone was able to give me some pointers as to how I can update my jetty.xml so that I can set this value.
Thank you
Rob
Looking at Jetty source code I see that name attribute is the one you are after. Your example should look like this:
<Configure id="server" class="org.eclipse.jetty.server.Server">
<Set name="threadPool">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">1000</Set>
<Set name="name">myname</Set>
</New>
</Set>
</Configure>
This is the result (from VisualVM) on my setup:
What I want is when Jetty starts, it creates a database which can be used by my webapps. My goal is to be able to deploy my webapps on every computer to display my application.
I need a way to declare my HSQLDB database (I've SQL-files for all my databases to set up the structure and to fill it with datas) in the Jetty configuration. Those parameters just have to be set one time and won't change in the future.
I feel like I've looked for it everywhere and tried everything but nothing wants to work :( I'm using Jetty 9 by the way.
This is one of the option I've tried and which seems to be close to my solution to me. I added this code to jetty/etc/jetty.xml
<New id="toto" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/toto</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="DriverClassName">org.hsqldb.jdbc.jdbcDataSource</Set>
<Set name="Url">jdbc:hsqldb:hsql://localhost:9015/toto</Set>
<Set name="Username">toto</Set>
<Set name="Password">toto</Set>
</New>
</Arg>
</New>
and this one to jett/etc/webdefault.xml
<resource-ref>
<res-ref-name>jdbc/toto</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Merry Christmas to anyone who can help me :)
Edit 26/12/2013 :
Another option I tried is to configure the database through spring in Eclipse. Each webapp matches a project (maven architecture) and use its own database. Thus, for one project I did this :
*conf/common/resources/applicationContext.xml (Project)
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:toto"/>
<property name="username" value="toto"/>
<property name="password" value="toto"/>
</bean>
*conf/dev/WEB-INF/web.xml (Project)
<resource-ref>
<res-ref-name>jdbc/toto</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
*conf/dev/WEB-INF/jetty-web.xml (Project)
<Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext">
<New id="square" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref id="wac" /></Arg>
<Arg>jdbc/square</Arg>
<Arg>
<New class="org.hsqldb.jdbc.jdbcDataSource">
<Set name="Database">file:square</Set>
<Set name="User">${database.connection.username}</Set>
<Set name="Password">${database.connection.password}</Set>
</New>
</Arg>
</New>
</Configure>
*jetty/start.ini (Jetty) : Uncomment these lines
OPTIONS=jndi
OPTIONS=plus
etc/jetty-plus.xml
With all that, I get this exception :
java.lang.ExceptionInInitializerError
at org.apache.jasper.servlet.JspServlet.init(JspServlet.java:159)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:540)
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:349)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:812)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1322)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:732)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:490)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:282)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:214)
at org.eclipse.jetty.util.component.ContainerLifeCycle.updateBeans(ContainerLifeCycle.java:764)
at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:89)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.setHandlers(ContextHandlerCollection.java:145)
at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:155)
at org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:41)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
EDIT 07/01/2014
I gave up on that path but I succeeded to do what I want here: Connect databases to HSQLDB Server
It looks like you are using your HSQLDB as an embedded database, but are trying to connect to it in the server mode. Please check out the following documentation for the correct JDBC connection string when running HSQLDB in the embedded mode:
http://hsqldb.org/doc/guide/running-chapt.html#rgc_inprocess
We are using Oracle connection Pooling mechanism in our project as our application uses some oracle specific features.
The configuration of our datasource in jetty.xml is as follows:
<Call name="addService">
<Arg>
<New class="org.mortbay.jetty.plus.DefaultDataSourceService">
<Set name="Name">DataSourceService</Set>
<Call name="addDataSource">
<Arg>app_ds</Arg><!--java:comp/env-->
<Arg>
<New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<Set name="description">xxxx</Set>
<Set name="user">xxx</Set>
<Set name="password">xxxx</Set>
<Set name="loginTimeout">xxx</Set>
<Set name="URL">jdbc:oracle:thin:#localhost:1521:xxx</Set>
</New>
</Arg>
</Call>
<Call name="start"/>
</New>
Now How do we integrate this datasource with P6Spy, so that P6Spy can print out all the SQL statements on to the console...?
I have previously used P6spy with other datasources like spring's DriverManagerDataSource, other datasources like as
(In Tomcat)
Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#xxx"
username="xxx" password="xxx" maxActive="65" maxIdle="10"
maxWait="-1" removeAbandoned="true"/>
..etc.
All these datasources take driverClassName as argument where we can provide the "com.p6spyengine.spy.P6SpyDriver" in the place of "oracle.jdbc.driver.OracleDriver" and provide the real driver name in spy.properties. The all worked fine.
But with oracle.jdbc.pool.OracleConnectionPoolDataSource, there is no such property called driverClassName to provide a proxy driver to.
In this case how can i integrate P6Spy with it?
Please help...
Thanks in Advance,
Krishna V
From my experience with Glassfish, I would suggest to:
keep your existing oracle (real) datasource definition
create new one (P6Spy one) used as proxy to real one,
defined like this:
<Call name="addService">
<Arg>
<New class="org.mortbay.jetty.plus.DefaultDataSourceService">
<Set name="Name">DataSourceService</Set>
<Call name="addDataSource">
<Arg>p6spy_ds</Arg><!--java:comp/env -->
<Arg>
<New class="com.p6spy.engine.spy.P6DataSource">
<!-- properties would be irrelevant here -->
<Set name="description">xxxx</Set>
<Set name="user">xxx</Set>
<Set name="password">xxxx</Set>
<Set name="loginTimeout">xxx</Set>
<Set name="URL">jdbc:oracle:thin:#localhost:1521:xxx</Set>
</New>
</Arg>
</Call>
<Call name="start" />
</New>
and make sure to refer the real one from the spy.properties file,
using:
realdatasource=jdbc/app_ds # assuming that app_ds is your real datasource
the last thing is to refer the proxy_ds in all your application logic to make sure to use it (If referring would cost you too much, you can always call the proxy datasource the same as the original one and rename the original one + refer the new name in spy.properties config file)
With Jetty, adding P6Spy is actually a little easier. P6Spy has a P6DataSource that accepts another data source via constructor parameter. This is by far the easiest way to setup P6Spy.
<Call name="addService">
<Arg>
<New class="org.mortbay.jetty.plus.DefaultDataSourceService">
<Set name="Name">DataSourceService</Set>
<Call name="addDataSource">
<Arg>app_ds</Arg><!--java:comp/env-->
<Arg>
<New class="com.p6spy.engine.spy.P6DataSource">
<Arg>
<New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
<Set name="description">xxxx</Set>
<Set name="user">xxx</Set>
<Set name="password">xxxx</Set>
<Set name="loginTimeout">xxx</Set>
<Set name="URL">jdbc:oracle:thin:#localhost:1521:xxx</Set>
</New>
</Arg>
</New>
</Arg>
</Call>
<Call name="start"/>
</New>