I am building a RCP application , where I need to monitor http traffic and show it to user. For that I require use of Embeded Jetty as transparent proxy.
I tried everything , followed this Tutorial But things just don't work. I get build exception.
I tried adding Jetty jar as external dependency , but still no use.
Would appreciate any help. Also please let me know if there are any other ways of achieving this without use of jetty. (I tried Socks but it conflicts with RCP UI thread)
Thank You.
In broad terms you need to look into making eclipse plugins and how to declare dependencies in eclipse plugin projects. What you are basically looking to do is write a bit of code based on our jetty embedded examples only in a plugin context, so when your plugin loads it would trigger the starting of the jetty server. You will load the jetty dependencies as osgi bundles. Note that in juno much of jetty 8.1.3 will be available by default.
Its not the best example in the world, but you can look at our crusty wtp plugin for some ideas, at least on how you could configure things using tycho and maybe some organizational bits.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.wtp.git/
Related
I have a spring-boot application in which I loaded all the necessary (or so I believe) dependencies to run without using spring-boot initializer or the spring-boot gradle plug-in. These tools are not available for me at my work. I can run the application through intellij without issues, but when attempting to run a fat jar, I am met with
No auto configuration classes found in META-INF/spring.factories.
Now the spring.factory files ARE located inside the fat jar (there are multiples of them) and they are inside the meta-inf directory.
Spring boot has so much automated functionality, I am not sure where to begin. There are a lot of similar posts and everyone just tells people to use the spring-boot gradle plugin bootJar task but as I said these are not available to me. I need to get it running without those tools,
if anyone has insight into what the issue may be or how to resolve it, any help is appreciated. I will try to add more details later.
I am using spring-boot v. 2.1.1 and spring 5.1.4
I'm using IntelliJ to build a standard java web application on top of Tomcat and Spring. I'm fairly new to IntellJ and feel like I'm missing something setup wise because I cannot seem to resolve resource files from the classpath.
Relevant Info -
IJ 2017.1.4
Tomcat 8.5.15
Java 8
Spring platform-bom:2.0.8.RELEASE
I should also mention I'm using a java only configuration, taking advantage of the Spring's annotations and the servlet 3.0+ spec.
Since I'm pretty sure this is an issue with my IJ configuration, here's a series of screenshots outlining my setup & the error. Appreciate any help on this one, it's had me stumped for a bit.
Modules
Facets
Artifacts
Project src
Exploded War ouptut
Code where I'm attempting to load in a file on the classpath
Error
Since spring-boot comes with embedded tomcat containers, I was wondering how is the patching being done. If I decide to go for using embedded approach and a security vulnerability has been found out and the tomcat community has released a patch, how do I apply that patch to the embedded tomcat container which comes with the Spring-boot.
Any help would be greatly appreciated since it will help to decide to go the traditional route of standalone tomcats v's embedded.
According to this Spring blog post, you can specify any version of Tomcat you want. As long as it's released to the Maven repo, just add the following property to your Maven build properties specifying whatever version you like: <tomcat.version>8.0.3</tomcat.version>.
See http://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core for versions currently available in Maven Central.
I seem to be really struggling here. What I want to do (in this order) is:
1) Build a RESTful resource using a Jersey application and resource w/annotations (this is not the issue).
2) Package, install, and start that bundle into the Felix OSGi container, as an HTTP service, including dependencies.
3) Package, install, and start a WAR in the OSGi container that may incorporate #2 as a dependency.
And I would like to be able to do all of this using Maven.
I cannot seem to find a working example of even the individual steps, especially involving Maven, that work let alone the combination of those steps. I have tried cobbling together various q&a from across the web with varying levels of success but not an end-to-end working example yet.
Any pointers would be appreciated...
I do not have an example for Jersey but I have a tutorial for CXF with Apache Karaf (which uses Felix). It shows how to create a Rest service and build it with maven. Using Apache Karaf you can then deploy the bundle directly from the maven repo. Moving this to Jersey probably just means to exchange the lib and use another blueprint config to initialize the rest service.
Apache Karaf also allows to deploy wars and wabs but I have not yet tested them.
Apache Stanbol does most or all of this (not sure if the war packaging is included out of the box) to implement its RESTful services.
You'll have to dig through its codebase but searching for Jax-RS annotations in there should point you to the right places.
I also am really struggling with exactly what you are attempting to do. So far, I seem to be really close but alas not quite there, here's what I've been doing:
creating a War with Maven that defines my Jersey Resource's
bundling it with maven bundle plugin ( see section Adding OSGi metadata to existing projects without changing the packaging type ). Which allows me to run the restlets in Tomcat and test.
define a target in Eclipse that includes resources from my locally defined p2 site which I create with the p2-maven-plugin plugin. In this way I can gather up any of the dependencies from the WAR project into a p2 site, which I can deploy to an Eclipse defined target
Where I am stuck is trying to register the Jersey Resource's as services, for which I've tried:
using the JAX-RS OSGI connector, for which I eventually gave up on because it uses glassfish jersey which seems to export a version 2 API of Jersey when Jersey hasn't even defined a version 2 API yet. This caused package resolution problems when I wanted to use version 1.17 of Jersey libs.
registering the Resources using a Whiteboard a la Apache Felix HTTP Service, my current approach which doesn't seem to work yet.
And, finally, if the preceding doesn't work I'll try Amdatu
Another route I might try is from the Jersey project OSGI chapter
I tried this combination and made it up and running -
1- Modularity Specification-->OSGi specification
2- OSGi implementation-->Apache Felix 4.4.0
3- OSGi Runtime-->Apache Karaf 3.0.3
4- Software Architecture Specification of REST – JAX-RS
5- JAX-RX implementation-->Apache CXF – 2.7.5
You can refer this nice tutorial - http://java.dzone.com/articles/building-cxf-rest-service-osgi
Now, I am also planning to move to Jersey from CXF as the Jersey is the light wait reference implementation of JAX-RS. Now I am planning to use Jersey with Apache Felix/Apache Karaf. You can install Jersey in Karaf and deploy your Jersey Rest Web Services as Bundle. You can refer this tutorial - https://vzurczak.wordpress.com/2014/09/30/web-applications-with-osgi-working-with-jersey/
Here's a good example on github : https://github.com/ddragosd/jax-rs-on-karaf
I'm trying to do some "hello world" example with Apache Camel. Just a simple route, deployed as OSGi bundle to Apache Karaf. And it's crazy, too many things to learn at once, Camel itself, integration with spring, integration with OSGi and Karaf...ugh.
I'm trying to follow the idea from here: http://www.andrejkoelewijn.com/wp/2008/10/19/simple-camel-dsl-osgi-bundle-example/.
I've created the bundle, the package with FileRoute.java file, etc, but I can't produce valid manifest.mf file, it's generated by "bundle plugin for maven" - so the POM file is used to generate the manifest file.
What's the problem is this in the manifest file, line with import packages:
Import-Package: com.company.foo.bar.demo;version="0.1",org.apache.ca
mel.builder;version="2.10",org.apache.camel.model;version="2.10",org.
apache.commons.logging
With error: "No available bundle exports package 'org.apache.camel.builder'" (and .model package).
Well, I understand what is the problem, but…How to expose these packages for the bundle?
Next I have there another bundle with Apache Camel context, so I thought that good idea is to expose the packages from there, through "export package", but it doesn't work, the camel bundle can't be build then.
I'm quite lost :( I'd really appreciate help or hint.
Thanks!
If you use Apache Camel 2.10 or better then the Maven archetypes is a good place to start a new Camel project. We have archetypes that can create OSGi based project for either spring-dm or OSGi blueprint. You chose which one you want to use. The project is then ready for OSGi as it setup a maven plugin that generated the needed osgi stuff for you. Only in more advanced cases you would need to tweak this plugin.
See details at: http://camel.apache.org/camel-maven-archetypes.html
If you use Maven 3.0.x then its much easier as you can just type
mvn archetype:generate
Then it runs in interactive mode, then type camel to filter only camel archetypes.
And then select the number for the archetype. eg for example the spring-dm to use OSGi with Spring.