Home » Eclipse Projects » Kura » Packaging resources into a "web" bundle
Packaging resources into a "web" bundle [message #1663363] |
Tue, 10 March 2015 11:40 |
Alessandro Da Rugna Messages: 43 Registered: December 2014 |
Member |
|
|
I've created a bundle which serves webpages using OSGi HttpService, much like org.eclipse.kura.web bundle. I start the bundle into the emulator and it works fine, I can retrieve webpages and call servlets. However I'm unable to correctly deploy such bundle into a running kura instance.
Using mToolkit to install to remote OSGi container from within Eclipse correctly installs the bundle but I get 404 on all static resources, servlets work ok. I suspect my resources inside "www" folder (symlink to src/main/webapp) are not deployed.
Creating a *.dpp file requires a "Resource Processor" to be set, and Eclipse proposes only "org.osgi.deployment.rp.autoconf". This mess up with the bundle install.
2015-03-10 11:13:28,553 [DeploymentAgent] ERROR o.e.k.d.a.i.DeploymentAgent - Exception installing package at URL file:/tmp/myweb.dp
org.osgi.service.deploymentadmin.DeploymentException: No resource processor for resource: 'www/index.html'
at org.apache.felix.deploymentadmin.spi.ProcessResourceCommand.execute(ProcessResourceCommand.java:119)
at org.apache.felix.deploymentadmin.spi.DeploymentSessionImpl.call(DeploymentSessionImpl.java:73)
at org.apache.felix.deploymentadmin.DeploymentAdminImpl.installDeploymentPackage(DeploymentAdminImpl.java:214)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installDeploymentPackageInternal(DeploymentAgent.java:462)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installer(DeploymentAgent.java:315)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.access$0(DeploymentAgent.java:300)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent$1.run(DeploymentAgent.java:184)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
This is my activate method.
protected void activate(BundleContext context, Map<String,Object> properties) {
s_logger.info("Activate");
HttpContext httpCtx = new OpenHttpContext(m_httpService.createDefaultHttpContext());
try {
m_httpService.registerResources("/site", "www/index.html", httpCtx);
m_httpService.registerResources("/sitestatic", "www/static", httpCtx);
m_httpService.registerServlet("/rest/status", new StatusServlet(), null, httpCtx);
m_httpService.registerServlet("/rest/network", new NetworkingServlet(), null, httpCtx);
} catch (NamespaceException e) {
s_logger.error("No http", e);
} catch (ServletException e) {
s_logger.error("No servlet", e);
}
}
I would like to build a deployment package (*.dp file, as the modbus bundle) containing a "web" bundle, how do I include my resources? Is maven the only way?
My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
|
|
| | |
Re: Packaging resources into a "web" bundle [message #1680396 is a reply to message #1668765] |
Tue, 17 March 2015 00:44 |
David Woodard Messages: 420 Registered: July 2014 |
Senior Member |
|
|
Hello,
Sorry if I missed understood your question. It sounds like you have a working web bundle and that bundle works as a deployment package if you create the deployment package manually . Is that correct? So, you are looking to create the deployment package as part of the build process? I was a little confused by your statement about the POM files. Is your web bundle building correctly as part of the Maven build? The Tycho compiler errors can be difficult to debug, if you are having build errors please post your bundle's POM file and the error you are seeing. This problem I believe is a bit different than Franz, who is trying to distribute and build his code without having the Kura target platform on his local machine. We don't have a good solution for this yet, but are working on it. One thing to make clear, the Maven local repository (~/.m2/repository) is different than the P2 repository in Kura (~/target-definition/common/repository/). You must be explicit in Maven when you are referencing a P2 repository.
If your web bundle is building correctly and you have the JAR file, you should be able to create the deployment package as part of the build. As you are aware, the DP is nothing more than a JAR file with a special manifest. So, you could use the Maven antrun plugin [1] to create the JAR with an ant jar task [2]. Let me know if you need an example of this.
[1] http://maven.apache.org/plugins/maven-antrun-plugin/
[2] https://ant.apache.org/manual/Tasks/jar.html
Thanks,
--Dave
|
|
|
Goto Forum:
Current Time: Sat Apr 27 03:10:25 GMT 2024
Powered by FUDForum. Page generated in 0.02893 seconds
|