You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by smunro <st...@gmail.com> on 2017/04/24 14:46:38 UTC
Standard Webapp unable to locate web.xml
Hello,
I realise this topic has been raised in the past for an older version of
karaf, but even after following the steps in that advice given, I am still
unable to get past karaf throwing a FileNotFoundException.
Essentially, I have a run-of-the-mill angular web app and some noddy
servlets, which I want to eliminate with jaxrs. I followed the guide to
doing this, creating a OSGI-INF in src/main/resources and defining a
rest.xml blueprint file.
The maven plugin in the pom looks as follows:
<configuration>
<supportedProjectTypes>
<supportedProjectType>war</supportedProjectType>
</supportedProjectTypes>
<instructions>
<_wab>src/main/resources</_wab>
<Web-ContextPath>/demo</Web-ContextPath>
<Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>
<Bundle-Activator>demonamespace.Activator</Bundle-Activator>
</instructions>
</configuration>
When starting the bundle, I get:
2017-04-24 15:21:27,091 | ERROR | nsole user karaf | BlueprintContainerImpl
| 12 - org.apache.aries.blueprint.core - 1.7.1 | Unable to start blueprint
container for bundle com.smartergridsolutions.sgs-ui.client/0.0.1.SNAPSHOT
java.io.FileNotFoundException: Unable to find configuration file for
WEB-INF/OSGI-INF/blueprint/rest.xml
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.getResources(BlueprintContainerImpl.java:454)[12:org.apache.aries.blueprint.core:1.7.1]
I've tried the same in a standard JAR osgi bundle and it works perfectly, so
obviously it's an issue with paths. As said, a previous post on this forum
indicated that a <_wab> entry was needed, but this does not seem to have
worked. If it helps, I've included the header's from the generated war in my
.m2 folder:
Bundle-Name: Demo
Bundle-Version: 0.0.1.SNAPSHOT
Bundle-ClassPath: .,WEB-INF/classes
Bundle-Activator: demonamespace.Activator
Web-ContextPath: /demo
Bundle-Blueprint: OSGI-INF/blueprint/rest.xml
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.8.0_73
Any suggestions or advice would be useful. I've burned up half a day
perusing google and trying different things to get it working. I'll I've
managed to do is get it working when not running it as a WAR type. In
addition, even if someone has some good examples to look at, that too would
be great.
Thanks,
Stephen
--
View this message in context: http://karaf.922171.n3.nabble.com/Standard-Webapp-unable-to-locate-web-xml-tp4050233.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Standard Webapp unable to locate web.xml
Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,
first of all make sure to either only depend on an activator or on
blueprint, it's something you shouldn't mix.
If a JAR works for you, just stick to the jar, the actual zip file
extension name isn't much of a concern.
The Web-ContextPath element in the manifest is what makes it a WAB, nothing
else ;)
After that Pax-Web tries to find the appropriate web.xml and other stuff
making a war (or just Servlet3 annotated servlets)
regards, Achim
2017-04-24 16:46 GMT+02:00 smunro <st...@gmail.com>:
> Hello,
>
> I realise this topic has been raised in the past for an older version of
> karaf, but even after following the steps in that advice given, I am still
> unable to get past karaf throwing a FileNotFoundException.
>
> Essentially, I have a run-of-the-mill angular web app and some noddy
> servlets, which I want to eliminate with jaxrs. I followed the guide to
> doing this, creating a OSGI-INF in src/main/resources and defining a
> rest.xml blueprint file.
>
> The maven plugin in the pom looks as follows:
>
> <configuration>
> <supportedProjectTypes>
>
> <supportedProjectType>war</supportedProjectType>
> </supportedProjectTypes>
> <instructions>
> <_wab>src/main/resources</_wab>
> <Web-ContextPath>/demo</Web-ContextPath>
>
> <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</
> Bundle-ClassPath>
>
>
> <Bundle-Activator>demonamespace.Activator</Bundle-Activator>
> </instructions>
> </configuration>
>
> When starting the bundle, I get:
> 2017-04-24 15:21:27,091 | ERROR | nsole user karaf | BlueprintContainerImpl
> | 12 - org.apache.aries.blueprint.core - 1.7.1 | Unable to start blueprint
> container for bundle com.smartergridsolutions.sgs-ui.client/0.0.1.SNAPSHOT
> java.io.FileNotFoundException: Unable to find configuration file for
> WEB-INF/OSGI-INF/blueprint/rest.xml
> at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.getResources(
> BlueprintContainerImpl.java:454)[12:org.apache.aries.blueprint.core:1.7.1]
>
> I've tried the same in a standard JAR osgi bundle and it works perfectly,
> so
> obviously it's an issue with paths. As said, a previous post on this forum
> indicated that a <_wab> entry was needed, but this does not seem to have
> worked. If it helps, I've included the header's from the generated war in
> my
> .m2 folder:
>
> Bundle-Name: Demo
> Bundle-Version: 0.0.1.SNAPSHOT
> Bundle-ClassPath: .,WEB-INF/classes
> Bundle-Activator: demonamespace.Activator
> Web-ContextPath: /demo
> Bundle-Blueprint: OSGI-INF/blueprint/rest.xml
> Created-By: Apache Maven Bundle Plugin
> Build-Jdk: 1.8.0_73
>
> Any suggestions or advice would be useful. I've burned up half a day
> perusing google and trying different things to get it working. I'll I've
> managed to do is get it working when not running it as a WAR type. In
> addition, even if someone has some good examples to look at, that too would
> be great.
>
> Thanks,
> Stephen
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Standard-Webapp-unable-to-locate-web-xml-tp4050233.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
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
Re: Standard Webapp unable to locate blueprint .xml
Posted by Achim Nierbeck <bc...@googlemail.com>.
Either way is fine with samples.
I'm not sure we have enough web samples in Karaf,
usually all samples are directed to Pax-Web as it's the actual
implementation of the Web-Container.
regards, Achim
2017-04-28 10:55 GMT+02:00 smunro <st...@gmail.com>:
> Ok,
>
> turns out that I was missing something rather obvious. Our pom file already
> has a copy-resources maven goal setup, which targets webapp/build
> (generated
> angular content is placed here by another plugin). So anything above this
> level was not being placed into the WAR file. I just added another
> <resource> entry to copy /src/main/resources to copy over
> OSGI-INF/blueprint/rest.xml and everything is working as expected :)
>
> In addition, I removed the bundle activator.
>
> Thanks for helping me out with this one, sorry it turned out to be a minor
> thing, but at least I'm confident there is nothing wrong with Karaf or the
> maven plugin when using WAR types.
>
> I still think it would be good to do a simple example of the above, which
> I'm happy to do. I can either contribute that to your list of samples or
> link it to my own github.
>
> Stephen
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050278.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
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
Re: Standard Webapp unable to locate blueprint .xml
Posted by smunro <st...@gmail.com>.
Ok,
turns out that I was missing something rather obvious. Our pom file already
has a copy-resources maven goal setup, which targets webapp/build (generated
angular content is placed here by another plugin). So anything above this
level was not being placed into the WAR file. I just added another
<resource> entry to copy /src/main/resources to copy over
OSGI-INF/blueprint/rest.xml and everything is working as expected :)
In addition, I removed the bundle activator.
Thanks for helping me out with this one, sorry it turned out to be a minor
thing, but at least I'm confident there is nothing wrong with Karaf or the
maven plugin when using WAR types.
I still think it would be good to do a simple example of the above, which
I'm happy to do. I can either contribute that to your list of samples or
link it to my own github.
Stephen
--
View this message in context: http://karaf.922171.n3.nabble.com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050278.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Standard Webapp unable to locate blueprint .xml
Posted by smunro <st...@gmail.com>.
Thanks for the links Achim :)
As mentioned previously, I tried to use the programmatic approach to
bootstrapping a CXF-JAXRS service within a bundle activator and it worked
fine. It's not apocalyptic if I go down this road, but I'd like to have
declarative control with the address.
I think it's worth doing a project for the karaf samples that shows just
blueprint and a WAB as similar people have had problems with this.
I'll have a look at the links you provided me with to see if there is
anything different to my configuration.
Stephen
--
View this message in context: http://karaf.922171.n3.nabble.com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050250.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Standard Webapp unable to locate blueprint .xml
Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,
here's one that uses blueprint to register servlets, though no WAB [1].
another one I have using cxf rest is also a non WAB bundle [2].
For a WAB with blueprint I'd need to create a sample first. That'll take
some time though :)
regards, Achim
[1] -
https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-blueprint
[2] -
https://github.com/ANierbeck/Karaf-Microservices/tree/master/service-proxy
2017-04-25 13:23 GMT+02:00 smunro <st...@gmail.com>:
> Thanks for the swift reply and the information.
>
> Sadly, I tried as you suggested and removed the activator and it's
> definition in the maven plugin. Even after changing my type to JAR. I still
> had the missing configuration error.
>
> What I did in the past was simply created a standard OSGI bundle with no
> web
> components i.e no WEB-INF folder. This allowed my REST server to work fine,
> but I was asked to have it working with the web osgi bundle.
>
> Again, I consistently get the same "missing configuration" error. Late on,
> I'll download the karaf source and see what exactly is causing getResource
> problems.
>
> I don't suppose you know of any examples lingering around that are standard
> WAB bundles with a blueprint definition? I've had a look around, and not
> really found much. What I did find added several additional bundles
> confused
> matters further.
>
> At the moment, I'm just trying to hard code the cxf rest server in the
> activator class and register end points to see if that works, but
> personally, I'd rather have declaration control over these things hence the
> usage of blueprint.
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050248.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
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
Re: Standard Webapp unable to locate blueprint .xml
Posted by smunro <st...@gmail.com>.
Thanks for the swift reply and the information.
Sadly, I tried as you suggested and removed the activator and it's
definition in the maven plugin. Even after changing my type to JAR. I still
had the missing configuration error.
What I did in the past was simply created a standard OSGI bundle with no web
components i.e no WEB-INF folder. This allowed my REST server to work fine,
but I was asked to have it working with the web osgi bundle.
Again, I consistently get the same "missing configuration" error. Late on,
I'll download the karaf source and see what exactly is causing getResource
problems.
I don't suppose you know of any examples lingering around that are standard
WAB bundles with a blueprint definition? I've had a look around, and not
really found much. What I did find added several additional bundles confused
matters further.
At the moment, I'm just trying to hard code the cxf rest server in the
activator class and register end points to see if that works, but
personally, I'd rather have declaration control over these things hence the
usage of blueprint.
--
View this message in context: http://karaf.922171.n3.nabble.com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050248.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Standard Webapp unable to locate blueprint .xml
Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,
I'm not sure if the blueprint extender does have an issue with WAR types,
but if changing it to JAR fixes your issue.
Then go for using JARs ;)
regards, Achim
2017-04-24 22:10 GMT+02:00 smunro <st...@gmail.com>:
> Looking at this further, the getResources method in the code seems unable
> to
> find a "configuration" for whatever blueprint file name I use (I've tried
> renaming the file and the error will use what ever name I give it).
>
> Is there an underlying problem with using the WAR type with blueprint or am
> I missing something in my configuration?
>
> As mentioned, I can get the cx-jaxrs code working fine in a normal JAR
> bundle, It's only when I try to integrate it into a WAR type bundle.
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050240.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
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
Re: Standard Webapp unable to locate blueprint .xml
Posted by smunro <st...@gmail.com>.
Looking at this further, the getResources method in the code seems unable to
find a "configuration" for whatever blueprint file name I use (I've tried
renaming the file and the error will use what ever name I give it).
Is there an underlying problem with using the WAR type with blueprint or am
I missing something in my configuration?
As mentioned, I can get the cx-jaxrs code working fine in a normal JAR
bundle, It's only when I try to integrate it into a WAR type bundle.
--
View this message in context: http://karaf.922171.n3.nabble.com/Standard-Webapp-unable-to-locate-blueprint-xml-tp4050233p4050240.html
Sent from the Karaf - User mailing list archive at Nabble.com.