I am new Java web service programmer and I am looking to see why I see 2 instances of my service being created when I have 2 web pages open to it (One over localhost and another from a different PC using the server PC's IP address and web service URL).
Stack details: Using Tomcat, Java web service under Windows 7 PC.
I have a small web service that connects to a black box internally. Each time I bring up the web service and open up a URL associated with it, I can see the details from the black box. The problem is, when I have 2 web pages open to the web service (One over localhost and another from a different PC using the server PC's IP address and web service URL), I see two instances of the service being created and that are trying to connect to one black box at the same time. I need the ability to start the connect to the black box remotely or locally. But, only the localhost connection should win. I tried creating a servlet to start the service when Tomcat startup but not much luck with it. With the servlet, I see my autowired Datasource connection is null.
Any idea on this would help.
@Repository public class HServiceDAO {
@Autowired
private DataSource mySql_dataSrc;
web.xml
<servlet>
<servlet-name>StartWebApp</servlet-name>
<servlet-class>com.StartWebApp</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Aucun commentaire:
Enregistrer un commentaire