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

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?

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

appengine-web.xml does not contain a <threadsafe> element

Working on an app engine java application I am getting the error in the subject.
I have looked at similar questions that say that a
<threadsafe>true</threadsafe>
element should be added to appengine-web.xml, but my appengine-web.xml file is auto generted based on app.yaml and the instructions here do not provide any help...
I think it might be acheived using the instructions re "Custom XML Output" in that same page but they seem to be missing the part on how to actually do it...
The 'threadsafe' option would need to be appear in a place similar to the 'sessions-enabled' option. I suggest trying the following additional line in app.yaml after the 'runtime' line:
threadsafe: true
It's not documented, as you said, but 'sessions_enabled' corresponds to 'sessions-enabled', so it might work. ("feature!" ;-)
A minimal sample appengine-web.xml file looks like this as found here:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>_your_app_id_</application>
<version>1</version>
<threadsafe>true</threadsafe>
</appengine-web-app>

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?

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>...

Problems Deploy Webservices in oracle Weblogic 10.01

i am using jwsc to build my webservices application. This produces a war file with a weblogic.xml like the following:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/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">
<context-root>eori-ws</context-root>
</weblogic-web-app>
As you can see the namespace points towards bea.com. When i try to deploy the war (inside an ear) to my weblogic i get the following:
An error occurred during activation of changes, please see the log for details.
[HTTP:101064][WebAppModule(eori_services:eori-ws)] Error parsing descriptor in Web appplication
"/softs/apps/bea1001/user_projects/domains/myapp/servers/myServer/tmp/_WL_user/myapp/jd3urj/myapp-ws.war"
weblogic.application.ModuleException: Unmarshaller failed at
weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:858) at
weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:285)
(snip)
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200) at
weblogic.work.ExecuteThread.run(ExecuteThread.java:172) Caused by:
com.bea.xml.XmlException: failed to load java type corresponding to e=weblogic-web-app#http://www.bea.com/ns/weblogic/weblogic-web-app at
com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:329)
at
com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:296)
at
(snip)
weblogic.servlet.internal.WebAppDescriptor.getWeblogicWebAppBean(WebAppDescriptor.java:164)
at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:853)
... 25 more weblogic.application.ModuleException: Unmarshaller failed
Failed to load java type corresponding to e=weblogic-web-app#http://www.bea.com/ns/weblogic/weblogic-web-app
i've tried changing the url to match the new domain and i get the same error. I've tried downloading the xsd and putting it in the same folder of the weblogic.xml, wich i changed to look like:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="weblogic-web-app.xsd">
<context-root>eori-ws</context-root>
</weblogic-web-app>
and the error is still the same
I'm out of ideas. Any help?
EDIT: no solution yet, ill post solution when i find it.
I solved my problem. Seems i was using the wrong version of the JWSC ant task. Just make sure to use the correct weblogic.jar

Categories