I am new to CAMEL, CXF and Karaf.
I want to access static file using CAMEL with CXF and KARAF.
Wanted to know the best way to do that.
I have searched through net and found that CXF based rest web service can be written for the same.
Is there any other simpler way for this.
We are using jboss FUSE server.
To solve this problem we can define a redirect-list which will contain pattern of static resources you want to serve and the CRX default servlet will take care of forwarding to the specific resource please refer the following url for more information
Redirecting requests and serving the static content
web.xml file which does what is described above
Got a better way to do the same.
Step 1
Add <_wab>src/main/webapp/ tag in you maven pluggin so that your bundle can be treated as WAB by karaf container.
Use and to declare your custom context path.
By default maven will take Bundle-SymbolicName as context.
Step 2.
Write web.xml. Place it under /src/main/webapp/WEB-INF.
Step 3.
Place your static resource file under webapp folder.
Step 4.
Build the code to generate bundle jar using maven command mvn clean install and deploy the jar in karaf
Step 5
Use below link to access the static resource.
http://:8181//
Related
I want to deploy a Spring boot application in an external Tomcat server version 9. I am able to deploy it and working the endpoints also. But properties I have set in application.properties file those are not working. Like server.servlet.context-path=/myapp is is not working instead the context path which I am getting is http://localhost:8080/myapp-0.0.1-SNAPSHOT/api/ping.
I am using 2.3.10.RELEASE and Java 1.8 and Tomcat version 9.0.46 Can anyone please help me out with this.
But everything is perfectly working on embedded tomcat. Thanks in advance and any suggestion, comment is highly appreciated.
Can anyone please help me with how I can do this - My war file name would be myapp-0.1.war but the context path of the application would be like this localhost:8080/myapp/api/ping
Use finalName property in your build file (pom.xml for maven)
<finalName>myapp</finalName>
When you run a Spring Boot application in an external servlet container, the server.* properties do not apply.
If you are willing to change the naming convention you can drop a WAR file named myapp##0.1.war in the $CATALINA_BASE/webapps directory and benefit from parallel deployment (cf. parallel deployment).
If you want to stick to your naming convention, you can create a folder for your WAR files (e.g. $CATALINA_BASE/webapps-available) and create a deployment descriptor $CATALINA_BASE/conf/<engine_name>/<host_name>/<context_path>.xml (in your case probably $CATALINA_BASE/conf/Catalina/localhost/myapp.xml) with the following content:
<Context docBase="${catalina.base}/webapps-available/myapp-0.1.war" />
I have a Tomcat 8 instance which is used to publish multiple web applications.
As today, I have a Spring architecture which produces 2 .war:
Front-end
Back-end
And the result is the following:
http://localhost:8080/my-front-end
http://localhost:8080/my-back-end
What I would like to achieve is to have a common root path for both these wars. Is this something I can do in Tomcat? In JBOSS or IIS I can use the concept of "Virtual Directory" to achieve that.
My intended result is the following:
http://localhost:8080/my-app/my-front-end (my-front-end.war)
http://localhost:8080/my-app/my-back-end (my-back-end.war)
The Tomcat documentation says to use # in the name.
Context Name Base File Name Example File Names
/foo foo foo.xml, foo.war, foo
/foo/bar foo#bar foo#bar.xml, foo#bar.war, foo#bar
So use these names for your war files:
my-app#my-front-end.war
my-app#my-back-end.war
Set the context paths: /my-app/my-front-end and /my-app/my-back-end respectively.
For example, if you are using Spring Boot, then put:
server.contextPath=/my-app/my-front-end
and
server.contextPath=/my-app/my-back-end
in application.properties file.
If you cannot modify the application's source code, here you can find out how to configure Tomcat to get the same result.
Sorry if this is a duplicate, I looked at several other questions but none seemed to match or provide workable solutions.
Problem
I am writing a Spring Boot (v2.0.2) app, this app exposes a RESTful API which then calls into a WSDL service. I've generated the WSDL classes with Maven/jaxb plugin and everything works from my dev machine. When deployed to the server I get an error that the WSDL service class can not load the underlying WSDL file. The problem is that when the Java classes are generated it is using the full path from my dev machine (snippet from the generated service class)
try {
URL baseUrl;
baseUrl = com.mytest.WSDLService.class.getResource(".");
url = new URL(baseUrl, "/home/users/me/projects/wsdltest/wsdl/MyWSDL.wsdl");
} catch (MalformedURLException e) {
The WSDL file (MyWSDL.wsdl) is in the spring boot JAR file for my application, it is in a subdirectory off root called 'wsdl'
Question Is there a way that I can load this WSDL from the JAR file without having to modify the generated classes?
Ideal Solution I'm hoping to find a solution that doesn't make me modify the generated files (we intend to do this for several services), ideally I'd like a solution which can be done at build time (in the pom.xml?), if that's possible.
Solutions Tried
A post on here suggested using the "wsdlLocation" tag in my pom.xml and provide a explicit path to the WSDL file, e.g. <wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>
Tried most of the solutions from this thread
Thanks in advance
I think I was able to find a solution thanks to this SO Thread. Evidently the answer depends on the version of the jaxws tool being used in maven (jaxws-maven-plugin). The project (which I inherited) explicitly asked for version 1.12 (which invoked JAX-WS RI 2.1.7-b01-), using this version of the tools I was able to use the '<wsdlLocation>classpath:wsdl/MyWSDL.wsdl</wsdlLocation>' solution in the thread mentioned. Once I noticed that the pom was using an explicit version I removed that the jaxws was updated (using JAX-WS RI 2.2.10) but then the 'classpath' solution stopped working. I switched to the other option mentioned in the thread '<wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>'
I did a quick test and this seemed to have solved the problem (in both my dev machine and my test site).
Thank you
I'm in the process of migrating my project as a spring boot application (mostly for the embedded tomcat solution) from a WAR that was previously deployed on tomcat.
So I encountered a problem with the embedded tomcat container that I hope someone can perhaps offer a solution, perhaps through spring or maven instead of modifying my dependency jars that my project uses to work around this issue.
I have two data model jars that contain xsd files and each one has a catalog file in "/catalog/jaxb-catalog.xml". I found that when one of my libraries call:
Class loader = Thread.currentThread().getContextClassLoader();
URL url = loader.getResource("/catalog/jaxb-catalog.xml");
It would only one xml file and ignore the second xml file as confirmed when i printed out the "url". It seems the container is "TomcatEmbeddedWebappClassLoader" However, when my application is deployed in a standalone tomcat container, the "url" would include both and the container is WebAppClassLoader.
You can read all resources with a name using
org.springframework.core.io.support.PathMatchingResourcePatternResolver
its a normal 'java' class so you can create an instance with new
to find all resources use
resolver.findResources("classpath*:catalog/jaxb-catalog.xml"
have a look at the javadoc of PathMatchingResourcePatternResolver it contains some valuable information.
I am using Apache Felix to create an embedded OSGi host application. I am using the following code to expose the packages I want to expose:
List<String> extra = new ArrayList<>();
extra.add("some.example.packag.to.expose.1");
extra.add("some.example.packag.to.expose.2");
extra.add("some.example.packag.to.expose.3");
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, extra.toString().replace("[","").replace("]", ""));
Everything works great and these packages are exposed. However, I need the bundles to have access to ALL the host project declared dependencies. So for example the parent application has Jackson, Apache (various), etc. declared and I need the bundles to have access to these.
I tried adding the packages explicitly but that does not seem to do the trick when they are dependencies. So for example in the bundle I want to use Jacksons com.fasterxml.jackson.core.type.TypeReference; so I added com.fasterxml.jackson.core.type to the above EXTRA list but it does not appear to solve the problem, the package still doesn't get exposed.
In a perfect work I just want to make ALL the host dependencies available without having to explicitly state each one.
You will have to configure each package. In OSGi you would normally install the dependencies as bundles. So the settings do not suppot to mass export system packages.