Custom Jetty Handler How to deploy in pax-web-jetty?

172 views
Skip to first unread message

dt pham

unread,
Dec 20, 2017, 12:18:19 PM12/20/17
to OPS4J
I have a very special requirement that I have to write my own Jetty Handler. I looked at the IPAccessHandler from Jetty and I successfully configure a my-jetty.xml to have pax-web loads it. The IPAccessHandler is working good on my Talend Karaf runtime. So I kind of want to do the same as IPAccessHandler and basically just create MyHandler object that extends org.eclipse.jetty.server.handler.HandlerWrapper as IPAccessHandler, but I am really don't know where to add my jar or MyHandler.class to where so it can work like the IPAccessHandler. If I put it in runtime/lib directory, the pax web can see my class, but cannot see the HandlerWrapper (NoClassFoundException).
What should I need to do to have this work?

Message has been deleted

dt pham

unread,
Dec 20, 2017, 12:20:35 PM12/20/17
to OPS4J

I have pax web 6.0.3 and Jetty 9.3.14 in my environment.

Achim Nierbeck

unread,
Dec 20, 2017, 12:26:33 PM12/20/17
to op...@googlegroups.com
Hi

good question, something I would need to dig into.
One thing that should always work is to create a fragment bundle which attaches to the pax-web jetty bundle.
In that case it's a common classloader and therefore is visible.
Otherwise we would need some extra service handling for this.
Again something I need to think about first.

regards, Achim



2017-12-20 18:20 GMT+01:00 dt pham <dtpha...@gmail.com>:

I have pax web 6.0.3 and Jetty 9.3.14 in my environment.

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

dt pham

unread,
Dec 20, 2017, 12:40:07 PM12/20/17
to OPS4J
I am happy to hear there is away to have it works. Could you please point me to where (document , example...) I can create a fragment bundle which attaches to the pax-web jetty bundle as you said. I am new to this stuffs, but I can catch up it quickly.

dt pham

unread,
Dec 20, 2017, 12:49:32 PM12/20/17
to OPS4J
I am googling about fragment bundle now and will post back what I think later

dt pham

unread,
Dec 20, 2017, 4:21:25 PM12/20/17
to OPS4J
After do some reading. I got a jar file that content my custom handler class and the manifest has these info below. I am not really sure it is correct, could someone let me know: ( is my class on the import-package or export-package ?)
Manifest-Version: 1.0
Bundle-Description: Attaching com.riits.handlers to pax web jetty
Bundle-SymbolicName: com.riits.handlers
Bundle-Version: 1.0.0
Bundle-Name: HandlerWrapper Extension
Archiver-Version: Plexus Archiver
Built-By: d.pham
Bundle-ManifestVersion: 2
Import-Package: com.riits.handlers
Fragment-Host: org.ops4j.pax.web.pax-web-jetty
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_92

dt pham

unread,
Dec 20, 2017, 7:30:50 PM12/20/17
to OPS4J
Achim, I still has ClassNotFoundException of my class. This is what I have in MANIFEST file.
Manifest-Version: 1.0
Bundle-Description: Attaching com.riits.handlers to pax web jetty
Bundle-SymbolicName: com.riits.handlers 
Archiver-Version: Plexus Archiver
Built-By: d.pham
Bundle-ManifestVersion: 2 
Import-Package: org.eclipse.jetty,javax.servlet,java.io,java.util
Fragment-Host: org.ops4j.pax.web.pax-web-jetty; version="[6.0.3]"
Export-Package: com.riits.handlers; version="1.0.0"
Bundle-Version: 1.0.0
Bundle-Name: HandlerWrapper Extension 
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_92 

I also add a line in startup.properties to point to my com-riits-handlers-1.0.0.jar file
mvn\:org.apache.karaf.features/org.apache.karaf.features.extension/4.1.1 = 1
file:C:/Talend/6.4.1/runtime/riits/com-riits-handlers-1.0.0.jar = 2
mvn\:org.apache.felix/org.apache.felix.metatype/1.1.2 = 5
mvn\:org.apache.karaf.services/org.apache.karaf.services.eventadmin/4.1.1 = 5
mvn\:org.ops4j.pax.url/pax-url-aether/2.5.2 = 5
mvn\:org.ops4j.pax.logging/pax-logging-api/1.9.1 = 8
mvn\:org.ops4j.pax.logging/pax-logging-log4j2/1.9.1 = 8
mvn\:org.apache.felix/org.apache.felix.configadmin/1.8.14 = 10
mvn\:org.apache.felix/org.apache.felix.fileinstall/3.5.8 = 11
mvn\:org.apache.karaf.features/org.apache.karaf.features.core/4.1.1 = 15




 
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Achim Nierbeck

unread,
Dec 21, 2017, 11:10:47 AM12/21/17
to op...@googlegroups.com
ok, first question.
Why do you have an extra import.
I would suggest to actually have the Class(s) in question inside your fragment bundle.

Everything else looks ok to me.

regards, Achim


--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dt pham

unread,
Dec 21, 2017, 6:14:26 PM12/21/17
to OPS4J
Thank Achim. I successfully build a fragment bundle and it is working great now. I did manually build the MANIFEST before just for quickly test, but later I use maven builds for me and it turns out great.
I am not sure if you know any thing about apache cxf jetty in Talend environment, I would like to do the same to intercept all the Talend routes. What I just have is only taking care the Talend Web services.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages