Hello Guillaume,
merci beaucoup. It works.
This is the content of the file I generate during validate/invalidate:
Starting workbench server, log is
org.osgi.service.log.LogService$$Proxy@16a327b0
Stopping workbench server, log is
org.osgi.service.log.LogService$$Proxy@16a327b0
So the log service is available. Can someone tell me how to configure
the log file it should use?
Hermann
Am 06.01.2014 15:38, schrieb Guillaume Sauthier (OW2/GMail):
Hi Hermann
Make sure you manipulate your bundles with the latest ipojo manipulator
(1.11.0) (there are ant, maven and bnd extension available).
--G
2014/1/6 Hermann Matthes <[email protected]>
Hello Clement,
thnaks a lot for the quick answer.
When I set the LogServervice to optional and reinstall the module, I get
the following log error meeesage during "start":
2014-01-06 15:19:34,517 | ERROR | pool-1-thread-1 | server
| ? ? | 96 - server -
1.0.0.SNAPSHOT | [ERROR] : [de.hermannmatthes.workbench.server.ServerImpl-0]
createInstance -> The POJO constructor invocation failed : Expecting a
stackmap frame at branch target 12 in method
de.hermannmatthes.workbench.server.ServerImpl.start()V
at offset 4
java.lang.VerifyError: Expecting a stackmap frame at branch target 12 in
method de.hermannmatthes.workbench.server.ServerImpl.start()V at offset 4
at java.lang.Class.getDeclaredConstructors0(Native Method)[:1.7.0_07]
at java.lang.Class.privateGetDeclaredConstructors
(Class.java:2404)[:1.7.0_07]
at java.lang.Class.getConstructor0(Class.java:2714)[:1.7.0_07]
at java.lang.Class.getDeclaredConstructor(Class.java:2002)[:1.7.0_07]
at org.apache.felix.ipojo.InstanceManager.createObject(
InstanceManager.java:715)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.InstanceManager.getPojoObject(
InstanceManager.java:923)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.handlers.lifecycle.callback.
LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:
156)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.handlers.lifecycle.callback.
LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.InstanceManager.setState(
InstanceManager.java:536)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.InstanceManager.start(
InstanceManager.java:418)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.ComponentFactory.createInstance(
ComponentFactory.java:179)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(
IPojoFactory.java:319)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(
IPojoFactory.java:240)[84:org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.extender.internal.linker.
ManagedType$InstanceSupport$1.call(ManagedType.java:312)[84:
org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.extender.internal.linker.
ManagedType$InstanceSupport$1.call(ManagedType.java:306)[84:
org.apache.felix.ipojo:1.11.0]
at org.apache.felix.ipojo.extender.internal.queue.
JobInfoCallable.call(JobInfoCallable.java:114)[84:
org.apache.felix.ipojo:1.11.0]
at java.util.concurrent.FutureTask$Sync.innerRun(
FutureTask.java:334)[:1.7.0_07]
at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1110)[:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:603)[:1.7.0_07]
at java.lang.Thread.run(Thread.java:722)[:1.7.0_07]
2014-01-06 15:19:34,517 | ERROR | pool-1-thread-1 | server
| ? ? | 96 - server -
1.0.0.SNAPSHOT | [ERROR] de.hermannmatthes.workbench.server.ServerImpl :
Cannot create a POJO instance, the POJO constructor invocation has thrown
an exception
Does anybody know what's the reason for that error?
Hermann
Am 06.01.2014 07:42, schrieb Clement Escoffier:
Hi,
On 5 janv. 2014, at 20:07, Hermann Matthes <[email protected]>
wrote:
Hello everybody,
I try to learn ipojo to implement a simple server using Netbeans 7.4 and
Apache Karaf.
My first goal is to write a really simple server which just prints a
message when it's activated or deactivated. No tutorial which I found gave
enough information to perform such a simple task.
Here's my code:
The server interface:
package de.hermannmatthes.workbench.server;
public interface Server {
public void start();
public void stop();
}
The server implementation:
package de.hermannmatthes.workbench.server;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Validate;
import org.osgi.service.log.LogService;
@Component(immediate=true)
@Instantiate
public class ServerImpl implements Server {
@Requires(policy="static")
private LogService log;
@Override
@Validate
public void start() {
trace("Starting workbench server, log is " + log);
log.log(LogService.LOG_INFO, "Starting workbench server.");
}
@Override
@Invalidate
public void stop() {
trace("Stopping workbench server, log is " + log);
log.log(LogService.LOG_INFO, "Stopping workbench server.");
}
private void trace(final String msg) {
FileWriter w = null;
try {
w = new FileWriter("C:/temp/test.log", true);
w.write(msg + "\n");
} catch (IOException ex) {
Logger.getLogger(ServerImpl.class.getName()).log(Level.SEVERE,
null, ex);
}
finally {
if (w!=null) {
try {
w.close();
} catch (IOException ex) {
Logger.getLogger(ServerImpl.
class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
If I install the module in karaf and resolve it, everything's fine. But
when I start it, its state changes to Active but nothing happens. In the
attachment you find my project file.
Can someone tell me whats wrong with my code?
Is the log service available ? Try to set it ‘optional’ (optional=true).
Regards,
Clement
Any hint is welcome
Hermann
<pom.xml>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]