简体   繁体   中英

Do-While loop is showing a lot of error while entering user input (Java -OSGi Equinox in Eclipse EE

I am new to OSGi Equinox. I am trying to do a Producer-Consumer sample. I have one consumer and 2 producers. When I run the project everything is working fine. Services started and working successfully.

In the consumer I have a Do-While loop where if user enter "no" the loop will continue. If they type "yes" or any other, the loop needs to stop and execute the function I have mentioned.

"no" command is working successfully. But if I type yes or anything it is showing a lot of errors. This is the beginning of the error. (I can provide full error if needed)

错误

This is the Do-While loop I have. I tried running the SubMethod.PrintBill() function, but still got the same error.

private void MainMethod() {
    Scanner sc=new Scanner(System.in);
    String user_option="no";
    
    do {
        int serviceType = SubMethod.find();
        
        if(serviceType == 1) {
            ServiceReference service_1 = context.getServiceReference(Vehicle_Interface.class.getName());
            Vehicle_Interface Vehicle_Int =(Vehicle_Interface) context.getService(service_1);
            SubMethod.vehicleService(Vehicle_Int);
            context.ungetService(service_1);
        }
        else if(serviceType == 2) {
            
            ServiceReference service_2 = context.getServiceReference(Food_Interface.class.getName());
            Food_Interface Food_Int =(Food_Interface)context.getService(service_2);
            SubMethod.foodService(Food_Int);
            context.ungetService(service_2);
        }
        else {
            System.out.println("");
        }
        System.out.println("Do you want to exit? \n 'yes' for YES \n 'no' for NO");
        user_option = sc.next();
        
    }while(user_option.equals("no"));   
    SubMethod.PrintBill();
    
}

Do I need to add any dependencies related to (OSGi) or anything to resolve the issue? Can someone explain why this error is coming and how to resolve it?

I think the whole code of the project is not necessary. But if needed please ask. I can provide.

Thank-you in advance.

This is completely unrelated to any Java code (while loop or anything).

Your module (OSGi bundle) com.sun.xml.bind with ID 22 can't be resolved . The reason is that another module (OSGi bundle) can't be resolved and this module is a bundle with javax.activation symbolic name.

The exact reason why javax.activation is not resolved is that it requires JDK 9, while you're probably using JDK 8 (or earlier).

The version of javax.activation you're using is 1.2.2.v20201119-1642 , which means it is NOT an official bundle available in:

You're probably using some repackage version of Activation API from Eclipse repositories. Please either use JDK11+ or replace the Activation bundle with the official one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM