0

Problem:

When I try to add following code to context.xml of Tomcat 7 It gives this error.

(NOTE: I'm adding this code from inside the Eclipse)

<?xml version="1.0" encoding="UTF-8"?>
<Context>

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Resource
    name="jdbc/UsersDB"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="10000"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/usersDB"
    username="root"
    password="secret"
/>
</Context>

Error:

Could not load the Tomcat server configuration at \Servers\Tomcat v7.0 Server at localhost-config. The configuration may be corrupt or incomplete. Element type "Resource" must be followed by either attribute specifications, ">" or "/>".

And when I remove this code and save context.xml , Server starts successfully without doing anything (Refreshing and all).

What I have tried:

Referred This question: publishing failed with multiple errors eclipse

  • Tried closing Eclipse and opening again.
  • Tried closing and opening peoject again.

Nothing is working.

What should I try Now?

UPDATE:

Tomcat server started successfully. I just typed everything in context.xml rather than copy paste the code. It could be some encoding problem I guess in copy pasting the code directly into eclipse file.

Community
  • 1
  • 1
Vikas Agrawal
  • 35
  • 2
  • 10

2 Answers2

0

This is how it should look . Resource should be properly enclosed within the Context. Like:

   <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/webAppName">

  <Resource
    name="jdbc/UsersDB"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="10000"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/usersDB"
    username="root"
    password="secret" />

    </Context>
WannaBeGeek
  • 979
  • 14
  • 32
0

I have similar thing working. All the difference - I have one single row, not multiple lines like you have. Try it in a single row. Plus before you copy it to eclipse, try copy it to notepad, or another simple editor to remove invalid chars.

Vladimir Nabokov
  • 1,797
  • 1
  • 14
  • 19
  • This same thing is working on my laptop and denying to work on my PC. and just this problem is occured. everything else shows no error. – Vikas Agrawal Aug 01 '15 at 14:23
  • It is possible, that you saved this file with some different encoding. It may depend on tools, that you used to copy-paste the file content or the way you saved the file. I suggest to ensure, that you save file in ASCII format. Open it with notepad, instead of eclipse and save it as ascii file. – Vladimir Nabokov Aug 01 '15 at 17:28
  • I don't know where that file is located in my PC because the directory I provided for the tomcat server was not changed when I make change inside eclipse. So I suppose eclipse make his own copy of the server and I don't know where it is. I thought this could be the problem so I just manually typed everything rather than copy paste it, and It worked! Thanks for your reply :D – Vikas Agrawal Aug 02 '15 at 12:06