Go Apache Tika Error - debug ideas? `could not wait for server to finish: exit status 1`

I use the package “github.com/google/go-tika/tika” to start an Apache Tika Server and extract the text content from PDFs. When closing the Tika server I get the error message:

could not wait for server to finish: exit status 1

At the end of the func Main I run:

//Stop Tika server & delete server
defer func() {
	err = s.Stop()
	if err != nil {
		fmt.Println("Stop Tika server error:", err)
	// Nachdem der Tika-Server verwendet wurde, löschen
	err = os.Remove(tikaServerPath)
	if err != nil {
		log.Println("Delete Tika Server error: ", err)

I’m running the tool on Windows. The Stop() function has the following code:

// Stop shuts the server down, killing the underlying Java process. Stop
// must be called when finished with the server to avoid leaking the
// Java process. If it has not been started, stop will panic.
// If not running in a Windows environment, it is recommended to use Shutdown
// for a more graceful shutdown of the Java process.
func (s *Server) Stop() error {
	if err := s.cmd.Process.Kill(); err != nil {
		return fmt.Errorf("could not kill server: %v", err)
	if err := s.cmd.Wait(); err != nil {
		return fmt.Errorf("could not wait for server to finish: %v", err)
	return nil


// Wait releases any resources associated with the Cmd.
func (c *Cmd) Wait() error {
	if c.Process == nil {
		return errors.New("exec: not started")
	if c.ProcessState != nil {
		return errors.New("exec: Wait was already called")

	state, err := c.Process.Wait()
	if err == nil && !state.Success() {
		err = &ExitError{ProcessState: state}
	c.ProcessState = state

	var timer *time.Timer
	if c.ctxResult != nil {
		watch := <-c.ctxResult
		timer = watch.timer
		// If c.Process.Wait returned an error, prefer that.
		// Otherwise, report any error from the watchCtx goroutine,
		// such as a Context cancellation or a WaitDelay overrun.
		if err == nil && watch.err != nil {
			err = watch.err

	if goroutineErr := c.awaitGoroutines(timer); err == nil {
		// Report an error from the copying goroutines only if the program otherwise
		// exited normally on its own. Otherwise, the copying error may be due to the
		// abnormal termination.
		err = goroutineErr
	c.parentIOPipes = nil

	return err

Do you have any ideas how I can get to the bottom of the error?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.