I am having some trouble trying to adjust the deployment settings of our application in weblogic. I feel what I'm trying to do ought to be quite simple, but it's not working as expected.
I am just trying to override the context-root in weblogic.xml and the JNDI name for the data source, so these can both be configured at deployment time.
I have removed the application.xml from the ear file, so that shouldn't be affecting the overrides.
What I have so far:
weblogic.xml:
<context-root>mosaic</context-root>
<resource-description>
<res-ref-name>jdbc/LogicalDS</res-ref-name>
<jndi-name>LogicalDS</jndi-name>
</resource-description>
web.xml
<resource-ref>
<description>A logical reference to the datasource - mapped in deployment plan</description>
<res-ref-name>jdbc/LogicalDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
plan.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:deployment-plan xmlns:wls="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd" global-variables="true">
<!--weblogic-version:10.3.5-->
<wls:application-name>mosaic.ear</wls:application-name>
<wls:variable-definition>
<wls:variable>
<wls:name>datasource_name</wls:name>
<wls:value xsi:nil="true"></wls:value>
<wls:description>The name of the datasource to map to the mosaic application</wls:description>
</wls:variable>
<wls:variable>
<wls:name>new_context_root</wls:name>
<wls:value xsi:nil="true"></wls:value>
<wls:description>URL to deploy Mosaic at</wls:description>
</wls:variable>
</wls:variable-definition>
<wls:module-override>
<wls:module-name>mosaic.war</wls:module-name>
<wls:module-type>war</wls:module-type>
<wls:module-descriptor>
<wls:root-element>weblogic-web-app</wls:root-element>
<wls:uri>WEB-INF/weblogic.xml</wls:uri>
<wls:variable-assignment>
<wls:name>new_context_root</wls:name>
<wls:xpath>/weblogic-web-app/context-root</wls:xpath>
<wls:operation>replace</wls:operation>
</wls:variable-assignment>
<wls:variable-assignment>
<wls:description>Data source for mosaic application</wls:description>
<wls:name>datasource_name</wls:name>
<wls:xpath>/weblogic-web-app/resource-env-description/resource-env-ref-name</wls:xpath>
<wls:operation>replace</wls:operation>
</wls:variable-assignment>
<wls:variable-assignment>
<wls:name>datasource_name</wls:name>
<wls:xpath>/weblogic-web-app/resource-description/[res-ref-name="jdbc/LogicalDS"]/jndi-name</wls:xpath>
<wls:operation>replace</wls:operation>
</wls:variable-assignment>
</wls:module-descriptor>
</wls:module-override>
</wls:deployment-plan>
Nothing happens when I use the deployment plan, and none of the variables appear under the Deployment Plan configuration screens in the admin console. From what I understand, I should at least be asked for these variables, since I have specified that they are null in the deployment plan.
When I use WLST to browse the tree, I find that the runtime configuration just stays as the values in the deployment descriptors.
I have verified the deployment plan is being used in the general tab of the admin console.
Can anyone help me find out what I am doing wrong here ?
I see that you have "datasource_name" variable replacement twice. Is that intended? Your xpath appears to be incorrect:
resource-description/[res-ref-name=
etc.
Should it be:
resource-description[res-ref-name=
etc.
My suggestion is to change one thing at at time, for example, the web app context first, and test. The web app context can be also set in the admin console, so you should see the value there.
There are few good articles about deployment plan:
https://blogs.oracle.com/jamesbayer/entry/11gr1_update_and_a_deployment
http://m-button.blogspot.com/2008/08/how-to-use-deployment-plan.html
A good resource mapping doc:
http://docs.oracle.com/cd/E15523_01/web.1111/e13737/packagedjdbc.htm
(look for the diagram near the bottom).
Is your variable a "replace" or "define"?
Related
I'm trying to implement a simple login using Spring Security (I'm a newbie in Spring Security). I've started with Spring Security reference that contains a simple "Hello world" example (link). I've prepared a web project in Eclipse (with EAR project), file structure looks like this:
SecurityConfig and SecurityWebApplicationInitializer classes are identical to those in a link above ("Hello world" example). I've also added Log4j 2 configuration file and home page (login.xhtml) that (for now) just prints "test". Later it will be used as a custom login page.
web.xml contains only a welcome-file element:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SpringSecurity</display-name>
<welcome-file-list>
<welcome-file>pages/login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
EAR's deployment assembly looks like this:
When I deploy my EAR on a JBoss AS 7.1.1, there's no error, but when I access http://localhost:8080/SpringSecurity, my home page is displayed normally.
I'm guessing that the configuration above should generate a default login page. When I access my home page, that login page should appear, right? It looks like that Spring Security is not even loaded and there's no protection when accesing my home page.
I don't really understand why is this simple example not working. Any help?
I do not have JBoss on my machine currently. But I was able to deploy this example on tomcat.
The issue certainly is that the war classloader is not able to see the spring jars at runtime.
There can be two possible solutions to resolve this.
If the spring jars are only required by war module (not by any other module in the ear), then you can shift these spring jars from ear's lib directory to war's WEB-INF/lib directory.
If the spring jars are also required by the other modules than you can to explicitly set the Class-Path entry in the MANIFEST.MF file of the war and the other modules that require these jars in a portable way.
e.g.
Manifest-Version: 1.0
Class-Path: lib/spring-beans-4.3.9.RELEASE.jar lib/spring-context-4.3.9.RELEASE.jar
Add all the required jars in this way separated by sapce (' ').
Note:- I used following jars to make this example run.
spring-aop-5.0.2.RELEASE.jar
spring-beans-5.0.2.RELEASE.jar
spring-context-5.0.2.RELEASE.jar
spring-core-5.0.2.RELEASE.jar
spring-expression-5.0.2.RELEASE.jar
spring-jcl-5.0.2.RELEASE.jar
spring-security-config-5.0.0.RELEASE.jar
spring-security-core-5.0.0.RELEASE.jar
spring-security-crypto-5.0.0.RELEASE.jar
spring-security-web-5.0.0.RELEASE.jar
spring-web-5.0.2.RELEASE.jar
And with this version of spring and spring-security you may have to make a small change in your code.
User.withDefaultPasswordEncoder().username("user").password("user").roles("USER").build();
or
User.withUsername("user").password("{noop}user").roles("USER").build();
Refer - Spring Boot PasswordEncoder Error for more details about the code change required.
I am migrating my RESTful web application from GlassFish4.1 to WildFly9.0 for the first time.
Initially, I suffered deployment issues due Jersey dependencies. To overcome that problem, I simply replaced said project dependencies with RESTEasy equivalents inside of the pom.xml file. In doing so, my application became deployable -- and according to (WildFly_base)/standalone/log, and the applications themselves -- are working as expected.
Additionally, I added a jboss-web.xml configuration file to my WEB-INF folder:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "http://www.jboss.org/j2ee/dtd" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<context-root>myprojectstart</context-root>
</jboss-web>
The hello-world page can be reached # http://ipaddress:8080/myprojectstart.
... however, I cannot view my web services # http://ipaddress:8080/myprojectstart/getData, just like I could when using GlassFish-4.1.
So; what am I missing?
Note: I use #annotations like:
#ApplicationPath("/*")
#Path("/getData")
No seperate .xml business here
I don't think RestEasy supports * in ApplicationPath. If you remove that it should work fine.
Deployment to the Jetty server is very slow (around 45 seconds), which is tough for development, so I'm looking for advice on how to speed it up.
I'm using Maven with the Jetty plugin (jetty-maven-plugin), and the jetty:run goal on a vaadin project created from the archetype com.vaadin:vaadin-archetype-application.
I found reference here: wiki.eclipse.org/Jetty/Howto/Avoid_slow_deployment, and it makes sense that this is the problem, because there are many jar files to be scanned (from vaadin framework), but I cannot figure out where to put the xml file, what to name it, and how to get the maven jetty:run goal to use it (and I have tried lots of variations that I could think of!)
Any help is appreciated!
You can configure an individual context in the plugin either by adding attributes/parameters in the web.xml (for some limited things) or using a context xml file that applies to the context, which you need to specify with the contextXml element of the plugin configuration.
See https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#configuring-your-webapp
P.S. Jetty 9 is a little faster in scanning etc.
Gregw pointed me in the right direction. Here is the complete detail of how I ended up resolving this:
1) I added a file named jetty-web.xml in my src/main/webapp/WEB-INF folder. It contained:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>nothing.jar</Arg>
</Call>
</Configure>
Note at this point I don't have any jars the need scanning, so I just put in a dummy entry of "nothing.jar" as the pattern to match.
2) Edit the jetty-maven-plugin's entry in pom.xml: in the section, I added
<contextXml>${basedir}/src/main/webapp/WEB-INF/jetty-web.xml</contextXml>
Now redeploys happen in just a couple seconds.
We are new to Weblogic (12c). We try to choose how we're going to pass some configurations to the application depending on the environment it is running on (dev / staging /prod).
I'm currently trying to use a deployment plan. In WEB-INF/web.xml, I have :
<context-param>
<param-name>test</param-name>
<param-value>11111</param-value>
</context-param>
And I use a plan.xml for my application in Weblogic.
Some parts :
<variable-definition>
<variable>
<name>test</name>
<value xsi:nil="false">22222</value>
<description>some description</description>
</variable>
</variable-definition>
and
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
<variable-assignment>
<name>test</name>
<xpath>/web-app/context-param/[param-name="test"]/param-value</xpath>
<origin>planbased</origin>
<operation>replace</operation>
</variable-assignment>
</module-descriptor>
This works!
But I heard it could be possible to change the value of the variable from the administration console, is that true?
When I browse my application in the console (in the Deployment Plan tab or in the Configuration tab), I do not see any field which I could use to change the test variable... Am I missing something or must the values of overriding variables be set in the plan.xml file itself?
I do not think you can change the variable directly, I believe this is because it's a fundamental change to the deploy that requires a "hot update" BUT you can easily "redeploy/update" with a new plan. This is how you would do it in a production environment:
From the Weblogic admin console, click Deployments, click the checkbox next to your ear/war
Click Update
The next screen will ask you for the source path and the deployment plan path, you can change just the deployment plan path to set your new value(s)
You can also call java weblogic.Deployer with the update option if you want to do it from the command line.
It is also possible to do the same via WLST scripting - see these Oracle Docs
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.