-
15. Re: Class path not loading from web-inf/classes
martsecurit Jul 10, 2013 4:27 AM (in response to astempfel)I suggest the file is not on the class path then, where is the file that you are trying to read stored?
Is it in web-inf/classes? if it does not work in it's current location try putting it in the web-inf/classes directory (people will say this is bad practice but it is somewhere to start from).
It should work from there.
If you can get it working with your file stored in web-inf/classes then you can move the file to a shared lib (not sure about shared libs in JBoss but I can tell you how to do them in WebSphere :-) or place it on the class path.
That would be my next step.
-
16. Re: Class path not loading from web-inf/classes
bsl.lacerda Jul 18, 2013 9:50 AM (in response to sfcoy)1 of 1 people found this helpfulHi Stephen, how are you?
I'm facing this problem but the file is getting loaded from ThirdParty jar file (xwork-2.0.3-.jar), so "I cannot" change the behive of the class ResolverUtil.
What should you suggest in this case?Here is the staktrace.
16:26:07,026 INFO [com.opensymphony.xwork2.util.ResolverUtil] (MSC service thread 1-4) Scanning for classes in [/C:/REDHAT/APPS/jboss-as-7.1.1.Final/bin/content/myapp-0.0.1-SNAPSHOT.war/WEB-INF/classes/eco/stok/contrato/web/struts2/] matching criteria: org.apache.struts2.config.ClasspathConfigurationProvider$1@d74ad67
16:26:07,029 ERROR [com.opensymphony.xwork2.util.ResolverUtil] (MSC service thread 1-4) Could not search jar file 'C:\REDHAT\APPS\jboss-as-7.1.1.Final\bin\content\myapp-web-0.0.1-SNAPSHOT.war\WEB-INF\classes\eco\stok\contrato\web\struts2' for classes matching criteria: org.apache.struts2.config.ClasspathConfigurationProvider$1@d74ad67 due to an IOException: java.io.FileNotFoundException: C:\REDHAT\APPS\jboss-as-7.1.1.Final\bin\content\myapp-web-0.0.1-SNAPSHOT.war\WEB-INF\classes\eco\stok\contrato\web\struts2 (O sistema não pode encontrar o caminho especificado)
at java.io.FileInputStream.open(Native Method) [rt.jar:1.6.0_24]
at java.io.FileInputStream.<init>(Unknown Source) [rt.jar:1.6.0_24]
at com.opensymphony.xwork2.util.ResolverUtil.loadImplementationsInJar(ResolverUtil.java:341) [xwork-2.0.3.jar:]
at com.opensymphony.xwork2.util.ResolverUtil.findInPackage(ResolverUtil.java:288) [xwork-2.0.3.jar:]
at com.opensymphony.xwork2.util.ResolverUtil.find(ResolverUtil.java:240) [xwork-2.0.3.jar:]
at org.apache.struts2.config.ClasspathConfigurationProvider.loadPackages(ClasspathConfigurationProvider.java:234) [struts2-core-2.0.8.jar:]
at org.apache.struts2.config.ClasspathConfigurationProvider.loadPackages(ClasspathConfigurationProvider.java:402) [struts2-core-2.0.8.jar:]
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:152) [xwork-2.0.3.jar:]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52) [xwork-2.0.3.jar:]
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395) [struts2-core-2.0.8.jar:]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452) [struts2-core-2.0.8.jar:]
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201) [struts2-core-2.0.8.jar:]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_24]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_24]
Thanks a lot in advance.
-
17. Re: Class path not loading from web-inf/classes
bsl.lacerda Jul 18, 2013 10:14 AM (in response to bsl.lacerda)Hi all,
I notice that the problem only happen when I deploy a non exploded .war generated by Maven 3.
If I deploy exploded .war generated by eclipse everything works fine.I did some other tests and concluded that the problem is related only with non exploded war generated by Eclipse or Maven.
I also tested with libs on modules and embedded on .war and the problem remains.Any tip will be appreciated.
Thanks in advance.
-
18. Re: Class path not loading from web-inf/classes
sfcoy Jul 18, 2013 10:49 AM (in response to bsl.lacerda)Hi Bruno,
The ResolverUtil class is making the fatal assumption that the application server is going to explode the WAR file in order to deploy it (and therefore permit it to read content from the file system). JBossAS/WildFly doesn't work like this (and has not since about 5.1 or so).
It's not alone in that versions of the Spring Framework prior to about 3.0.3 were broken in the same way.
You might find that it's fixed in a newer version of Struts 2.
This problem is not really related to the original post, btw.
-
19. Re: Class path not loading from web-inf/classes
bsl.lacerda Jul 18, 2013 11:38 AM (in response to sfcoy)Hi Stephen!
We are going to open a Red Hat Call for this problem.Very thanks for always reply my questions.
-
20. Re: Class path not loading from web-inf/classes
sumncc Mar 7, 2014 5:07 AM (in response to bsl.lacerda)Hi Bruno,
Did you managed to get a solution for this at all? If you have, would you mind to tell us please.
I am completely stuck with this.
Or any one else please?
Many Thanks in advance.
-
21. Re: Class path not loading from web-inf/classes
sfcoy Mar 7, 2014 7:45 AM (in response to sumncc)Please describe your problem exactly in a new thread. This one already contains two unrelated problems.
-
22. Re: Class path not loading from web-inf/classes
sumncc Mar 7, 2014 7:50 AM (in response to sfcoy)Hi Stephen,
Many Thanks for your response. I have been little pessimistic with this.
I have posted it here.
ContextClassLoader is not working when war is zipped in Jboss as-7.1.1
Could you kindly have a look , please.
Best Regards
-
23. Re: Class path not loading from web-inf/classes
paulomi Jan 16, 2015 3:34 AM (in response to martsecurit)Hi Martin,
I have an image file which I am reading as resource. And then passing the resource to a File. I am also using JBOSS for deployment and getting the same issue.
If I use resourceAsStream, then it returns an InputStream object. How are you passing the InputStream to a File? My file is a jpg.
Please help.
Thanks,
Paulomi.
-
24. Re: Class path not loading from web-inf/classes
rollsroyas Apr 19, 2015 9:56 AM (in response to astempfel)I know this reply is 2 years late, but I just ran into this same issue with AS7. While handling a file is well documented, I thought I would share the solution that I came up with for handling a directory.
// Thanks to Reading a zip file from java using ZipInputStream
// Using apache commons-io
File targetDir = ...
File srcDir = new File(resourceAsUrl.getFile());
if (srcDir.isDirectory()) {
//This handles the case when the war is exploded try {
// Copies the src directory from the exploded war to the parent of the target dir
// In my case the src directory and the target directory have the same name
FileUtils.copyDirectoryToDirectory(srcDir, targetDir.getParentFile());
} catch (IOException e) {
throw new IllegalStateException(e);
}
} else {
//This handles the case when the war is not exploded
InputStream is = null;
try {
is = resourceAsUrl.openStream();
// FYI: org.jboss.vfs.VirtualJarInputStream extends ZipInputStream
if (is instanceof ZipInputStream) {
ZipInputStream stream = (ZipInputStream) is;
// now iterate through each item in the stream. The get next
// entry call will return a ZipEntry for each file in the stream
ZipEntry entry;
while((entry = stream.getNextEntry())!=null) {
// Copies the contents of the src directory from the non-exploded war // to the target dir File outFile = new File(targetDir, entry.getName());
FileOutputStream output = null;
try {
output = new FileOutputStream(outFile);
IOUtils.copy(stream, output);
} finally {
IOUtils.closeQuietly(output);
}
}
}
} catch (Exception e) {
throw new IllegalStateException("Unable to find src directory in the war", e);
} finally {
// we must always close the zip file.
IOUtils.closeQuietly(is);
}
if (is == null) {
throw new IllegalStateException("Unable to find src directory in the war");
}
}