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 8021859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:06:32+00:00 2026-06-04T22:06:32+00:00

I have a service interface that reads thus package services; import domain.Items; public interface

  • 0

I have a service interface that reads thus

package services;

import domain.Items;

public interface IItemsService extends IService {

public final String NAME = "IItemsService";


/** Places items into the database */
public void storeItem(Items items);




/** Retrieves items from the database
 * 
 * @param category
 * @param amount
 * @param color
 * @param type
 * @return
 * @throws ClassNotFoundException 
 */
public Items getItems (String category, float amount, String color, String type) throws ItemNotFoundException, ClassNotFoundException;

}

And a factory that looks like this…

package services;
public class Factory {



public Factory(){}



@SuppressWarnings("unchecked")
public IService getService(String name) throws ServiceLoadException {
    try {
        Class c = Class.forName(getImplName(serviceName));
        return (IService)c.newInstance();
    } catch (Exception e) {
        throw new ServiceLoadException(serviceName + "not loaded");
    }
}



private String getImplName (String name) throws Exception {
    java.util.Properties props = new java.util.Properties();
        java.io.FileInputStream fis = new java.io.FileInputStream("properties.txt");
            props.load(fis);
                fis.close();
                return props.getProperty(serviceName);
}
}

This should be really simple – but I keep getting two errors – IService cannot be resolved to a type (on both the factory and the service) and also an serviceName cannot be resolved into a variable error in the factory. I know I am missing something simple…

  • 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-06-04T22:06:34+00:00Added an answer on June 4, 2026 at 10:06 pm

    Regarding the type error: if IService is not in the package services, then IItemService will not have access to it and you will need to import some.package.name.IService.

    The second answer is simple: in the getService and getImplName methods, the parameter is named name. In the method bodies, you’re referring to it as serviceName. You should probably change name to serviceName in each of them.

    If, on the other hand, you’re trying to access an instance variable, note that in Java you have to declare all instance variables before you can access (read from/write to) them. You would need to modify the class as such:

    public class Factory {
    
        private String serviceName;
    
        public Factory () {}
    
        // other code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a service contract as follow [ServiceContract] public interface IService { [MyCustomBehavior] [OperationContract]
I have a WCF service and methods are exposed as below: public interface IService
I have some interface that is marked as a [ServiceContract] for WCF service. But
I have a service with multiple contracts like so. [ServiceContract] public partial interface IBusinessFunctionDAO
I currently have service classes that look something like this public class UserService :
I have a User Interface that receives asynchronous notifications from a Service that prompts
I have a REST web-service interface that calls-down to a service layer which orchestrates
I have created a WCF service interface and implementation in a Class Library. I
I have several services implementing a common interface and I want to be able
I have written a service that I would like expose both via rest and

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.