Error running Spring Batch Admin on Tomcat 6/7 - spring

I am getting this error when running a Spring Batch Admin template project created via STS 3.2 on vanilla Tomcat 6/7 on RedHat Linux:
Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [batch-L.properties] cannot be opened because it does not exist
I have no idea where that file is coming from. I tried searching for the file but to no success. Also, I need to add, that when running the same *war file on my local machine, everything works fine.
I will be grateful for any help.

Spring Batch Admin uses a system variable ENVIRONMENT to determine what properties file to load. By default, (if the variable isn't set), it will look for an HSQLDB version named batch-hsqldb.properties. In your case, it looks like the ENVIRONMENT variable is being set to the letter L.

Related

The VMargument values not properly read by log4j2.properties

Spring web application with log4j2 implemented in tomcat 8 running in windows and linux servers.
In windows server
CATALINA_OPTS specified in setenv.bat file
set "CATALINA_OPTS=-DLOG_FOLDER=D:\apache-tomcat-9.0.22\customlog"
log4j2.properties file is inside WEB-INF\classes\config\
appender.rolling.fileName=${sys:LOG_FOLDER}\logger.log
appender.rolling.filePattern=${sys:LOG_FOLDER}\logging-%d{MM-dd-yyyy}-%i.log.gz
In linux server
CATALINA_OPTS specified in setenv.sh file
set "CATALINA_OPTS=-DLOG_FOLDER=/opt/tomcat01/customlog"
log4j2.properties file is inside WEB-INF\classes\config\
appender.rolling.fileName=${env:LOG_FOLDER}/logger.log
appender.rolling.filePattern=${env:LOG_FOLDER}/logging-%d{MM-dd-yyyy}-%i.log.gz
log folder is always created like '${env:LOG_FOLDER}' or '${sys:LOG_FOLDER}'
You should use ${sys:LOG_FOLDER} in both cases:
${sys:property_name} retrieves the Java system property of that name,
${env:variable_name} retrieves the OS environment variable of that name.
See Log4j 2 Lookups for more details.
There are also other problems in your configuration:
if you start Tomcat on Windows as a service, setenv.bat is not used. You should add -DLOG_FOLDER=D:\apache-tomcat-9.0.22\customlog to the Java tab of the Tomcat Monitor application (bin\tomcat<version>w.exe).
on Linux you are using the wrong syntax to modify an environment variable (Microsoft's syntax), use:
export CATALINA_OPTS="-DLOG_FOLDER=/opt/tomcat01/customlog"
instead.
Remark: If you want to use environment variables instead of system properties, you can use:
export LOG_FOLDER="/opt/tomcat01/customlog"
on Linux, while on Windows you need to run:
tomcat10.exe //US ++Environment="LOG_FOLDER=D:\apache-tomcat-9.0.22\customlog"
See Procrun documentation for more details.

The Server Instance cannot be started because the Integrated Weblogic domain was not built successfully.-jdeveloper

I am having jdeveloper 11.1.1.6.
I created domain named "jdev_domain" successfully.
I created simple application in jdeveloper and deploy it using integratedweblogicserver.The deployment finished successfully. But while I am running that application it throws following error:
The Server Instance cannot be started because the Integrated Weblogic domain was not built successfully.
The extensions log is:
Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\com.ibm.ws.admin.client_7.0.0.jar
not found. Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\com.ibm.ws.ejb.thinclient_7.0.0.jar
not found. Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\com.ibm.ws.jpa.thinclient_7.0.0.jar
not found. Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\com.ibm.ws.orb_7.0.0.jar not
found. Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\ejb3exceptions.jar not found.
Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\ibmorb.jar not found. Warning:
Classpath entry
C:\Oracle\Middleware\jdeveloper\was\oracle.webservices.standalone.client.jar
not found. Warning: Classpath entry
C:\Oracle\Middleware\jdeveloper\was\tools.jar not found. Warning:
Classpath entry
C:\Oracle\Middleware\jdeveloper\was\wsclient_extended.jar not found.
Eventhough there is errorlog, as I am beginner I don't know how to solve it. Please solve my issue.
Can you clarify how you created the domain? (You don't need to do this manually).
Are you able to start the integrated WebLogic at all?
If not try to remove the defaultDomain directory from the JDeveloper System folder.
I uninstall the jdeveloper and installed it again....I didnot create domain using configuration wizard....and it is working now.
The below site gives required information about configuration of integrated weblogic server
https://docs.oracle.com/middleware/12212/lcm/SOAQS/SOA-INTEGRATING.htm#SOAQS475
Make sure the environment variables are set properly. For eg)
setenv JAVA_HOME /ade_autofs/gd29_3rdparty/JDK6_MAIN_LINUX.X64.rdd/121114.1.6.0.38.0B05/jdk6
If it doesn't work, try removing the default domain directory. It is generally located inside the view, in .jdev_user_home with name as systemxx.x.
I too had the same problem.Tried different methods but failed. In worst case delete folder containing jdeveloper. Go to AppData->Roaming->Jdeveloper .Delete the folder "system11.1.1.7.40.66.61.3". Go to control panel and uninstall "Oracle fusion Middleware 11.1.1.x.x".
Freshly install jdeveloper again and start the server instance.

How to pass environment variable to Tomcat running as Windows service

I have an application installed in Tomcat that is invoked by the wrapper which sets an environment variable
set FOO=c:\foo
and invokes the startup.bat, and I have a requirement to run Tomcat as windows service.
So far, I tried to set the system environment variable, which did not help.
I tried following the windows service HOWTO appending ++Environment in the registry, so that
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat7\Parameters\ImagePath
looks like this
C:\Apache\Tomcat-7.0.64\bin\Tomcat7.exe //RS//Tomcat7 ++Environment=FOO=c:\foo
That did not help either.
Any suggestions, please
You were almost there. Replace the equal sign with a space in your tomcat7 command, and that should work.
I've just written this up on another question: Setting User Environment Variables for tomcat on Windows
I had to change --JvmOptions of the service.bat file then remove the service and re-install again.
--JvmOptions "-Dspring.profiles.active=pp;-Dcatalina.home=%CATALINA_HOME%;...."
I have a InstallService.bat file. In the file I am first creating the service without specifying the Environment variable and then I am updating the service with the Environment variable specified.This is how the bat file looks like.
tomcat8 //IS//CompassTomcat8_8080 --DisplayName="Compass Apache Tomcat 8:8080" --Install=%CATALINA_HOME%\bin\tomcat8.exe --Startup=auto
tomcat8 //US//CompassTomcat8_8080 --DisplayName="Compass Apache Tomcat 8:8080" --Install=%CATALINA_HOME%\bin\tomcat8.exe --Startup=auto --Environment=Key1=Value1;Key2=Value2
It has started working now.

Where to write set JAVA_OPTS in setenv.bat for tomcat 7 windows installation (as a service)

There are various similar questions but none answers where to embed the environment variable. Unfortunately, in my case there is already a file named setenv.bat which contains a lot of code.
There is a lot of code in it. So the question is where do I write (on which line at what place within setenv.bat)
set "JAVA_OPTS=%JAVA_OPTS% -Dblockchain.callbackUrl=http://example.com/"
I wrote it at the beginning of setenv.bat but it doesn't work.
FYI : I installed tomcat using the windows installer, hence, I have tomcat7w.exe
I'm running tomcat as a windows service
I'm trying to access this variable through Spring in my webapp as :
#Value("#{systemProperties['blockchain.callbackUrl']?:'http://localhost:8080/'}")
private String callbackHost;
Update
I tried setting it in catalina.bat, still didn't worked.
When we create a service from Tomcat installation on windows, such parameters have to be defined in service.bat before installing the service with service.bat install command.
--JvmOptions "-Dblockchain.callbackUrl=http://www.example.com/;-Dcatalina.home=%CATALINA_HOME
Add the environment variables to JvmOptions in service.bat as shown above.

Tomcat manager deployement via context file fails

I'm trying to deploy a web app via tomcat manager by only specifying the context file, as described in the tomcat 7 documentation at http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Deploy_A_New_Application_from_a_Local_Path.
I'm issuing the following call to the manager http://myhost.mydomain.com:8080/manager/text/deploy?config=file:/opt/company/product/conf/mycontext.xml
The context file looks like the following :
<!DOCTYPE project>
<Context path="/myapp" docBase="/opt/company/product/lib/myapp.war" antiResourceLocking="false" >
</Context>
And the manager indicates an error : FAIL - Invalid context path null was specified.
Now I can deploy the app if I use the call that also provides the deployment url (path). However I would expect Tomcat to read my context file and determine by itself the path from the file definition.
Is this an issue in the tomcat 7 manager and is there a way of bypassing this ?
Thanks for any pointers
As far as I can tell this is a bug with Tomcat (see comment from #devlearn).
To work around this limitation, I ended up relying on the Tomcat restart to do the initial deployment. Once Tomcat is aware of the application, then I can redeploy at will by stopping the application context, deleting the folder in webapps and manually unzipping the WAR file into a new folder that replaces the one I deleted. Ansible does all this work - I can revert back to using the Tomcat API when this bug is fixed.

Resources