I’m trying to implement logging system into OSGI bundle. This is the bundle activator:
import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Properties;
import org.DX_57.osgi.LS_27.api.LoggingSystem;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
public class LoggingSystemApp implements BundleActivator {
LoggingSystemImpl log = null;
public ServiceTracker st;
@Override
public void start(final BundleContext bc) throws Exception {
debug("Activator started");
ServiceRegistration registerService = bc.registerService(LoggingSystemImpl.class.getName(), new LoggingSystemImpl() {}, new Properties());
/* Start Logger System */
log = LoggingSystemImpl.getInstance();
log.start();
}
public void stop(BundleContext bc) throws Exception {
boolean ungetService = bc.ungetService(bc.getServiceReference(LoggingSystem.class.getName()));
st.close();
log.stop();
}
private void debug(String msg) {
System.out.println("JDBCBundleActivator: " + msg);
}
}
This is the code if the logging system:
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.sql.Connection;
import javax.sql.DataSource;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Locale;
import org.DX_57.osgi.LS_27.api.LoggingSystem;
public class LoggingSystemImpl implements LoggingSystem {
public LoggingSystemImpl() {
}
private final static Calendar calendar = Calendar.getInstance();
private final static String user = System.getenv("USERNAME").toLowerCase();
private final static String sMonth = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH);
private final static int y = calendar.get(Calendar.YEAR);
// the name of the log file
//private final String logName = sysDrive + "\\fttb_web - " + sMonth.toLowerCase() + ", " + y + ".log";
private final String logName = "logger - " + sMonth.toLowerCase() + ", " + y + ".log";
private static boolean closed;
private static LoggingSystemImpl log = null;
private static BufferedWriter bw = null;
private static FileOutputStream fos = null;
private static OutputStreamWriter osw = null;
/* Utilialize Buffer and wait for data to write */
public void start() throws IOException{
log = LoggingSystemImpl.getInstance();
}
public void stop(){
log.close();
}
public void WriteLog(String WriteString){
log.writeln(WriteString);
}
public void LoggingSystemImpl() throws IOException
{
fos = new FileOutputStream(logName, true);
// set encoding to cyrillic (if available)
if (Charset.isSupported("windows-1251"))
{
osw = new OutputStreamWriter(fos, Charset.forName("windows-1251"));
}
else { osw = new OutputStreamWriter(fos); }
bw = new BufferedWriter(osw, 2048); // 2Mb buffer
}
// intro header for log session
public static synchronized LoggingSystemImpl getInstance() throws IOException
{
boolean exc = false;
try
{
if (log == null || closed)
{
log = new LoggingSystemImpl() {};
closed = false;
log.writeln("logged in.");
log.nl();
}
}
// catch(IOException x) { exc = true; throw x; }
catch(Exception x) { exc = true; x.printStackTrace(); }
finally
{
if (exc)
{
try
{
if (fos != null) { fos.close(); fos = null; }
if (osw != null) { osw.close(); fos = null; }
if (bw != null) { bw.close(); bw = null; }
}
catch(Exception x) { x.printStackTrace(); }
}
}
return log;
}
public synchronized void nl()
{
try { bw.newLine(); }
catch(IOException x) {x.printStackTrace();}
}
public synchronized void nl(int count)
{
try
{
for (int i = 0; i < count; i++) bw.newLine();
}
catch(IOException x) {x.printStackTrace();}
}
public synchronized void writeln(String s)
{
try { bw.write(getTime() + ": " + s); bw.newLine(); }
catch(IOException x) {x.printStackTrace();}
}
public synchronized void write(String s)
{
try { bw.write(s); }
catch (IOException x) {x.printStackTrace();}
}
public synchronized void close()
{
try
{
if (bw != null)
{
writeln("logged out.");
nl();
bw.flush();
bw.close();
closed = true;
fos = null;
osw = null;
bw = null;
}
}
catch(IOException x) { x.printStackTrace(); }
}
public synchronized boolean isClosed() { return closed; }
public synchronized void writeException(Exception x)
{
writeln("");
write("\t" + x.toString()); nl();
StackTraceElement[] ste = x.getStackTrace();
int j = 0;
for (int i = 0; i < ste.length; i++)
{
if (i < 15) { write("\t\tat " + ste[i].toString()); nl(); }
else { j++; }
}
if (j > 0) { write("\t\t... " + j + " more"); nl(); }
nl(2);
}
private String getTime()
{
Calendar c = Calendar.getInstance();
int month = c.get(Calendar.MONTH) + 1;
int d = c.get(Calendar.DAY_OF_MONTH);
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
int s = c.get(Calendar.SECOND);
int y = c.get(Calendar.YEAR);
String dd = d < 10 ? "0"+d : ""+d;
String hh = h < 10 ? "0"+h : ""+h;
String mm = m < 10 ? "0"+m : ""+m;
String ss = s < 10 ? "0"+s : ""+s;
String sm = month < 10 ? "0"+month : ""+month;
return user + " [" + y + "." + sm + "." + dd + " " + hh + ":" + mm + ":" + ss + "]";
}
}
This is the Java interface:
public interface LoggingSystem {
}
When I try to deploy the code on Glassfish server I get this error stack:
[#|2012-03-14T13:20:42.940+0200|INFO|glassfish3.1.2|org.hibernate.validator.util.Version|_ThreadID=50;_ThreadName=Thread-2;|Hibernate Validator 4.2.0.Final|#]
[#|2012-03-14T13:20:44.147+0200|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=50;_ThreadName=Thread-2;|WEB0671: Loading application [__admingui] at [/]|#]
[#|2012-03-14T13:20:44.150+0200|INFO|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=50;_ThreadName=Thread-2;|CORE10010: Loading application __admingui done in 12,777 ms|#]
[#|2012-03-14T13:20:44.150+0200|INFO|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.admin.adapter|_ThreadID=50;_ThreadName=Thread-2;|The Admin Console application is loaded.|#]
[#|2012-03-14T13:20:54.222+0200|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.com.sun.enterprise.container.common|_ThreadID=66;_ThreadName=Thread-2;|User [] from host localhost does not have administration access|#]
[#|2012-03-14T13:21:10.569+0200|INFO|glassfish3.1.2|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=75;_ThreadName=Thread-2;|Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false |#]
[#|2012-03-14T13:21:12.530+0200|INFO|glassfish3.1.2|com.sun.jersey.server.impl.application.WebApplicationImpl|_ThreadID=75;_ThreadName=Thread-2;|Initiating Jersey application, version 'Jersey: 1.11 12/09/2011 10:27 AM'|#]
[#|2012-03-14T13:21:13.546+0200|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.admin.rest.adapter|_ThreadID=75;_ThreadName=Thread-2;|REST00001: Listening to REST requests at context: /management/domain|#]
[#|2012-03-14T13:21:13.587+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=74;_ThreadName=Thread-2;|Redirecting to /common/index.jsf|#]
[#|2012-03-14T13:21:14.133+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=72;_ThreadName=Thread-2;|Admin Console: Initializing Session Attributes...|#]
[#|2012-03-14T13:22:04.476+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=74;_ThreadName=Thread-2;|Stopped LS_27-api [470]|#]
[#|2012-03-14T13:22:04.489+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=74;_ThreadName=Thread-2;|Uninstalled LS_27-api [470]|#]
[#|2012-03-14T13:22:04.878+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=137;_ThreadName=Thread-2;|com.sun.webui.jsf.component.DropDown::The current value of component propertyForm:deployTable:topActionsGroup1:filter does not match any of the selections.
Did you forget to reset the value after changing the options? |#]
[#|2012-03-14T13:22:19.830+0200|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=135;_ThreadName=Thread-2;|PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called|#]
[#|2012-03-14T13:22:19.968+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=135;_ThreadName=Thread-2;|GUI deployment: uploadToTempfile|#]
[#|2012-03-14T13:22:19.995+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=135;_ThreadName=Thread-2;|uploadFileName=LS_27-api-1.0-SNAPSHOT.jar|#]
[#|2012-03-14T13:22:20.081+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=302;_ThreadName=Thread-2;|Installed LS_27-api [472] from reference:file:/opt/glassfish3/glassfish/domains/domain1/applications/LS_27-api-1.0-SNAPSHOT/|#]
[#|2012-03-14T13:22:20.090+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=302;_ThreadName=Thread-2;|Started LS_27-api [472]|#]
[#|2012-03-14T13:22:20.128+0200|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=302;_ThreadName=Thread-2;|LS_27-api-1.0-SNAPSHOT was successfully deployed in 115 milliseconds.|#]
[#|2012-03-14T13:22:33.840+0200|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=313;_ThreadName=Thread-2;|PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called|#]
[#|2012-03-14T13:22:33.962+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=313;_ThreadName=Thread-2;|GUI deployment: uploadToTempfile|#]
[#|2012-03-14T13:22:33.963+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=313;_ThreadName=Thread-2;|uploadFileName=LS_27-impl-1.0-SNAPSHOT.jar|#]
[#|2012-03-14T13:22:34.043+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=311;_ThreadName=Thread-2;|Installed LS_27-impl [473] from reference:file:/opt/glassfish3/glassfish/domains/domain1/applications/LS_27-impl-1.0-SNAPSHOT/|#]
[#|2012-03-14T13:22:34.046+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=311;_ThreadName=Thread-2;|JDBCBundleActivator: Activator started|#]
[#|2012-03-14T13:22:34.050+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=311;_ThreadName=Thread-2;|Exception while invoking class org.glassfish.extras.osgicontainer.OSGiDeployedBundle start method
java.lang.RuntimeException: org.osgi.framework.BundleException: Activator start error in bundle LS_27-impl [473].
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.startBundle(OSGiDeployedBundle.java:110)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.resume(OSGiDeployedBundle.java:83)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.start(OSGiDeployedBundle.java:67)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:391)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207)
at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.osgi.framework.BundleException: Activator start error in bundle LS_27-impl [473].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2027)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.startBundle(OSGiDeployedBundle.java:107)
... 56 more
Caused by: java.lang.ExceptionInInitializerError
at org.DX_57.osgi.LS_27.impl.LoggingSystemApp.start(LoggingSystemApp.java:38)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
... 59 more
Caused by: java.lang.NullPointerException
at org.DX_57.osgi.LS_27.impl.LoggingSystemImpl.<clinit>(LoggingSystemImpl.java:41)
... 62 more
|#]
[#|2012-03-14T13:22:34.072+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=311;_ThreadName=Thread-2;|Exception while loading the app|#]
[#|2012-03-14T13:22:34.077+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=311;_ThreadName=Thread-2;|Uninstalled LS_27-impl [473]|#]
[#|2012-03-14T13:22:34.080+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=311;_ThreadName=Thread-2;|Exception while loading the app : org.osgi.framework.BundleException: Activator start error in bundle LS_27-impl [473].
org.osgi.framework.BundleException: Activator start error in bundle LS_27-impl [473].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2027)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.startBundle(OSGiDeployedBundle.java:107)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.resume(OSGiDeployedBundle.java:83)
at org.glassfish.extras.osgicontainer.OSGiDeployedBundle.start(OSGiDeployedBundle.java:67)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:391)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214)
at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207)
at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ExceptionInInitializerError
at org.DX_57.osgi.LS_27.impl.LoggingSystemApp.start(LoggingSystemApp.java:38)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
... 59 more
Caused by: java.lang.NullPointerException
at org.DX_57.osgi.LS_27.impl.LoggingSystemImpl.<clinit>(LoggingSystemImpl.java:41)
... 62 more
|#]
[#|2012-03-14T13:22:34.084+0200|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=313;_ThreadName=Thread-2;|Exception Occurred :Error occurred during deployment: Exception while loading the app : org.osgi.framework.BundleException: Activator start error in bundle LS_27-impl [473].. Please see server.log for more details.|#]
I have an error in the bundle activator which I cannot find.
I want to implement logging bundle which writes error messages into text file. When the bundle is deployed the bundle must open the text file and listens for messages from other OSGI bundles which it must record into the file.
Best Wishes
Peter
It seems the Exception is thrown at the class intitialization (as pointed by the stacktrace
at ... LoggingSystemImpl.<clinit>).This is usually thrown when there is some error at the class static fields initialization stage.
Checking your
LoggingSystemImplclass code, found this at the fields declaration:If system can’t find this environment value, it will return
null(reference), and thus, thetoLowerCaseinvocation on a null reference will throw aNullPointerException.Have you checked if the environment property
"USERNAME"is available at runtime?