Database schema is not generated in a EAR Application - java

I have this scenario in a EAR application which have the following structure:
Project
data
ear
entity
META-INF
persistence.xml
business
web
At the entity folder there is all the entity classes and a persistence.xml with the hibernate.hbm2ddl.auto property setted to create. When I deploy the jar about entity the database is generated but when I deploy the ear he isn't. Please somebody can let me know why this is happening and some way to solve it?

In your EAR project you must have a META-INF/application.xml file, that includes the entity jar file:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>MY_ear</display-name>
<module>
<ejb>ENTITY.jar</ejb><!--change the name accordingly-->
</module>
</application>

Related

How to change context-root for enterprise application (.ear) in weblogic

We have third party web based enterprise application, which is deployed on weblogic server and can be accessible using
http://hostname:port/myApp
But, due to some reason, we wanted to change context-root for this application, so that it must be ONLY accessible using
http://hostname:port/newApp
So, to achieve this, we tried changing application.xml
<?xml version = '1.0' encoding = 'utf-8'?>
<application 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/application_1_4.xsd" version="1.4">
<display-name>myApp</display-name>
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>newApp</context-root> // changed from myApp to newApp
</web>
</module>
</application>
But, while deploying this application on weblogic server, we are getting following error.
weblogic.management.DeploymentException: The application myApp contains a SubDeploymentMBean with a name myApp however there is no module in the application with that URI or context-root.
On the other hand, if we keep both context-root as shown below application.xml file, then it gets deployed successfully and also able to access application using both context-root.
<?xml version = '1.0' encoding = 'utf-8'?>
<application 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/application_1_4.xsd" version="1.4">
<display-name>myApp</display-name>
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>newApp</context-root> // changed from myApp to newApp
</web>
</module>
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>myApp</context-root>
</web>
</module>
</application>
Can anyone help me to resolve this issue ? Let me know, if additional information required.
==Edited==
I have added weblogic.xml file, but not sure, what I suppose to change in this file as pointed by #Hououin Kyouma in his/her answer.
<?xml version = '1.0' encoding = 'US-ASCII'?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<session-descriptor>
<cookie-path>/myApp</cookie-path>
</session-descriptor>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
You cannot define a context root with a differently named war file in the application.xml
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>newApp</context-root> // changed from myApp to newApp
</web>
</module>
You must change above to
<module>
<web>
<web-uri>newApp.war</web-uri> // changed from myApp to newApp
<context-root>newApp</context-root>
</web>
</module>
You need to create the war with the new name. You will still need to change the weblogic.xml in the new war file, but as long as this question goes, above is what you need to do.
Have you tried setting the context root in the weblogic.xml?
https://docs.oracle.com/cd/E13222_01/wls/docs90/webapp/weblogic_xml.html#1073750
EDIT
Trying adding it like mentioned in this
https://community.oracle.com/thread/747158
<?xml version = '1.0' encoding = 'US-ASCII'?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<context-root>/newApp</context-root>
<session-descriptor>
<cookie-path>/newApp</cookie-path>
</session-descriptor>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

How to deploy war file in root(/) context to Wildfly ver 8.1.0.Final and remove welcome-content

I'm trying to put my application on the root context to wildfly.
I put this files jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
and the empty file bean.xml at WEB-INF/
The welcome-content is still working at localhost:8080
If you put localhost:8080/index.xhtml my application appears.
I tried renaming the direcctory welcome-content but no works.
SOLVED: REFRESH CACHE OF THE BROWSER

read html file from JSF project root folder

I dont know how to explain it but let me try :
I have a eclipse JSF project named web-gestao
I would like to call from URL : http://www.domainxxx/simplefile.html and NOT http://www.domainxxx/web-gestao/simplefile.html
I need this for google verification purposes.
In jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<!-- URL to access the web module -->
<context-root>/</context-root>
...
...
...

Webservices in weblogic9.2

I have written an Webservice using jax-ws (with Eclipse IDE) and have bundled it in War, in turn bundled within an Ear. I'm able to deploy that fine and testing of the web services also works fine. But when I login to my Weblogic Admin console and expand the Ear deployment, I don't see anything under 'Web services', it displays None to display.
Could any one please let me know what is that am missing here?
this is the application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="1.4" 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/application_1_4.xsd">
<display-name>EAR1</display-name>
<module id="WebModule_1376158300960">
<web>
<web-uri>TestWEB.war</web-uri>
<context-root>TestWEB</context-root>
</web>
</module>
</application>

issues deploying a JAVA application to weblogic 11g

I have a simple JSP/Servlets application. The app is already deployed to the server and is running at say URL http://www.servername:7001/myapp1/jsp/login.jsp. I have made some substantial changes to the code and I redeployed it as myapp2 in the server. However if I try to access it at this URL,,say http://www.servername:7001/myapp2/jsp/login.jsp, this gives me a "resource not found error". Is the URL mapped to the application somewhere? What do I need to do to access the newly deployed project. I do not want to remove the old project till I am sure the new one works properly
You probably need to specify a context root. There are a couple of places this might appear.
1) Inside your EAR file in META-INF/application.xml, e.g.:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
id="Application_ID" version="5">
<display-name>myapp2</display-name>
<module>
<web>
<web-uri>myapp2.war</web-uri>
<context-root>/myapp2</context-root>
</web>
</module>
</application>
2) In the WAR file, in WEB-INF/weblogic.xml, e.g.:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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 http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.2</wls:weblogic-version>
<wls:context-root>myapp2</wls:context-root>
</wls:weblogic-web-app>

Categories

Resources