0

I am working with Java 8 application. I am trying to create a file. When I deploy the war in jboss 10 server and start it, file is not generated. At second run file is generated. Can someone please help me over this? My code for file generation is:

File workletProps = new File(configDir, DBConstants.OfflineWorkletExportProperties.WORKLET_EXPORT_CONFIG_WORKLET_PROPERTIES.getGettypeValue() +".properties");

PrintWriter pw = new PrintWriter(workletProps);

pw.println("WORKLET_ID=" + worklet.getId());
pw.println("PROJECT_ID=" + worklet.getProject().getId());

pw.flush();
pw.close();
Assafs
  • 3,257
  • 4
  • 26
  • 39
user82504
  • 111
  • 1
  • 12

1 Answers1

0

Please refer to Eager / auto loading of EJB / load EJB on startup (on JBoss) on how to execute code on JBoss startup. JBoss 10 (Wildfly 10) supports Java EE 7 which includes EJB 3.2, which should empower you to do the following:

@Singleton
@Startup
public class StartupBean {
    @PostConstruct
    private void postConstruct() {
        // your file generation code here, enriche with exception handling and logging
    }

If that does not work as you expect, set a break point and debug. }

Lars Gendner
  • 1,816
  • 2
  • 14
  • 24