I am currently working on a weblogic 10 application server that has several installed ears. I got a request to change the application name of some aps as they appear in
Home >Summary of Deployments
I went to the appropiate Plan.xml and changed the with the appropriate name, restarted the domain but the name did not change.
Any ideas?
You can do that easily by modifying config.xml file in
DOMAIN_NAME/config
You can just modify the name and restart the server.
<app-deployment>
<name>jms-rename</name>
<target>DefaultServer</target>
<module-type>ear</module-type>
<source-path>C:\JMSTest\application\jms\target\jms-0.0.1-SNAPSHOT.ear</source-path>
<security-dd-model>DDOnly</security-dd-model>
</app-deployment>
The answer was very simple in the end. I added inside the EAR's manifest file the following entry
Weblogic-Application-Version: x.y.z
In this way I didn't have to mess up with any of the Weblogics configuration files.
Related
I know this question has answered many a time with most useful answer as below,
Where to place and how to read configuration resource files in servlet based application?
However, We have some special requirement as below,
Webapp will be deployed to tomcat.
Normal java app in form of .jar will be placed under folder /myapp
myappConfig.property file will be placed under /myapp
Directory Structure on client machine
/myapp
/myapp.jar
/assests/myappConfig.property
/tomcat/webapps/myapp.war
Basically myapp.jar and myapp.war will access sql db connection values for MySql database connection and db operations.
Accessing myappConfig.property from myapp.jar --> Working fine
File jarPath = new File(Myapp.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String propertiesPath = jarPath.getParent();
System.out.println(" propertiesPath-" + propertiesPath);
mainProperties.load(new FileInputStream(propertiesPath + "\\assets\\myapp.property"));
Can anyone help/suggest how to implement,
Accessing myappConfig.property file from mywebapp,
provided run time change in myappConfig.property file does not required myapp.war to be redeployed
Thanks for your help in advance.
edit
Below is the steps in which we want to deliver the project to client.
Below is my app directory
/myapp
/myapp.jar
/assests/myappConfig.property
/tomcat/webapps/myapp.war
pack everything in one package with some packaging tool.
Run this package in client machine at any location and it will have same directory structure as above
Here, I do not want to hard code any location in webapp or tomcat for "/assests/myappConfig.property"
Normal Java app I can read property file but for wepapp I am not getting clear idea for how to do that?
You can add a <context> to tomcat/conf/server.xml (in this example, linux path):
<Context docBase="/home/yourusername/tomcat/assests" path="/assets" />
If you are using Windows:
<Context docBase="C:\path\to\myapp\assets" path="/assets" />
And then you can access it like any other resource within your webapp (e.g.: /assets/myappConfig.property).
If you are using JDBC for example, you could store the connection properties in a Singleton and request it from there, and that class could take care of change checks on that file.
In my Spring Boot app i need to call to:
System.setProperty("java.security.auth.login.config", authConf);
where authConf seems to be expected as an absolute path to the file.
the problem is, my Spring Boot app is packaged and executed as a jar and i want to package the file inside the jar.
The answer provided in this question might work only when a WAR is deployed in a server. It doesn't seem to work when we run JARs with embedded container.
is there way i could set a relative path to java.security.auth.login.config to refer to my conf file packaged within my jar ?
I know that the answer is about 6 years too late, but I recently faced the same issue and found and answer. Maybe my answer will at least help the next dev who will face this issue. I was able to solve it is by first creating a javax.security.auth.login.Configuration of type JavaLoginConfig and then use the Configuration.setConfiguration(configuration method) of the same Configuration class. Using this method I was able to bundle our jaas.conf inside the jar and use a relative path to it.
To give a concrete example:
Get the URL of the security configuration file you want to use
URL configLocation=YourClass.getClassLoader().getResource("resources/jaas.conf);"
Create the JavaLoginConfig configuration
Configuration secConfig=Configuration.getInstance("JavaLoginConf", new URIParameter(configLocation.toURI());
Set the configuration to the one you created in step 2
Configuration.setConfiguration(secConfig);
I have a Jersey based Rest service running on a tomcat server. There is no UI, just a server that offers some rest services. Now, to access this service the URL that i have to type in is pretty long. Something like localhost:8080/MyApp/url_pattern/classPath/method where MyApp is the webapp that i deployed, url_pattern is the pattern that i defined in the servlet-mapping in web.xml, classPath and method being the #Path annotations for the Class and method respectively. Is it possible to shorten it such that I get rid of the MyApp and url_pattern part of this URL. Something like localhost:8080/classPath/method.
PS: There is just one webApp running on this server, so no point having the MyApp part
I don't think you can remove all what you desire from the url but you can definitely remove the MyApp part by making it the root application for tomcat.
Answer on this related link describes it pretty well, how to set your application as the root application. So you can access your REST services without having the app name in url:
Setting default application in tomcat 7
Content copied from the above link:
First Method:
first shutdown your tomcat [from the bin directory (sh shutdown.sh)]
then you must delete all the content of your tomcat webapps folder (rm
-fr *) then rename your WAR file to ROOT.war finally start your tomcat [from the bin directory (sh startup.sh)]
Second Method:
leave your war file in CATALINA_BASE/webapps, under its original name
- turn off autoDeploy and deployOnStartup in your Host element in the server.xml file. explicitly define all application Contexts in
server.xml, specifying both path and docBase. You must do this,
because you have disabled all the Tomcat auto-deploy mechanisms, and
Tomcat will not deploy your applications anymore unless it finds their
Context in the server.xml.
Note:
that this last method also implies that in order to make any change to
any application, you will have to stop and restart Tomcat.
Third Method:
Place your war file outside of CATALINA_BASE/webapps (it must be
outside to prevent double deployment). - Place a context file named
ROOT.xml in CATALINA_BASE/conf//. The single element in this context
file MUST have a docBase attribute pointing to the location of your
war file. The path element should not be set - it is derived from the
name of the .xml file, in this case ROOT.xml. See the Context
Container above for details.
I have developed a java web application integrating with SAP. I have developed it with Linux Server and Tomcat 7.0. I have added sapjco3.jar and libsapjco3.so in WEB-INF/lib folder. It is working fine local server. But when deploying WAR file in remote server the following error is generating.
java.lang.NoClassDefFoundError: com.sap.conn.rfc.driver.CpicDriver
at com.sap.conn.rfc.engine.DefaultRfcRuntime.createChannel(DefaultRfcRuntime.java:52)
at com.sap.conn.rfc.engine.RfcIoOpenCntl.open_channel(RfcIoOpenCntl.java:1260)
at com.sap.conn.rfc.engine.RfcIoControl.ab_rfcopen(RfcIoControl.java:85)
at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:83)
at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect(MiddlewareJavaRfc.java:1107)
at com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:659)
at com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:103)
at com.sap.conn.jco.rt.ConnectionManager.createFactory(ConnectionManager.java:171)
at com.sap.conn.jco.rt.DefaultConnectionManager.createFactory(DefaultConnectionManager.java:44)
at com.sap.conn.jco.rt.ConnectionManager.getFactory(ConnectionManager.java:160)
at com.sap.conn.jco.rt.RfcDestination.initialize(RfcDestination.java:754)
at com.sap.conn.jco.rt.RfcDestination.ping(RfcDestination.java:964)
at com.my.ciry.sap.Connection.<init>(Connection.java:63)
The error is arising when ping the destination from Tomcat Server.
private JCoDestination dest;
public Connection(SapSystem system) {
dest = JCoDestinationManager.getDestination(SAP_SERVER);
dest.ping();
}
What's the cause of the problem.
SAP Servers are generally configured based on
System ID , the Message Server and possible a Group Server along with an Instance Number.
You probably need to pass these parameters when instantiating your connection. It could be that on localhost, these are not needed/ignorable, but on production, it is required.
Try connecting to the server using SAP's tools and try to provide all the settings that you would otherwise provide.
If you post what settings you are using for your JCO, perhaps I can help more.
Ideally, you should keep libsapjco3.so file outside your web application. Place it in any arbitary location and add that folder path to LD_LIBRARY_PATH environment variable. sapjco.jar can be in your classpath.
If the tomcat cannot load the .so file using the environment variable, you can try using System.setProperty("java.library.path", "folder_path_of_.so_file");
OR try to supply this variable by editing tomcat configuration files.
Finally, ensure that folder_path_of_.so_file has needed privileges for tomcat user.
This will solve your problem.
......
I have been working on a Java web application using wicket framework on Netbeans 7.2 and out of a sudden I encountered this problem. I tried cleaning the build-impl.xml then restarting the IDE and I should say I have fairly low knowledge on this. Can someone please tell me why it is giving an error and how I can fix that?
The lines 1024, 1025 and 1026 are :
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
The error message says :
nbproject/build-impl.xml:1025: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 4 seconds)
I came up with a solution by myself, I cloned the project and changed the project's directory name back to original, that worked fine for me. But it seems to have a better and proper solution, though.
/* START BY RESTARTING YOUR GLASSFISH SERVER */
1-add DBMS(ex:oracle,MySQL,MsSQL..) jdbc connector jar to domain
"glassfish directory/domain/{yourDomain}/lib"
2-add connection pool in glassfish server "JDBC-->ConnectionPool"
3-add your JNDI "JDBC-->jdbc ressource"
4-Test connection
5-add additional properties
IF YOU HAVE NO PASSWORD ON YOUR DATABASE ACCOUNT YOU CAN EASILY
6- glassfish/config/domain.xml change password value to "" in your jdbc-connection-pool
may its so late but the response useful for others so : Sometimes, when you don't specify a server or servlet container at the creation of the project, NetBeans fails to create a context.xml file.
In your project under Web Pages, create a folder called META-INF.
Do this by right mouse button clicking on Web pages, and select:
New->Other->Other->File Folder
Name the folder META-INF. Case is important, even on Windows.
Create a file called context.xml in the META-INF folder.
Do this by right mouse button clicking on the new META-INF folder, and select:
New->Other->XML->XML Document
Name it context (NetBeans adds the .xml) Select Well-formed Document Press Finish
Edit the new document (context.xml), and add the following:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/app-name"/>
Replace app-name with the name of your application.
Now your in-place deployment should work. If not, make sure that the file can be read by everyone.
The context.xml file is specific to Tomcat. For more information about that file, see the Tomcat documentation at tomcat.apache.org.