Jetty ConcatServlet to handle filter generated content - servlets

I try to use jetty's ConcatServlet to concatenate javascript generated from my own servlet and javascript generated by wro4j WroFilter. It seems concatenation doesn't work, regardless the javadoc of ConcatServlet that states that it can be used to concat generated content.
I think the issue is that the wro4j content is generated by a filter an not a servlet as 'concatenating' a single source generated by my servlet works fine, while 'concatenating' the single wro4j generated resource doesn't work but I get the exception below. It complaints about a missing file, although the request /wro/script.js is served fine if requested normally. Any suggestions?
java.io.FileNotFoundException: !/wro/script.js
at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:465)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:526)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:586)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1105)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1039)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.Dispatcher.include(Dispatcher.java:169)
at org.eclipse.jetty.servlets.ConcatServlet.doGet(ConcatServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:695)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1564)
at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:164)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1535)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:524)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1105)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1039)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:201)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:445)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:277)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:216)
at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
at java.lang.Thread.run(Thread.java:724)

Related

Websphere - javax.servlet.UnavailableException: Servlet not a servlet class

I get this error message when trying to connect to our webservices.
Error 404: javax.servlet.UnavailableException: SRVE0201E: Servlet [...] not a servlet class.
However, the class mentioned inside the brackets is a servlet class:
#WebService(serviceName = "xxx", endpointInterface = "xxx")
What I read was that in Websphere the class loader should be configured to Parent last; this is what I did and then to get rid of all jar - files that use Servlet.jar - I think I did this, too, since the only files that I am using are these ones:
antisamy-1.4.3.jar
api-7.9.0.0.jar
avalon-framework-4.1.3.jar
batik-css-1.7.jar
batik-ext-1.7.jar
batik-util-1.7.jar
bsh-core-2.0b4.jar
commons-beanutils-1.7.0.jar
commons-beanutils-core-1.7.0.jar
commons-codec-1.2.jar
commons-collections-3.2.jar
commons-configuration-1.5.jar
commons-digester-1.8.jar
commons-fileupload-1.2.jar
commons-httpclient-3.1.jar
commons-lang-2.3.jar
commons-logging-1.1.jar
core-7.9.0.0.jar
dom4j-1.6.1.jar
esapi-2.0_rc11.jar
istack-commons-runtime-2.16.jar
jaxb-api-2.2.9.jar
jaxb-core-2.2.8-b01.jar
jaxb-impl-2.2-promoted-b65.jar
jaxen-1.1-beta-8.jar
jdom-1.0.jar
log4j-1.2.16.jar
log4j-api-2.7.jar
log4j-core-2.7.jar
logkit-1.0.1.jar
nekohtml-1.9.12.jar
serializer-2.7.2.jar
xalan-2.7.2.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
xml-apis-ext-1.3.04.jar
xom-1.1.jar
Maybe someone could give me a hint or knows that the problem can be?
Thank you very much!
If you're relying on the annotation you mentioned, that's going to create a web service, not a servlet. Unless of course the class the #WebService is defined in extends javax.servlet.Servlet. Did you mean #WebServlet instead? Posting the pertinent portion of your source would be helpful.
This is one possibility:
https://developer.ibm.com/answers/questions/171243/srve0201e-servlet-my-webservice-not-a-servlet-clas.html
This text in particular:
The issue was showing up at deploy time and had to do with the fact
that my web services was referencing classes in a shared library. The
deploy code doesn't have access to the shared library so it wasn't
able to resolve things and gave up.
After some mad refactoring it started working.

Optaplanner as jar does not seem to read xml file

I am new to optaplanner
i worked in iDE and created a working prototype and now want to run in a prod mimic testing.
i created a jar of my entire project
but when i invoke the jar with the input files,
i get exception as "Null POinter Exception"
I tried created SolverFactory by two ways
Trial 1:
SolverFactory<PocSolution> factory = SolverFactory.createFromXmlResource(SOLVER_CONFIG,this.getClass().getClassLoader());
Trial 2:
SolverFactory<PocSolution> factory = SolverFactory.createFromXmlReader(new FileReader(SOLVER_CONFIG),this.getClass().getClassLoader());
Exception in thread "main" java.lang.NullPointerException
at org.kie.internal.io.ResourceFactory.newByteArrayResource(ResourceFactory.java:66)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.getResource(AbstractKieModule.java:299)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.addResourceToCompiler(AbstractKieModule.java:264)
at org.drools.compiler.kie.builder.impl.AbstractKieModule.addResourceToCompiler(AbstractKieModule.java:259)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:228)
at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:74)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:251)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:219)
at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:177)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:503)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:331)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:220)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:57)
at org.optaplanner.examples.MyPoc.app.Poc.solve(Poc.java:132)
at org.optaplanner.examples.MyPoc.app.Poc.main(Poc.java:41)
Your solver config file is being read successfully. The problem seems to be inside the <scoreDirectorFactory> element, where you specify score DRL. Please make sure that you use the <scoreDrl> element and not <scoreDrlFile>. <scoreDrlFile> is supposed to contain a local file system path whereas <scoreDrl> is used to load a classpath resource (which is the case when the DRL file is located inside a JAR). It should look similar to:
<scoreDirectorFactory>
<scoreDrl>org/myproj/core/solver/myRules.drl</scoreDrl>
</scoreDirectorFactory>

JDO + datanucleus API enhancement

I want to load dynamically XML meta-data files that are not in the classpath (the XML meta-data files will be generated after launching my app).
I thought I could call the method
MetaDataManager.registerFile(java.lang.String fileURLString, FileMetaData filemd, ClassLoaderResolver clr)
Then, I tried the API enhancement, so I added the following lines:
JDOEnhancer enhancer = JDOHelper.getEnhancer();
enhancer.setVerbose(true);
enhancer.addClasses(ClassToPersist.class.getName()).enhance();
getClass().getClassLoader().loadClass(ClassToPersist.class.getName());
The following jars are in the classpath: datanucleus-api-jdo.jar, datanucleus-connectionpool.jar, datanucleus-core.jar datanucleus-rdbms.jar, jdo-api.jar, asm.jar.
But when I launch my app, I get this exception:
Caused by: mypackage.MyException:
org.datanucleus.api.jdo.exceptions.ClassNotPersistenceCapableException: The class "mypackage.ClassToPersist" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
Do you please have any idea how to fix this ?
PS: I also noticed that the method enhance returns 0 which indicates that the class has not been enhanced (we could exclude the other options)
Thanks
I think I found an easy way to fix this.
At runtime, I created a jar that contains the updated metadata file as META-INF/package.jdo. Then I added this jar to the classpath as described here
Using this hacks, I didn't need to re-enhace my class since it is enhanced after compilation.
(But for information, I had to call JDOEnhancer.addFiles() to enhance my class.)
So your call to loadClass has loaded the unenhanced class (since it would have been loaded in order to perform the enhancement presumably), and you didn't follow the tutorial that is provided at http://www.datanucleus.org/documentation/development/dynamic_class_metadata_enhance_runtime.html

Parsing Meteor error: Exception from Deps afterFlush

I get these Deps errors from time to time and I can never figure out what they mean or what they're pointing to:
Exception from Deps afterFlush function function: SyntaxError: Unexpected identifier
at eval (native)
at http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:372:22
at Function.jQuery.extend.globalEval (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:373:7)
at jQuery.ajaxSetup.converters.text script (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9806:11)
at ajaxConvert (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:8873:18)
at done (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9293:15)
at callback (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9753:8)
at Object.send (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9759:7)
at Function.jQuery.extend.ajax (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9244:15)
at Function.jQuery._evalUrl (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9409:16) debug.js:41
It thinks that there is a syntax error, but the only files it points to are jquery.js, which I HIGHLY doubt contain errors...
This error is caused by code in a Template helper somewhere that uses JQuery/a jquery plugin and is running code using eval which contains a syntax error in it, which is why it appears to come from JQuery itself.
There isn't much more than this to go off im afraid. It might be from ajax. Have a look at your chrome's network tab to see what is being downloaded just before this happens and see if it contains any javascript.
If it contains HTML when it should contain javascript check your Meteor paths, Meteor does not throw 404 errors, instead it serves out the main page's html, which may be why the error displays this way instead of a 404
I just came across the similar "afterFlush" error, and while my error was also rooted in a jQuery/plugin with Meteor, it had nothing to do with eval.
The issue circled back around to updating the DOM at the same time I was updating a reactive method, where Meteor was also updating the DOM reactively. I found this out, and removed the manual DOM manipulation, which made this error go away. Hope someone else finds this helpful...

Rendering Component link with Tridion2011 OData Linking.svc

We are using custom-written proxy class for handling the Web Service communication provided by Mihai Cadariu (screenshot attached) for resolving dynamic linking.
For forming the LinkUrl parameters to resolve dynamiclink/component link we are following the below sample approach. But its throwing error (stacktrace,debug error)attached .Please validate and provide the inputs where we are going wrong. Please let us know the parameters we are passing are correct or not
Approach we used:
-->We have two components Comp1,Comp2 (can be created of same/different schema guess it not any issue)
-->Comp2 is being used as component link inside Comp1 (we have a component link field in comp1)
-->Created two dynamic CT’s DCT1, DCT2 for each comp (CT’s have simple DWT, Default finish actions)
Note: also tried keeping DD4T TBBs in similar set of CT’s as other approach but final got same error result
-->DWT code has --> SomeLink (to render component link so that LinkResolver TBB will resolve the links)
Also kept OTHWayLink (for cross checking)
-->Created two Pages Page1 (has Comp1+DCT1), Page2 (has Comp2 +DCT2) and published both pages to broker DB
-->Our goal is to resolve component link (Comp2) which is present inside Comp1 content so,
-->For GetDynamicLink() we provided parameters as given below. Which throwed error :400 (bad request) and exception in log trace attached above.
Param’s List --> string targetPageUri, string targetComponentUri, string targetTemplateUri, string linkText, bool showTextOnFail, string linkTagAttributes
Param’s we passed--> Page2 tcmid, Comp2 tcmid, DCT2 tcmid ,”some link txt”,true,”some string”;
-->For GetComponentLink()we provided parameters as given below. In this case we tried keeping both dynamic and non dynamic CT’s combination inside pages, Which also throwed error :400 (bad request) and exception in log trace attached above.
Param’s List --> string targetComponentUri, string sourcePageUri, string excludeTemplateUri, string linkText, bool showTextOnFail, bool showAnchor, string linkTagAttributes
Param’s we passed --> Comp2 tcmid, Page1 tcmid, DCT1 tcmid, “some link txt”,true,true,”some string” ;
we are refering Live documentation for Linking.
Mihai Proxy Code sample:
Error message:
Looks to me like your odata website is not set up correctly in d:/inetpub/wwwroot/odata/bin as the error message is that Classes are not found.
Can you confirm you've installed/placed the correct SDL Tridion dll/lib and configuration XML files into your website?
Here is a great post about how SDL Tridion loads these files: http://www.tridiondeveloper.com/how-tridion-content-delivery-loads-configuration-files-in-dotnet I'm sure once you've got the Odata application/website up and running this will work correctly for you.
The Content Delivery linking service's parameters are documented on this page (log in required). I'll paste an excerpt below, but you really should simply compare your strings to the parameters mentioned on that page.
Component Links
Command:/linking/componentLink (Java) or /linking.svc/componentLink (.NET)
Input parameters:
Parameter name Default value
sourcePageURI (none)
targetComponentURI (none)
excludeTemplateURI (none)
linkTagAttributes (empty)
linkText (empty)
showTextOnFail true
showAnchor false
From cross-checking these with the code you pasted in the screenshot, everything seems to line up.
That answer your question. But I doubt it solves your problem, since that seems (as John Winter suggested) more infrastructural: you're missing cd_link.jar in the relevant directory.
If you find it difficult to diagnose this problem further, I suggest contacting the original author of this custom code (or SDL or one of its partners). This will ensure you get help from someone who is experienced in troubleshooting the loading of JARs, DLLs and configuration files.

Resources