It is a web service deployed on Apache Karaf using camel-cxf. I am able to see the cxf service listing in URL localhost:8181/cxf which has some rest and soap services deployed on it.
The problem is it is returning the service listing whenever any request comes with keyword "services". For example the url http://localhost:8181/abcd/services returns cxf service listing page instead of processing the actual request.
I got to know from http://cxf.apache.org/docs/jaxrs-services-description.html that its is because of the default value of service-list-path of CXFServet is services.
Here is my Question. If I want to override this, I should set this property in etc/org.apache.cxf.osgi.cfg. This cfg file is not present under etc folder in my karaf. What are the steps to be taken if I am creating this property file manually? What features I need to install? Or creating this cfg is sufficient ?
Appreciate your help !
There should be no extra installation requirements, just create a new file etc/org.apache.cxf.osgi.cfg.
There are three settings you may be interested in:
org.apache.cxf.servlet.context = /mycxf
org.apache.cxf.servlet.service-list-path = /myservices
org.apache.cxf.servlet.hide-service-list-page = false
Where the default URL for the CXF service listing is usually like http://localhost:8181/cxf/services, with the changes above the URL would become http://localhost:8181/mycxf/myservices
If you change from false (default value) to true, then your services will be hidden and you will instead get a page stating No service was found.
Because these are initialisation settings you need to shut down Karaf for the changes to apply.
I see several points here --
The CXF framework is installed by default in karaf under the context-path /cxf.
/cxf/services can be considered as a CXF internal app that displays the list of services deployed in CXF. I don't think you can configure the name "services" here (and why would you change that?)
the "url-pattern in web.xml" you speak of (if I understand correctly) determines the context path of your servlet/application. You can specify this is camel like this:
<cxf:rsServer id="secureRsServer" address="https://0.0.0.0:8182/my/path/"
serviceClass="....">
(for the RS Server, probably same for the WS server).
Related
I want to apply filter in below URL's.
http://10.78.97.29/robots.txt
http://10.78.97.29/sitemap.xml
https://10.78.97.29/
Since they does not contain any specific URL pattern , I am not getting any idea. And in which web.xml I have to add that filter mapping. I am using Tomcat as a webcontainer.
Thanks in advance.
Tomcat by default uses the web application named ROOT to serve the application at the root folder of the server. You can either handle the requests there or just have the files contained in the web application.
You might want to read about tomcat naming for more details, explaining this behaviour.
Alternatively, you can also have an Apache httpd in front of your tomcat and handle those files there.
I am having trouble create a new custom type to the jackrabbit in apache sling using the below code. This worked fine straight on Jackrabbit but not on Apache Sling. Am I doing this correctly for sling? Thanks
The following code gives me a "javax.jcr.InvalidItemStateException: Conflict". I am using a standalone sling and am the only user so there is definitely no conflict.
Repository repository = JcrUtils.getRepository("http://localhost:8080/server");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
registry.registerNamespace("my", "http://my.com/v1.0");
CndImporter.registerNodeTypes(new FileReader("C:\\test.cnd"), session);
If you're using Sling, you can avoid all this by putting your CND file in an OSGi bundle (where your java code should reside anyway), with a header that tells Sling where to find it.
Your node types will then be registered automatically when your bundle is activated. For an example of this see the event.cnd file which is declared in a Sling-Nodetypes bundle header that's set in that module's pom.xml (or in any other way if you're not using Maven).
Note also that you shouldn't need JcrUtils.getRepository in Sling anyway, the right way to get a repository is via the SlingRepository OSGi service, which takes care of repository login and configuration in a consistent way for all your Sling components. You can get the repository via a #Reference to a SlingRepository in java code, or get a JCR Session from the Resource that Sling provides to request handlers like servlets and scripts. The Slingbucks sample uses both mechanisms.
The JavaDocs for InvalidItemStateException offer this clue:
Exception thrown by the write methods of Node and Property and by save
and refresh if an attempted change would conflict with a change to the
persistent workspace made through another Session. Also thrown by
methods of Node and Property if that object represents an item that
has been removed from the workspace.
Are you sure that you don't have any old sessions still running, perhaps is a daemon process that hasn't been shut down properly?
I have an application with name test.war.
Because of Apache installed on my server I have to use another port number for Tomcat applications so after deployment this application available at domain.com:8080/test/.
I decided to create a subdomain in order to remove that ugly 8080 from url, so I setted up the server like described here. So now test.domain.com reffers to domain.com:8080/test/.
Everything seems fine except of one problem - because my application is not ROOT.war and I am using spring:url function every url in the application is translated to /test/bla-bla. So I removed that function. But still have a problem with spring security because it still translates an urls relative to app name i.e. /test/bla-bla.
How can I solve that problem?
Thank you
UPD: I don't want to deploy it as a ROOT application because I have two or three such applications and I wanted to create a subdomain for each one of them
Spring Security doesn't "translate" URLs. In fact this isn't specific to Spring Security. You'll run into similar issues with any application which does redirects. If you want to hide the context paths of applications which are behind a proxy, then you need to rewrite the URLs at the proxy.
I'd recommend you read the Tomcat Generic Proxy Howto and the section on URL rewriting in particular, as it specifically addresses this issue.
I have a webapplication that I am running in Felix osgi container. I am using jetty as the implementation for the extHttpService. Currently it is writing the cookies to the '/' root path. I would like to change this as it is causing conflicts with other web applications. Looking at jetty documentation it appears I need to set the following property.
org.mortbay.jetty.servlet.SessionPath
However, I am unable to find a way to set this using the ExtHttpService via osgi. I have tried creating a jetty.xml file, adding this to the config.properties, and setting it as a property in the call to register my servlet.
Does anyone know how to set this?
thanks,
I actually ended up patching the source for my current implementation, but on the mailing lists here, a patch has been submitted that should allow this to be configurable.
What is the MBeanServerFactory.findMBeanServer(null); exactly doing?
Returns a list of all registered MBeanServers? Registered where?
I am asking because I have the following problem.
I have a java web app deployed in Tomcat using a service wrapper.
I have custom connector implementations in my server.xml that use ManagedBeans (spring enabled).
If I start the app via the service wrapper all is ok.
If I start the web app through Tomcat directly it seems that the deployment breaks.
All I see in the logs is that the connector does a
MBeanServerFactory.findMBeanServer(null);
and then tries to invoke the bean beanServer.invoke(name, operationName, null, null);
The result is a InstanceNotFoundException.
It seems that the managed beans are not loaded in case I do not use a service wrapper? Is my understanding correct? Any input on how to debug this issue is
highly welcome!
The javadoc says that when you pass null, it returns the servers registered in the current JVM. If you are using JSW, then you cannot use null as JSW forks the VM as a separate process. This is why you see the InstanceNotFoundException.