Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:06+00:00 2026-05-27T22:28:06+00:00

I need help with a writing a OSGI module. This is the code that

  • 0

I need help with a writing a OSGI module. This is the code that I wrote. It’s still not finished but I can compile it with Netbeans.

/*
 * OSGI Module for Sessions handling
 */

package com.SessionHandle;
/** include SQL Packages */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import javax.annotation.Resource;
   // or import javax.faces.bean.ManagedBean;   

public class sessionLogger {
    public String error_Message = null;
    public String error_Database = null;

    /** Call the Oracle JDBC Connection driver */
    @Resource(name="java:/Oracle")
    private DataSource ds;


    /** method for checking active sessions into the Oracle database.
     *  The calling module sends the UserId, UserIP, UserBrowserId.
     *  If the check is successful the LastRefreshTime is updated with
     *  with the current time.
     */

    /*
     CREATE TABLE "ACTIVESESSIONS"(
  "SessionId" Char(20 ) NOT NULL,
  "UserId" Varchar2(30 ) NOT NULL,
  "LoginTime" Timestamp(6),
  "LastRefreshTime" Timestamp(6),
  "UserIP" Varchar2(30 ),
  "UserBrowserID" Varchar2(30 )) 
     */

       public Integer activeSessionCheck(String sessionId, String userId, 
                                         String loginTime, String lastRefreshTime, 
                                         String userIp,    String userBrowserId) throws SQLException {

            String storedSession = null;
            error_Message = null;
            String SQL_Statement = null;

            if (ds == null) throw new SQLException( error_Database = "No data source");      
       Connection conn = ds.getConnection();
            if (conn == null) throw new SQLException( error_Database = "No connection");      

       try {
            conn.setAutoCommit(false);
            boolean committed = false;
                try {
                       SQL_Statement = "SELECT * from ACTIVESESSIONS WHERE SessionId = ? AND UserIP = ? AND UserBrowserID = ?";

                       PreparedStatement sessionQuery = conn.prepareStatement(SQL_Statement);
                       sessionQuery.setString(1, sessionId);
                       sessionQuery.setString(2, userIp);
                       sessionQuery.setString(3, userBrowserId);

                       ResultSet result = sessionQuery.executeQuery();

                       if(result.next()){
                            storedSession = result.getString("SessionId");
                       }

                       conn.commit();
                       committed = true;
                 } finally {
                       if (!committed) conn.rollback();
                       }
            }
                finally {               
                conn.close();

                }  
         /** If the session is not null update the session expire time */
         if (storedSession != null){

                 try {
                    conn.setAutoCommit(false);
                    boolean committed = false;
                    try {           /* insert into Oracle the default system(Linux) time */
                           SQL_Statement = "UPDATE ACTIVESESSIONS SET LastRefreshTime = SYSDATE WHERE SessionId = ?";

                           PreparedStatement insertQuery = conn.prepareStatement(SQL_Statement);                                                             
                           insertQuery.setString(1, sessionId);                       
                           insertQuery.executeUpdate();                  

                           conn.commit();
                           committed = true;
                     } finally {
                           if (!committed) conn.rollback();
                           }
                    }
                    finally {               
                    conn.close();

                    }      
               /** if the session is registered successfully return 0 */ 
               return 0;
           } else {
               /** if the session is not registered return 1 */ 
               return 1;
           }     
         /*!!!!!! dobavi vav faces-config novo navigation rule - ako se varne otgovor 1 da prepra6ta klienta na login menu */
       }

       /** method for recording user activity into the Oracle database */

       /*
        CREATE TABLE "SESSIONSLOG"(
  "SessionID" Varchar2(30 ) NOT NULL,
  "Username" Varchar2(30 ),
  "IpAddress" Varchar2(30 ),
  "WebBrowserID" Varchar2(30 ),
  "LoginTime" Timestamp(6),
  "LogoutTime" Timestamp(6)) 
        */       

       public void sessionLog(String sessionId, String userName,
                                String ipAddress, String webBrowserId,
                                String loginTime, String logoutTime) throws SQLException {

            String storedPassword = null;
            error_Message = null;
            String SQL_Statement = null;

            if (ds == null) throw new SQLException( error_Database = "No data source");      
       Connection conn = ds.getConnection();
            if (conn == null) throw new SQLException( error_Database = "No connection");      

       try {
            conn.setAutoCommit(false);
            boolean committed = false;
                try {
                       SQL_Statement = "SELECT passwd from USERS WHERE userz = ?";

                       PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
                       passwordQuery.setString(1, sessionId);

                       ResultSet result = passwordQuery.executeQuery();

                       if(result.next()){
                            storedPassword = result.getString("passwd");
                       }

                       conn.commit();
                       committed = true;
                 } finally {
                       if (!committed) conn.rollback();
                       }
            }
                finally {               
                conn.close();

                }  
       /** if the user is not found or password don't match display error message*/
       if (storedPassword == null){
           error_Message = "Invalid Username!";
       } else {
           error_Message = "Invalid Password!";
       }

       return;       
       }



       /** method for recording sessions activity into the Oracle database */

       /*
        CREATE TABLE "ACTIVESESSIONSLOG"(
  "SessionId" Varchar2(30 ) NOT NULL,
  "UserId" Varchar2(30 ),
  "ActivityStart" Timestamp(6),
  "ActivityEnd" Timestamp(6),
  "Activity" Clob) 
        */

       public void activeSessionLog(String sessionId,     String userId,
                                      String activityStart, String activityEnd,
                                      String Activity) throws SQLException {
            String storedPassword = null;
            error_Message = null;
            String SQL_Statement = null;

            if (ds == null) throw new SQLException( error_Database = "No data source");      
       Connection conn = ds.getConnection();
            if (conn == null) throw new SQLException( error_Database = "No connection");      

       try {
            conn.setAutoCommit(false);
            boolean committed = false;
                try {
                       SQL_Statement = "SELECT passwd from USERS WHERE userz = ?";

                       PreparedStatement passwordQuery = conn.prepareStatement(SQL_Statement);
                       passwordQuery.setString(1, sessionId);

                       ResultSet result = passwordQuery.executeQuery();

                       if(result.next()){
                            storedPassword = result.getString("passwd");
                       }

                       conn.commit();
                       committed = true;
                 } finally {
                       if (!committed) conn.rollback();
                       }
            }
                finally {               
                conn.close();

                }  
       /** if the user is not found or password don't match display error message*/
       if (storedPassword == null){
           error_Message = "Invalid Username!";
       } else {
           error_Message = "Invalid Password!";
       }

       return;       
       }


}

This is the file structure of the OSGI bundle:

rcbandit@rcbandit-laptop:~/NetBeansProjects$ tree SL_24
SL_24
├── nbactions.xml
├── pom.xml
├── src
│   └── main
│       ├── assembly
│       │   └── felix.xml
│       ├── java
│       │   └── com
│       │       ├── SessionHandle
│       │       │   └── sessionLogger.java
│       │       └── SL_24
│       │           └── Activator.java
│       └── resources
│           └── com
│               └── SL_24
└── target
    ├── classes
    │   ├── com
    │   │   ├── SessionHandle
    │   │   │   └── sessionLogger.class
    │   │   └── SL_24
    │   │       └── Activator.class
    │   └── META-INF
    │       └── MANIFEST.MF
    ├── generated-sources
    │   └── annotations
    ├── SL_24-1.0-SNAPSHOT.jar
    └── surefire

19 directories, 9 files

And this is the Activator class which I don’t know how to write:

package com.SL_24;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

    public void start(BundleContext context) throws Exception {
        System.out.println("Module SL_24 is Loaded!");
    }

    public void stop(BundleContext context) throws Exception {
        System.out.println("Module SL_24 in Unloaded!");
    }

}

The problem comes when i try to deploy it to JBoss 7.1.0 server. It seems that the activator class is not properly written. Can you help me write it in proper way and how after that I can call methods for the OSGI bundle insight EAR package?

King Regards,

Peter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:28:07+00:00Added an answer on May 27, 2026 at 10:28 pm

    Based on the error trace given in your comment, I see that there is a NullPointerException being thrown from within JBoss. It seems likely that this is a bug in JBoss and should therefore be discussed on the JBoss forums.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help in writing java code that can connect to a remote UNIX
I need help with writing some code that will create a random number from
Hey guys! I need some help writing a code that creates an array in
Need help writing a script downloads data from google insight using c# this is
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help writing a basic IRC bot that just connects to a channel..
I need help writing a regex for a phone number pattern that allows the
I need help with writing regular expression for this pattern in PHP: [[{type:media,view_mode:small,fid:1,attributes:{width:0,height:0,src:http://localhost/x.png}}]] This
Im still a beginner in C programming and I need a little help writing
I need help writing a piece of JQuery using the slideToggle(), that is reusable.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.