Missing schema definitions in IntelliJ - java

Having updated to IntelliJ 14.0.3 Community Edition I am working on a new web project, but suddenly IntelliJ does not find the most basic schema definitions anymore. Here are examples: http://i.stack.imgur.com/FVYld.png and http://i.stack.imgur.com/SboLZ.png.
I have tried to 'Fetch External Resource', but with no success.
Using this approach "JSF xmlns URI not registered in IntelliJ IDEA" I imported web-facelettaglibrary_2_2.xsd, but the auto competition had errors and was useless.
I try to get this to work for weeks now and get 'URI is not registered' and 'Cannot resolve symbol' errors all over the place. How IntelliJ can be unaware of these URIs is completely beyond me.
Can someone please help me get my beloved auto competition up and running again?
Update:
I finally got the web-app schema working by adding web-app_3_1.xsd and every file it references and their references as well, namely:
javaee_7.xsd
javaee_web_services_client_1_4.xsd
jsp_2_3.xsd
web-app_3_1.xsd
web-common_3_1.xsd.
All from here: hxxp://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html

I have tried the same (with the firewall blocking all IntelliJ's external connections) and this worked for me:
web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"></web-app>
pom.xml
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
From Java EE Schemas download the definition web-app_3_1.xsd. In IntelliJ manually add an external resource and select the file you just downloaded. You can also see it under Settings > Languages & Frameworks > Schemas and DTDs in the list of external schemas.

Related

Is there a new schema location for websphere ibm-web-bnd.xml?

This used to work fine:
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0">
<virtual-host name="default_host" />
</web-bnd>
And at deploy-time it still does but Eclipse's validator keeps show annoying "errors" because http://websphere.ibm.com/xml/ns/javaee does not point to a valid site anymore (redirects to some search site),when trying to download the schemas.
I know that probably I'll just have to turn off validation for these files, but let me try asking first:
Is there a new home for those schemas?
Or somewhere to alert IBM that they are failing miserably on that regard...?
Install WebSphere Developer Tools via Eclipse Marketplace. It will add required schema to the XML Catalog in the Eclipse. You can check if you have them via Preferences > XML > XML catalog. These schemas are in one of the jars from plugin (the exact filename can be different depending on tools version)
Location: schemas\ibm-web-bnd_1_0.xsd in jar file C:\eclipse\plugins\com.ibm.jee.was.descriptors.schemas_1.1.100.v20141119_2034.jar.
For Websphere Application Server:
You can find all the schemas here...
WAS_INSTALL_ROOT/properties/schemas

Resource reference with name 'jdbc/devl' not found in ibm-web-bnd.xml

RAD 7, WebSphere 7.
ibm-web-bnd.xml:
<resource-ref name="jdbc/devl" binding-name="jdbc/devl" />
web.xml:
<resource-ref>
<res-ref-name>jdbc/devl</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
<mapped-name>jdbc/devl</mapped-name>
</resource-ref>
This conforms to the examples I see on the internet. This comes up because I am converting this app to servlet 2.5. As I understand it, the res-ref-name in web.xml should match the name attribute in resource-ref. The binding-name then matches the datasource defined in the admin console. To make it simple, I made them all match.
Is there another setting somewhere? Because this produces the error described in the title of the question.
I have the same issue many times. It disappeared when I closed the eclipse and when I reopened it I made a "project -> clean". I hope it works for the next person who has this error.
Also make sure you have the web.xml header updated to 2.5 or higher (3.0).This is related to the facets of the project, make sure they are with the same version
if it doesn't let you change it, you should change it in this file : "org.eclipse.wst.common.project.facet.core.xml"
If the error continues, you should generate the binding file again. Make sure you have the correct server settings in the facets of the project
To generate the file you must do it from java EE Tools.
Remember that ibm-web-bnd.xml and web.xml must be in the same directory
Build, and clean project.
If you are using Eclipse, try to update the web module version in project.facet.core.xml. It should be in synch with the web.xml web-app version.

How to validate beans.xml using a local XSD?

In my application, I have some beans.xml files (for eeach module). each of these files contains required XSD declarations :
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:weld="http://jboss.org/schema/weld/beans"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
Yesterday, due to some JBoss.org outage, schema files were unavailable, and as a consequence my beans.xml couldn't correctly validate.
It didn't prevent the project from validating, but slowed down project build (due to weld usage in tests, mainly).
So, what is a the solution, when using Weld 1.1.5 as CDI implementation, to not validate beans.xml during compilation, or to use a local XSD file (and if so, how to declare it, and where to put it in a maven project) ?
Just spoke with Pete Muir. He said its a bug. Would you mind creating a JIRA ticket please?

How do I resolve duplicate property errors in this j2ee schema?

I inherited a J2EE app written for deployment on Weblogic 10 and the developer primarily responsible for this application does not get this error when he opens the project in Eclipse.
I have the following very simple weblogic.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/920/weblogic-web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Eclipse generates a single XML validation problem for this file, which actually consists of a number of the same errors. The parent text of the XML problem is this:
The errors below were detected when validating the file "j2ee_1_4.xsd"
via the file "weblogic.xml". In most cases these errors can be
detected by validating "j2ee_1_4.xsd" directly. However it is
possible that errors will only occur when j2ee_1_4.xsd is validated in
the context of weblogic.xml.
And an example of the child errors. They all read this way:
sch-props.correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://java.sun.com/xml/ns/j2ee,descriptionGroup'.
This is followed by a line number. There are about 50 of these errors, and only the quoted name at the end of the error changes.
I found the following bug in Sun's bug tracker which seemed to indicate a possible cause, but I'm not sure how I'd apply it to my project, if it's even relevant.
Impossible to create javax.xml.validation.Schema instance from "web-app_2_4.xsd"
I can't help but think that this is related to my Eclipse configuration, but at this point I'm at a loss.
Thanks for your time.
I ran into the same issue. I found an article online about needing to update to the latest schema so I looked through Oracle for latest schemas versions here: http://www.oracle.com/webfolder/technetwork/weblogic/weblogic-web-app/index.html
I modified my weblogic.xml file with the following:
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
...
</weblogic-web-app>
Regards,
Jose
You say this is written for WL 10.
My weblogic.xml begins as
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app
http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
while I can see yours points to the Weblogic 9 namespace
xmlns="http://www.bea.com/ns/weblogic/90"
Does changing this make a difference?

Bogus Eclipse warning for web.xml: "No grammar constraints (DTD or XML schema) detected for the document."

The top of my web.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5">
But I still get the warning from Eclipse (Ganymede) that no XML schema is detected, and schema violations are not being warned about. Other XML files in my project (Spring Framework configuration files for example) don't have the warning and do give correct warnings about schema violations.
How do I get the schema checking working and hopefully the warning to go away? The server does run correctly. It just appears to be an IDE issue.
I hate that warning too. Specially because it appears in XML files that you haven't written but appear in your project for whatever reason (if you use MAVEN it's hell).
With Eclipse 3.5+ you can easily remove this validation rule. Go to Preferences-->XML-->XML FILES --> Validation and Select "ignore".
You may also have to do a Project -> Clean for the validation warnings to go away.
Perhaps try:
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
Instead of:
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
Also, the <!DOCTYPE ...> is missing:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- ... -->
</web-app>
Clear the cache for stored validation files.
Window > Preferences > General > Network Connections > Cache then remove all. Now go validate the file and see if that clears things up.
This happed to me and clearing the cache for the validation was the only way to get it functioning properly again. The advice for clearing dirty cache was found here.
If you have the same (missleading) error message because your XML Editor was not finding the XSD file, you can add a catalog entry.
You pick the URL specified for the schema, for a declaration like
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
The URL of the schema file (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd) is specified for the namespace http://java.sun.com/xml/ns/j2ee. You can now redirect the location of the file with the workspace catalog in Eclipse:
Preferences -> XML -> XML Catalog -> Add..
Use
Key Type = Schema Location
Key = http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
And then you can use the file chooser to pick actually a XSD file on the filesystem or the workspace.
The problem is two-fold:
Eclipse ships with a cache of a lot of well-known XSD's. The name space and/or location you provide does not match any of these.
So Eclipse tries to go looking for the XSD on the internet on the URI provided (may just work). Unfortunately it appears that after Oracle revised java.sun.com this mechanism just times out in Eclipse (apparently the server redirects to the homepage instead of simply saying "does not exist, sorry").
When you revise to the correct values for Java EE 5, the entry in the cache will be found and Eclipse will be happy.
Add this <!DOCTYPE ...> to your xml file. Please put it under <?xml ...>:
<!DOCTYPE ??? PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
??? = Your root element, now if your sub-element name is using a html reserved word you might be catching some errors, all you have to do is change them to a non-reserved word.
For example:
If your current sub-element is <img>, change it to <pic>...

Categories