I'm trying to compile a servlet which sets session data for my site. However I'm having big problems trying to import other class files which the servlet relies on.
I need to import my custom made MySQL class file which is located in evo.net. (WEB-INF/classes/evo/net). This is already compiled and works perfectly.
And I also need to import my custom made Encryption class for encrypting passwords using it's md5() method. This is located in evo.common (WEB-INF/classes/evo/common). This is already compiled and works perfectly too.
My Session servlet is located in the same package as my MySQL class (evo.net or WEB-INF/classes/evo/net).
I'm setting the classpaths as follows:
set classpath=;D:\Apache Software Foundation\Tomcat
7.0\lib\servlet-api.jar;D:\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\WEB-INF\classes\evo\common\Encryption;D:\Apache Software Foundation\Tomcat
7.0\webapps\ROOT\WEB-INF\classes\evo\net\MySQL
Is this the wrong way to set multiple classpaths? As its throwing 'cannot find symbol' errors. If I just set the classpath pointing at the servlet-api.jar it fixes the javax cannot find symbol errors, but when I add the others on the classpath it doesnt work. Help much appreciated. Thanks!
Related
I'm trying to decrypt a file using Bouncy Castle v1.53 PGP and Using PGPUtil class.
The program works fine in my Eclipse, but given following error when integrated inside a war file and deployed onto a weblogic server.I'm using following dependencies:
1)bcpg-jdk15on
2)bcprov-jdk15on
Error
java.lang.NoSuchMethodError:
org.bouncycastle.util.Strings.newList()Lorg/bouncycastle/util/StringList;
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.bcpg.ArmoredInputStream.<init>(Unknown Source)
at org.bouncycastle.openpgp.PGPUtil.getDecoderStream(Unknown Source)`
Resolution
This problem is resolved when I copied following classes into my source folder:
org.bouncycastle.util.Strings
org.bouncycastle.util.StringList
org.bouncycastle.bcpg.ArmoredInputStream
org.bouncycastle.openpgp.PGPUtil`
by changing their Class Names
However, I want a better fix than this as I feel this is some Jar Conflict
Please let me know if anyone finds one
That error is likely happening because you are using one version of the bouncycastle .jars when you run with Eclipse, but there is a different version of one of those .jars which is on the classpath that Weblogic is using when running your application.
You will need to investigate how exactly Weblogic sets up the classpath, and make sure the version of the .jars you need are on the classpath before the preexisting version (unless that preexisting version is there by mistake, in which case you can just remove the preexisting one from the classpath).
I am having an issue getting Peaberry/Guice/OSGi/Servlets to place nice. To begin, I have been migrating a Jetty-based, WAR deployed webapp over to OSGi to leverage the plugin architecture. My original application was using guice everywhere.
I have broken everything into modules and Maven-iszed the build. Everything seems to be working except for the pesky installation of the ServletModule.
I receive the following exception when I attempt to install a ServletModule:
java.lang.NoClassDefFoundError: com/google/inject/internal/util/$Preconditions
at com.google.inject.servlet.ServletModule.configure(ServletModule.java:44)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.AbstractModule.install(AbstractModule.java:118)
at com.payplum.CoreActivator$CoreImportModule.configure(CoreActivator.java:145)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at com.payplum.CoreActivator.start(CoreActivator.java:53)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
So I'm not quite clear on why it's failing to find these bundles. I have added the guice-servlet dependency and have verified that it is making it into my deployed bundles.
I guess the other piece of importance is registering the GuiceFilter. I use the ServiceTracker to get the ExtHttpService, as I'm using Jetty. When that Tracker returns, I add register it out using the typical call
service.registerFilter( this.guiceFilter, "/*", null, 0, null );
And that seems to work fine. I'm really struggling to get these things working and I'm a little caught in the middle between the Guice/OSGi/Peaberry part. Any help is much appreciated.
Thanks!
The exception means you're missing a class on your classpath, so you're either missing a jar or one of the jars (surprisingly) doesn't include its required classes. Check the JARs that are included in your final war file e.g. using 'jar -tf thejar.jar' on whether they include the $Preconditions class.
I've seen many manifestations of ways to use the user class path as precedent to the hadoop one. Often times this is done if an m/r job needs a specific version of a library that hadoop coincidentally already uses an older version of (for example jackson's json parser or commons http , etc.)
In any case : I've seen :
mapreduce.task.classpath.user.precedence
mapreduce.task.classpath.first
mapreduce.job.user.classpath.first
Which one of these parameters is the right one to set in my job configuration, in order to force mappers and reducers to have a class path which puts my user defined hadoop_classpath jars BEFORE the hadoop default dependency jars ?
By the way, this is related to this question :
Dynamodb requestHandler acception which I recently have found is due to a jar conflict.
So, assuming you're using 0.20.203, this is handled in the TaskRunner.java code as follows:
The property you're looking for is on line 94 - mapreduce.user.classpath.first
Line 214 is where the call is made to build the list of classpaths, which delegates to a method called getClassPaths(..)
getClassPaths() is defined on line 524, and you should be able to see that the configuration property is used to decide on whether your job + dist cache libraries, or the hadoop libraries go on the classpath first
For other versions of hadoop, you're best to check the TaskRunner.java class to confirm the name of the config property after all this is a "semi hidden config":
static final String MAPREDUCE_USER_CLASSPATH_FIRST =
"mapreduce.user.classpath.first"; //a semi-hidden config
As in the latest Hadoop version (2.2+), you should set:
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, true);
These settings work for referencing classes of external jars only in your mapper or reducer tasks. If, however, you are using these in, for example a customized InputFormat, it will fail to load the class. A way to make sure this also works everywhere (in MR2) is exporting this setting when submitting your job:
export HADOOP_USER_CLASSPATH_FIRST=true
I had the same issue and the parameter that worked for me on Hadoop Version 0.20.2-cdhu03 is "mapreduce.task.classpath.user.precedence"
This setting is tested not work on CDH3U3, following answer is from Cloudera team:
// JobConf job = new JobConf(getConf(), MyJob.class);
// job.setUserClassesTakesPrecedence(true);
http://archive.cloudera.com/cdh/3/hadoop/api/org/apache/hadoop/mapred/JobConf.html#setUserClassesTakesPrecedence%28boolean%29
In the MapR distribution, the property is "mapreduce.task.classpath.user.precedence"
http://www.mapr.com/doc/display/MapR/mapred-site.xml
<property>
<name>mapreduce.task.classpath.user.precedence</name>
<value>true</value>
<description>Set to true if user wants to set different classpath. (AVRO) </description>
</property>
jobConf.setUserClassesTakesPrecedence(true);
I'm getting a NoClassDefFoundError error when trying to compile or run a Jasper report.
2012-06-13 14:46:26,710 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/jahtest].[jahtest]] Servlet.service() for servlet jahtest threw exception
java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.xml.JRXmlDigesterFactory
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:207)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)
at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:156)
I have a set of java classes wrapped up in a war file and deployed in JBoss default/deploy folder.
I have the jasperreports-4.1.2.jar file in the JBoss default/lib folder so I can't see how there can be a classpath problem because all other jars in the lib folder can be seen.
My front-end app calls a HTTPServlet class which then uses reflection to call the class containing the Jasper code. Everything works fine up until the point where this line is called -
JasperDesign jasperDesign = JRXmlLoader.load(strCompiledReportFile);
The strCompiledReportFile is correct and exists. This all works when I run it through Eclipse, just not when called from my HTTPServlet class.
I'm at the point where I want to ditch Jasper because I've had so many issues with it so this is the last chance saloon.
Cheers for any help you might be able to offer.
I think you are missing few jars that jasper depends on at runtime. Check this thread and make sure you have those jars in your classpath as well.
I'm not sure if it would also apply to your case, but I had a similar problem recently, where after failing to load a font ("problem reading font data"), Jasper Reports would start giving spurious java.lang.NoClassDefFoundError for many of its classes; this problem was caused because java.awt.Font.createFont(int fontFormat, InputStream fontStream) tried and failed to create a temporary file. The error happened inside Tomcat, but not inside Eclipse; what was happening was that Tomcat automatically configures its JVM to point to its temp folder instead of the default one, and Tomcat's temp folder had been deleted.
If you are trying to integrate jasper with springboot application check whether the .jrxml is in the resources folder.
I have this seam project that a colleague built. I am trying to get it to build in Jboss dev Studio. He uses ant and builds manually. I got the project built in JBDS and deployed on the JBoss server. When i try to run the app, when it is time for the rules to fire, I get this error
Caused by: org.drools.RuntimeDroolsException: Unable to resolve class 'dne.nmst.ciscoconfig.model.ConfigParams_$$_javassist_seam_4'
The offending code is in the drools config file which includes 2 imports
package Config;
import dne.nmst.ciscoconfig.model.ConfigParams;
import dne.nmst.ciscoconfig.action.ConfigSelector;
Perhaps I need more detail here, I don't know what would be useful to post. I'm not even sure I know how to ask the question other than how do I fix this. Advice anyone?
Are you 100% sure the jar containing those imports is available at runtime, rather than just at compile time?