This is my code snippet returning NullPointerException on garmentFactory
GarmentFactoryApplicationLauncher
loads the /config/applicationContext.xml
public class GarmentFactoryApplicationLauncher extends Application{
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/fxml/clientInterface.fxml"));
stage.setScene(new Scene(root));
stage.setResizable(false);
stage.initStyle(StageStyle.UTILITY);
stage.setTitle("GarmentFactory Factory");
stage.show();
}
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("/config/applicationContext.xml");
launch(args);
}
}
this is my applicationContext.xml
file under resources/config
folder
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="com.design"/>
</beans>
error occurs in this file, saying NullPointerException
on garmentFactory
@Component
public class ClientInterfaceController implements Initializable {
@FXML
private ChoiceBox garmentSelectionChoiceBox;
@FXML
private TextField displaySelectionTextField;
@Autowired
private GarmentFactory garmentFactory;
public void initialize(URL location, ResourceBundle resources) {
}
/**
* call the garment factory to produce garment of specific type
*/
@FXML
public void OnClickGetBtn(){
String garmentCode = (String)garmentSelectionChoiceBox.getSelectionModel().getSelectedItem();
Garment garment = garmentFactory.getGarment(garmentCode);
displaySelectionTextField.setText(garment.toString());
}
}
the GarmentFactory
is annotated with @Component
and is basic java class with some logic
What am I missing/doing wrong
Thanks