# Could Not Initialize Class PreBuiltTransportClient

**URL:** <https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097>\
**Category:** Elasticsearch\
**Created:** [December 27, 2016, 9:50pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097 "2016-12-27T21:50:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![selpathor](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@selpathor](https://discuss.elastic.co/u/selpathor)\
**Post date:** [December 27, 2016, 9:50pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/1 "2016-12-27T21:50:02Z")

</div>

So I am working on a Java Spring project that IS NOT USING MAVEN and I am having some trouble getting my TransportClient started. I am using elasticsearch 5.1.1. My Code:

```
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.elasticsearch.transport.client.*;
import java.net.InetSocketAddress;

@Controller
public class DBTest{
	@RequestMapping(value="/elastictest",method=RequestMethod.GET)
	public void elasticTestFunction(ModelMap modelMap){
		try{
			TransportClient client = new PreBuiltTransportClient(Settings.EMPTY);
			client.addTransportAddress(new InetSocketTransportAddress( new InetSocketAddress("127.0.0.1", 9200) ) );
			client.close();
		}catch (Exception e){
			e.printStackTrace();	
		}
	}
}

```

When attempting to create my transport client I get an error: Could not initialize class org.elasticsearch.transport.client.PreBuiltTransportClient. Stacktrace below:

```
        java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.transport.client.PreBuiltTransportClient
	com.inspirave.controller.DBTest.elasticTestFunction(DBTest.java:49)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	java.lang.reflect.Method.invoke(Unknown Source)
	org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:205)
	com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:266)

```

Has anyone encountered an error like this before? Thank you for your help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 27, 2016, 10:03pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/2 "2016-12-27T22:03:15Z")

</div>

You did not add needed dependencies to your project.

---

<div class="post-metadata">

**Author:** ![selpathor](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@selpathor](https://discuss.elastic.co/u/selpathor)\
**Post date:** [December 28, 2016, 11:39am UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/3 "2016-12-28T11:39:48Z")

</div>

Okay, Is there somewhere where I can find a comprehensive list of all dependencies needed since I am not using maven?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 28, 2016, 12:28pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/4 "2016-12-28T12:28:46Z")

</div>

Not any updated AFAIK.  
On this forum you can probably find some of them.

Ideally, install maven, add just the transport client dependency, then run mvn dependency:tree and you will get that list.

HTH

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [December 28, 2016, 12:30pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/5 "2016-12-28T12:30:34Z")

</div>

Use a dependency management system to list you / download the files, with the techniques outlined [here](http://halyph.com/blog/2015/03/17/how-to-download-jars-from-maven-central.html) for example:

```auto
# 1. Download the latest ivy jar (currently it's v.2.4.0)
curl -L -O http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar

# 2. Run ivy.jar to retrieve all dependencies
java -jar ivy-2.4.0.jar -confs default -dependency org.elasticsearch.client transport 5.1.1 -retrieve "lib/[artifact]-[revision](-[classifier]).[ext]"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 25, 2017, 12:30pm UTC](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/6 "2017-01-25T12:30:55Z")

</div>

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