Custom Control ClassNotFoundException in Scene Builder

Related searches

I have created a new control by extending an existing one, and I would like to use this new control in my JavaFX scenes. I would like to be able to edit my scenes using Scene Builder, but after adding the new control to the FXML file, I am encountering a ClassNotFoundException when opening Scene Builder.

For example, here is a class I made which extends TextField:

public class RegexLimitingTextField extends TextField {

    private String regexLimiter = ".*";

    public void setRegexLimiter(String regex) {
        this.regexLimiter = regex;

    public void replaceText(int start, int end, String text) {
        if (text.matches(regexLimiter))
            super.replaceText(start, end, text);

    public void replaceSelection(String replacement) {
        if (replacement.matches(regexLimiter))

After adding this control to my FXML file...


<?import javafx.scene.layout.GridPane?>
<?import sample.RegexLimitingTextField?>
<GridPane fx:controller="sample.Controller"
          xmlns:fx="" alignment="center" hgap="10" vgap="10">
    <RegexLimitingTextField fx:id="textField" text="Test" />

... I get this error when loading Scene Builder 2.0:

Caused by: java.lang.ClassNotFoundException: sample.RegexLimitingTextField
    at java.lang.ClassLoader.findClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at javafx.fxml.FXMLLoader.loadTypeForPackage(
    at javafx.fxml.FXMLLoader.loadType(
    at javafx.fxml.FXMLLoader.importClass(
    ... 23 more

Why can't Scene Builder find my new control? What do I need to do in order for it to find and be able to use my new control?

Here are the other files if needed:

public class Main extends Application {

    public static void main(String[] args) {

    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setScene(new Scene(root, 200, 200));;

public class Controller implements Initializable {
    public RegexLimitingTextField textField;

    public void initialize(URL url, ResourceBundle resourceBundle) {

If anyone is still having troubles with SceneBuilder not loading their custom components, simply passing on a ClassLoader solved the issue for me.

try {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("CustomComponent.fxml"));
} catch (IOException e ){
    throw new RuntimeException(e);

Credit goes to the miracle worker, thatjavaguy.

LoadException in SceneBuilder for custom controls nested in other , LoadException in SceneBuilder for custom controls nested in other imported into SceneBuilder because of a ClassNotFoundException for� This eliminated errors from the FXML file but the problem was that Scene Builder could not display the custom control. Here are two views in Scene Builder: Notice that the TextField for the hours used in the month does not appear. It was fine when the application ran. The DoubleTextField does appear in the graph of the container but Scene

SceneBuilder fails to open with custom controls, SceneBuilder fails to open with custom controls - from eclipse #64. Closed. gluon -bot ClassNotFoundException: org.idahosif.custom.controls. In some cases, JavaFX Scene Builder is able to load a file that contains unknown element types even if you choose to not provide their classpaths. The unknown type will not be displayed in either the Control panel or the Hierarchy panel, but their FXML elements will be preserved. If you provide a class path for your custom element types, Scene

I also have had a lot of fun with a custom component extending TextField and causing Scene Builder to freeze when opening.

The jar file I added to Scene Builder only contained this one class. But my custom component has a reference to the controller — and that's the point. When I export both classes to the jar, then everything is fine.

So if you are in a similar situation and looking for an answer, look closely at the dependencies. The world without Scene Builder is not the same.

Scene Builder does not work anymore after update to 2019.2 , NoClassDefFoundError: com/sun/javafx/fxml/LoadListener only for fxml files if The assumption is that custom JDKs would follow the upgraded folder since they � Using the JavaFX Custom Control (in Scenebuilder) Now that we have created the custom control, we can use it like any other widget. The fun thing though, is the ability to load it into Scenebuilder. In order to do this, we have a few more steps to take. Create an executable Jar out of the project that contains your custom control

JavaFX: SceneBuilder tab shows java.lang.NoClassDefFoundError , Attempting to reopen a FXML document with a custom control inside results in a ClassNotFoundException (The document was opened by� Define the structure of a simple custom control containing a TextField and a Button instance. The root container is defined as an instance of the javafx.scene.layout.VBox class. Open the custom_control.fxml file. Delete the <AnchorPane> markup that NetBeans IDE automatically generated. Add code for the root container as shown in Example 5-1.

[JDK-8153378] Opening a FXML document with a custom control , Scene Builder 8.3.0 includes a fix to load all the custom controls from any number of jars, so this issue can be closed now. @david_macgibbon Thanks for your patch, but the fix, inline with how LibraryFolderWatch::exploreAndUpdateLibrary works, didn't require exposing LibraryFolderWatch.

License: Scene Builder 11 is licensed under the BSD license. Download Scene Builder for Java 8. The latest version of Scene Builder for Java 8 is 8.5.0, it was released on Jun 5, 2018. To be kept informed of Scene Builder releases, consider subscribing to the Gluon Newsletter.

  • Probably a duplicate of…
  • @James_D That worked, thank you. I'm a bit annoyed though. Why would they remove the scenebuilder-classpath-element tag? This seems to mean that every single time I make a change to my class, I have to re-build the jar and re-import it. Is there no easier way to do this?
  • I'm sorry to hear that, @SerhiiDikobrazko. At least 5 other people seem to disagree.