facebook

JDBC Setup in Web.xml for Struts Project.

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #203438 Reply

    Hi.
    I want to setup a Struts Project and define a JNDI DataSource in my Web.xml file.

    however.. When I setup the JNDI Resource it gives me validation errors.

    I have the xml and the erros listed below.

    I am using Tomcat 5.0 and I have tested this XML on other native apps outside of MyEclipse.

    If you can please advise I would appreciate it.

    Thanks,
    Kevin.
    XML Snipted contained within the <web-app> tag

    <Resource name=”jdbc/as400″ auth=”Container” type=”javax.sql.DataSource”/>
    <ResourceParams name=”jdbc/sqlserver”>
    <parameter>
    <name>username</name>
    <value>sa</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>blahblahblah</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:microsoft:sqlserver://dbserver</value>
    </parameter>
    <parameter>
    <name>catalog</name>
    <value>test</value>
    </parameter>
    </ResourceParams>
    <resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/sqlserver</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>

    causes error
    Kind Status Priority Description Resource In Folder Location
    Error Element type “Resource” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 27
    Error Element type “ResourceParams” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 28
    Error Element type “parameter” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 29
    Error Element type “name” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 30
    Error Element type “value” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 31
    Error Element type “parameter” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 33
    Error Element type “name” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 34
    Error Element type “value” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 35
    Error Element type “parameter” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 37
    Error Element type “name” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 38
    Error Element type “value” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 39
    Error Element type “parameter” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 41
    Error Element type “name” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 42
    Error Element type “value” must be declared. web.xml StrutsDemo/WebRoot/WEB-INF line 43
    Error The content of element type “web-app” must match “(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)”. web.xml StrutsDemo/WebRoot/WEB-INF line 52

    #203443 Reply

    Riyad Kalla
    Member

    The XMl snippet you just copy-pasted is actually what should go into your server’s config file. On Tomcat 4.1 this was in the:
    <tomcat home>\conf\server.xml file
    in Tomcat 5.0 its in:
    <tomcat home>\conf\localhost\<webapp name>.xml file

    this sets up your applications parameters. You can also do this via a GUI using the Tomcat administrator.

    If you notice the error from validation, those tags you entered aren’t valid for the web.xml file. The only thing that you can put in the web.xml file related to a data source, is a reference to it; and this isn’t even necessary 😉

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: JDBC Setup in Web.xml for Struts Project.

You must be logged in to post in the forum log in