I recently completed this tutorial: "http://static.springsource.org/docs/Spring-MVC-step-by-step/", but now I want it to work with Hibernate and annotations. I know I'm close but I've hit a roadblock and I can't figure it out. I've posted my code on the Spring forums here. I would greatly appreciate ANY help. Thanks
I'm trying to incorporate annotations and hibernate into it, but I've run into a problem and I can't figure it out. I keep getting errors of "No persistence unit with name 'product' found". ANY help would be greatly appreciated.
You need a META-INF/persistence.xml, with <persistence-unit name="product">. See here
(I usually put it in WEB-INF/classes/META-INF. As noted in the comments, with maven you can place it in src/main/resources/META-INF)
this is a example of file persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="poduct" transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>
create this file inside "src/main/resources/META-INF" if you use Maven project.
I run onto the same problem and had to manually edit the Web Deployment Assembly Configuration so as to instruct /META-INF/persistence.xml to be deployed under WEB-INF/classes/ (the red box in the attached img was manually edited)
i have the same problem. But when you use the ide(for example eclipse) and configure your server in the ide. When you asosiate the piece and restart the server always have the same error because detected the persistence unit is used, you need delete that part of the server and deploy to the oldway. Enter to the console and install the peace of you project and works!!
And the other is when you check the diagnostic in wls you need said who user is the owner of the jdbc, only select and check (for example, AdminServer) and save and check again!!
:D
Related
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
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.
I am trying to run the jbpm6 sample web application "rewards-basic" in my local. But it seems two datasources files are missing.
<persistence-unit name="org.jbpm.examples.rewards-basic" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<mapping-file>META-INF/**JBPMorm.xml**</mapping-file>
<mapping-file>META-INF/**Taskorm.xml**</mapping-file>
What for JBPMorm.xml and Taskorm.xml files ? How to recreate these files here ?
Thanks,
those files are in jbpm-human-task-jpa -> https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-jpa/src/main/resources/META-INF/Taskorm.xml
and
in jbpm-persistence-jpa:
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/main/resources/META-INF/JBPMorm.xml
Notice that both files are in the main/src/resources directory so they should be included if you have jbpm-persistence-jpa.jar and jbpm-human-task-jpa in your class path.
HTH
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?
An application that has been working well for months has stopped picking up the JPA #Entity annotations that have been a part of it for months. As my integration tests run I see dozens of "org.hibernate.MappingException: Unknown entity: com.whatever.OrderSystem" type errors.
It isn't clear to me what's gone wrong here.
I have no hibernate.cfg.xml file because I'm using the Hibernate Entity Manager. Since I'm exclusively using annotations, there are no .hbm.xml files for my entities. My persistence.xml file is minimal, and lives in META-INF as it is supposed to.
I'm obviously missing something but can't put my finger on it.
I'm using hibernate-annotations 3.2.1, hibernate-entitymanager 3.2.1, persistence-api 1.0 and hibernate 3.2.1. hibernate-commons-annotations is also a part of the project's POM but I don't know if that's relevant.
Is there a web.xml entry that has vanished, or a Spring configuration entry that has accidentally been deleted?
verify in your entity classe that you import javax.persistent.Entity and not org.hibernate.annotations.Entity
I seem to recall I had a similar issue at one time.
Its a long shot, but if you're not already doing this, have you explicitly specified the provider you are using?
<persistence ...>
<persistence-unit ...>
<provider>org.hibernate.ejb.HibernatePersistence</provider> <---- explicit setting
....
</persistence-unit>
</persistence>
Otherwise, I'm not sure?
Is this happening for one specific class (few classes) or all the entity classes. The persistence.xml file has a list of class and or jar files that need to be scanned for #Entity mappings. If it was working earlier you can do a quick diff with the version of persistence.xml that was working correctly. Another issue could be that it is picking up a different persistence.xml file - you can verify this by introducing an error (for e.g., make the xml invalid) in the persistence.xml.