How to set class path in weblogic 11g console for classes present in web-inf/classes/
And my classes are in the below structure which needs to be set as class path to avoid exception which needs these classes to be loaded first.
/com/cdy/ws/a.class files
/com/cdy/ws/b.class files
/com/cdy/ws/c.class files
Please help,
Thanks
If you are looking for WebLogic specific...
Lets say your web application dependent jars defined as:
WS_CLASSPATH=/com/cdy/ws
set in your environment variable.
That means your weblogic server can be loaded with weblogic.jar its relavent jars then, your WS_CLASSPATH can be added in the setDomainEnv.sh/cmc script find the EXT_PRE_CLASSPATH and assign to it.
EXT_PRE_CLASSPATH=$WS_CLASSPATH
There will be opposite side of CLASSPATH after the weblogic specific libraries available with EXT_POST_CLASSPATH in the setDomainEnv script.
The startup or shutdown class must be on the classpath of each server to which it is assigned.
To add a class to a server's classpath, do one of the following:
If you use a script to start a server instance, open the script in a text editor. In the command that sets the classpath, add the pathname of the directory that contains your class root package.
Then restart the server.
For example, you create a startup class named StartBrowser in a package named com.mycompany.startup. You archive the class file in a JAR file named c:\myDomain\src\myJAR.jar.
The start script for your server must add c:\myDomain\src\myJAR.jar to the server's classpath.
If you use the Node Manager to start a server instance, do the following on each server that runs the startup class or shutdown class:
In the left pane of the Console, expand Environment and select Servers.
On the Servers page, click on the server name.
Select Configuration > Remote Start.
In the Classpath field, enter the pathname for the classes that WebLogic Server requires to be on the classpath.
Use an absolute pathname or a pathname that is relative to the Node Manager's home directory.
Separate multiple classes with the type of separator that your operating system or shell requires.
For example, on Windows, use ; (semicolon) and in a BASH shell, use : (colon).
For example, weblogic.jar must be on the classpath. For a complete list, refer to Required Environment and Syntax for weblogic.Server.
In the Classpath field, add the pathname for your class or for a JAR file that contains your class.
For example, you create a startup class named StartBrowser in a package named com.mycompany.startup. You archive the class file in a JAR file named c:\myDomain\src\myJAR.jar. In this case, the Classpath field should contain the following value:
c:\Oracle\Middleware\wlserver_10.3\server\lib\weblogicsp.jar;c:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar;c\myDomain\src\myJAR.jar
step1)Class path can be set using ./setWLSEnv.sh(/wlserver_10.3/server/bin)
step2)Adding a jar file to class path abc.jar to this location(wlserver_10.3/server/lib) and follow step1
If in case you need to set Domain ./setWlEnv.sh(Domain_Home/bin) avil here
Related
I have a project with some config files. I need to externalize them to allow the user to edit them. It's a spring boot application and my files are in a yaml format.
It's not application.yaml, it's some custom files with different names.
I use bean annotations. For example, one of my beans looks like this :
#Configuration
#ConfigurationProperties
#PropertySource(value="globalConfiguration.yaml", factory = YamlPropertySourceFactory.class)
public class GlobalConfiguration {
//some fields
//accessors
}
When the file is in src/main/resources, it works well but once built it reads the file inside the jar (which is normal)
What I would like to do is to read in priority the yaml file from a config folder which is near the lib folder like this :
- bin
- config
globalConfiguration.yaml
- lib
myApp.jar
I tried using the parameter --spring.config.location="classpath:./config/" (and /./config and ././config and /config and config...) but nothing work I have this error :
***************************
APPLICATION FAILED TO START
***************************
Description:
Config data location 'classpath:/./config/' does not exist
Action:
Check that the value 'classpath:./config/' is correct, or prefix it with 'optional:'
EDIT :
Now I tried to add my config files to the classpath like this :
set CLASSPATH=%APP_HOME%\config\*;%APP_HOME%\lib\myJar.jar;someDepencies.jar
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %MYAPP_OPTS% -classpath "%CLASSPATH%" my.Main.Class %*
It's the bat generated by gradle when I build the project so I just added %APP_HOME%\config\*; to the classpath variable.
But it didn't change anything.
Finally it had nothing to do with the classpath. the spring.config.location works perfectly well but the directory used is the current one when launching the bat and my app was on a windows shared folder so I wasn't able to do a cd \mysharedfolder.. .
To make it works, there was two option :
To move the app in a local folder. Then move to the folder of the app and so the relative path works from there.
The second option is to set the complete path of the config folder like this :
--spring.config.location="\\\\mysharedfolder\\someSubDirectories\\config\\"
In spring boot application how do I give an external windows path using #Value Spring annotation and Resource
The below example works fine that look into resources folder but I want to give the path outside of application like c:\data\sample2.csv
#Value("classPath:/sample2.csv")
private Resource inputResource;
...
#Bean
public FlatFileItemReader<Employee> reader() {
FlatFileItemReader<Employee> itemReader = new FlatFileItemReader<Employee>();
itemReader.setLineMapper(lineMapper());
itemReader.setLinesToSkip(1);
itemReader.setResource(inputResource);
and if I want to get the value from properties file in annotaion, whats the format to put the path in windows?
i tried these, none of them worked:
in code
#Value("${inputfile}")
in properties file:
inputfile="C:\Users\termine\dev\sample2.csv"
inputfile="\\C:\\Users\\termine\\dev\\sample2.csv"
inputfile="C:/Users/termine/dev/sample2.csv"
inputfile="file:\\C:\Users\termine\dev\sample2.csv"
inputfile="file://C://Users//termine///dev//sample2.csv"
When you use classpath spring will try to search with the classpath even if you provide the outside file path.
so instead of using classpath: you can use file:
Ex.
#Value("file:/sample2.csv") //provide full file path if any
Use the key spring.config.location in properties to set the config location. Spring-boot will by default load properties from the locations, with precedence like below :
A /config subdir of the current directory.
The current directory
A classpath /config package
The classpath root
and apart from this when you start the jar or in application.properties you can provide the location of the config file like :
$ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
You can serve static files from the local disk, by making the resource(s) "sample2.csv" as a static resource. An easy way to do this is by adding spring.resources.static-locations configuration to your applicaiton.properties file. Example:
spring.resources.static-locations=file:///C:/Temp/whatever/path/sample2.csv",classpath:/static-files, classpath:/more-static-resource
When I did this in one of the projects, I was able to access the file form the browser using localhost:8080/sample2.csv.
I have around 10 applications and I am storing all the property files in one location on the file system. So suppose for example- All my property files are inside C:/Config.
Now what i want to do is have an application named folder structure. So lets say I have 3 applications named A,B and C. Then a folder structure like-
C:
-Config
-A
-env1(profile)
-A-env1.yaml
-env2
-A-env2.yml
-B
-env1
-B-env1.yml
-env2
-B-env2.yml
-C
-env1
-C-env1.yml
-env2
-C-env2.yml
Is this possible to achieve? I have gone through the documentation and have tried few things like adding the following in search Locations-
file:///C:/Config/${application}/${profile}
file://C:/Config/${label} (label tag which is there by default)
This doesn't work though.
Any help is much appreciated.
Thank you in advance.
You can load application properties from arbitrary file-system location.
By default Spring reads the following directories (taken from docs):
1)A /config subdirectory of the current directory
2)The current directory
3)A classpath /config package
4)The classpath root
You can also refer to an explicit location using the spring.config.location environment property (comma-separated list of directory locations, or file paths).
Example:
java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
I can't find an answer to this question on stackoverflow hence im asking here so I could get some ideas.
I have a Spring Boot application that I have deployed as a war package on Tomcat 8. I followed this guide Create a deployable war file which seems to work just fine.
However the issue I am currently having is being able to externalize the configuration so I can manage the configuration as puppet templates.
In the project what I have is,
src/main/resources
-- config/application.yml
-- config/application.dev.yml
-- config/application.prod.yml
-- logback-spring.yml
So how can I possibly load config/application.dev.yml and config/application.prod.yml externally and still keep config/application.yml ? (contains default properties including spring.application.name)
I have read that the configuration is load in this order,
A /config subdirectory of the current directory.
The current directory
A classpath /config package
The classpath root
Hence I tried to load the configuration files from /opt/apache-tomcat/lib to no avail.
What worked so far
Loading via export CATALINA_OPTS="-Dspring.config.location=/opt/apache-tomcat/lib/application.dev.yml"
however what I would like to know is,
Find out why loading via /opt/apache-tomcat/lib classpath doesn't work.
And is there a better method to achieve this ?
You are correct about load order. According to Spring boot documentation
SpringApplication will load properties from application.properties files in the following locations and add them to the Spring Environment:
A /config subdirectory of the current directory.
The current directory
A classpath /config package
The classpath root
The list is ordered by precedence (properties defined in locations higher in the list override those defined in lower locations).
[Note]
You can also use YAML ('.yml') files as an alternative to '.properties'.
This means that if you place your application.yml file to /opt/apache-tomcat/lib or /opt/apache-tomcat/lib/config it will get loaded.
Find out why loading via /opt/apache-tomcat/lib classpath doesn't work.
However, if you place application.dev.yml to that path, it will not be loaded because application.dev.yml is not filename Spring is looking for. If you want Spring to read that file as well, you need to give it as option
--spring.config.name=application.dev or -Dspring.config.name=application.dev.
But I do not suggest this method.
And is there a better method to achieve this ?
Yes. Use Spring profile-specific properties. You can rename your files from application.dev.yml to application-dev.yml, and give -Dspring.profiles.active=dev option. Spring will read both application-dev.yml and application.yml files, and profile specific configuration will overwrite default configuration.
I would suggest adding -Dspring.profiles.active=dev (or prod) to CATALINA_OPTS on each corresponding server/tomcat instance.
I have finally simplified solution for reading custom properties from external location i.e outside of the spring boot project. Please refer to below steps.
Note: This Solution created and executed windows.Few commands and folders naming convention may vary if you are deploying application on other operating system like Linux..etc.
1. Create a folder in suitable drive.
eg: D:/boot-ext-config
2. Create a .properties file in above created folder with relevant property key/values and name it as you wish.I created dev.properties for testing purpose.
eg :D:/boot-ext-config/dev.properties
sample values:
dev.hostname=www.example.com
3. Create a java class in your application as below
------------------------------------------------------
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
#PropertySource("classpath:dev.properties")
#ConfigurationProperties("dev")
public class ConfigProperties {
private String hostname;
//setters and getters
}
--------------------------------------------
4. Add #EnableConfigurationProperties(ConfigProperties.class) to SpringBootApplication as below
--------------------------------------------
#SpringBootApplication
#EnableConfigurationProperties(ConfigProperties.class)
public class RestClientApplication {
public static void main(String[] args) {
SpringApplication.run(RestClientApplication.class, args);
}
}
---------------------------------------------------------
5. In Controller classes we can inject the instance using #Autowired and fetch properties
#Autowired
private ConfigProperties configProperties;
and access properties using getter method
System.out.println("**********hostName******+configProperties.getHostName());
Build your spring boot maven project and run the below command to start application.
-> set SPRING_CONFIG_LOCATION=<path to your properties file>
->java -jar app-name.jar
Till now, I had been running ruta scripts from a maven project by creating AnalysisEngine and CAS, and processing the engine. To do this, I had placed all the scripts and descriptor files (Engine & TypeSystem) into scr/main/resources folder of the maven project.
Now I want to place the scripts and TypeSystem files in an external path and pass the path dynamically to my java code that runs the scripts. Is it possible to do it ? If so, how ?
I simply placed the files(script & descriptor) in an external path and passed the new path to instantiate the AnalysisEngine as below;
final AnalysisEngine engine = AnalysisEngineFactory.createEngine("home/admin/Desktop/TEST_ScriptFolder/com/textjuicer/ruta/date/Dazzle_ChapRef_UpdatedEngine");
Error
org.apache.uima.util.InvalidXMLException: An import could not be resolved. No file with name "home/admin/Desktop/TEST_ScriptFolder/com/textjuicer/ruta/date/Dazzle_ChapRef_UpdatedEngine.xml" was found in the class path or data path. (Descriptor: )
at org.apache.uima.resource.metadata.impl.Import_impl.findAbsoluteUrl(Import_impl.java:117)
at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription(AnalysisEngineFactory.java:869)
at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(AnalysisEngineFactory.java:107)
at com.textjuicer.ruta.date.ArtifactAnnotator.getAllAnnotations(ArtifactAnnotator.java:93)
at ApplyingStyle.XmiTransformer.parseXMI(XmiTransformer.java:33)
at ApplyingStyle.ApplyStyle.applyStyleOnDocx(ApplyStyle.java:76)
There are two layers:
The RutaEngine needs to find the scripts/resources/descriptors
UIMA needs to be able to resolve imports of descriptors
The resource lookup in Ruta has two stages, it searches for them in the absolute paths specified in the configuration parameters. If the resource is not found it searches for it in the classpath. So you need to set the configuration parameters: scripts are located in scriptPaths, descriptors are located in descriptorPaths and wordlists are located in resourcePaths. See the documentation for further information.
The problems with the imports in descriptors can be solved by either setting the datapath in the UIMA ResourceManager or by changing the import to "location" instead of "name". The datapath can be used as a replacement for the classpath. The Ruta descriptos use import by location if it specified int he ruta-maven-plugin.
DISCLAIMER: I am a developer of UIMA Ruta