Tapestry5 : Trying to load javascript file - java

I am stuck at really curious error.
I have a tapestry page in which I was trying to import a javascript file. Previously, I was importing extjs-version3.js file(which worked perfect) and then I wanted to import extjs-version4.js file. So, I removed the version3 file from file system, added version4 file to file system and changed my tapestry page's java code to import the version4 file. But I always got the error, "version3 file does not exist"!
While debugging, I changed the java code of page so that it does not import ANY file now.
So, now I have a page that does not import any javascript file and I still get the error, "version3 file does not exists".
Following are the exact details.
MyPage.java which imports the javascript file.
#Import(
library = {
//"context:js/lib/extjs3/adapter/ext/ext-base-debug.js",
//"context:js/lib/extjs3/ext-all-debug-w-comments-v4.js",
/*"context:js/lib/ext_compat_layer/ext3-compat.js",
"context:js/lib/ext_compat_layer/ext3-core-compat.js",*/
//"context:js/page/ActivitiesTab.js",
//"context:js/lib/extjs3/ux/gridSearch/Ext.ux.grid.Search.js",
//"context:js/lib/extjs3/ux/gridSearch/Ext.ux.IconMenu.js",
//"context:js/lib/extjs3/ux/gridSearch/Ext.ux.Toast.js"
},
stylesheet = {
/*"context:js/lib/extjs3/resources/css/ext-all.css",
"context:js/lib/extjs3/resources/css/xtheme-gray.css",
"context:js/lib/extjs3/resources/css/theme-gray/core.css",*/
//"context:js/lib/extjs3/resources/css/icons.css",
//"context:js/lib/extjs3/resources/css/gridsearch.css"
}
)
The stack trace of error I receive.
An unexpected application exception has occurred.
org.apache.tapestry5.ioc.internal.OperationException
Unable to locate asset 'context:js/lib/extjs3/ext-all-debug-w-comments.js' (the file does not exist).
trace
Constructing instance of page class net.semandex.salsa.tapestry.pages.ActivitiesTab
java.lang.RuntimeException
Unable to locate asset 'context:js/lib/extjs3/ext-all-debug-w-comments.js' (the file does not exist).
Hide uninteresting stack frames Stack trace
org.apache.tapestry5.internal.services.AssetSourceImpl.getLocalizedAssetFromResource(AssetSourceImpl.java:135)
org.apache.tapestry5.internal.services.AssetSourceImpl.getAssetInLocale(AssetSourceImpl.java:105)
org.apache.tapestry5.internal.services.AssetSourceImpl.getAsset(AssetSourceImpl.java:85)
org.apache.tapestry5.internal.transform.ImportWorker$5.map(ImportWorker.java:206)
org.apache.tapestry5.internal.transform.ImportWorker$5.map(ImportWorker.java:203)
org.apache.tapestry5.func.LazyMappedValue.get(LazyMappedValue.java:31)
org.apache.tapestry5.func.LazyFlow.first(LazyFlow.java:52)
org.apache.tapestry5.func.AbstractFlow$1.next(AbstractFlow.java:68)
org.apache.tapestry5.func.AbstractFlow.toMutableList(AbstractFlow.java:47)
org.apache.tapestry5.func.AbstractFlow.toMutableList(AbstractFlow.java:40)
org.apache.tapestry5.func.AbstractFlow.toList(AbstractFlow.java:205)
org.apache.tapestry5.internal.transform.ImportWorker.convertPathsToAssets(ImportWorker.java:202)
org.apache.tapestry5.internal.transform.ImportWorker.access$100(ImportWorker.java:40)
org.apache.tapestry5.internal.transform.ImportWorker$4.advise(ImportWorker.java:190)
org.apache.tapestry5.internal.services.AbstractComponentMethodInvocation.proceed(AbstractComponentMethodInvocation.java:86)
net.semandex.salsa.tapestry.pages.ActivitiesTab.containingPageDidLoad(ActivitiesTab.java)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$4.run(ComponentPageElementImpl.java:120)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:977)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.containingPageDidLoad(ComponentPageElementImpl.java:829)
org.apache.tapestry5.internal.structure.PageImpl.loaded(PageImpl.java:171)
org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:190)
org.apache.tapestry5.internal.pageload.PageLoaderImpl$3.invoke(PageLoaderImpl.java:174)
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:65)
org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68)
org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1063)
org.apache.tapestry5.internal.pageload.PageLoaderImpl.loadPage(PageLoaderImpl.java:173)
org.apache.tapestry5.internal.services.PageSourceImpl.getPage(PageSourceImpl.java:81)
org.apache.tapestry5.internal.services.NonPoolingRequestPageCacheImpl.get(NonPoolingRequestPageCacheImpl.java:74)
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:55)
org.apache.tapestry5.services.TapestryModule$36.handle(TapestryModule.java:2326)
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47)
org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:45)
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:321)
net.semandex.salsa.tapestry.services.AppModule$1.service(AppModule.java:164)
org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:984)
org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:974)
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
org.apache.tapestry5.internal.services.URLRewriterRequestFilter.service(URLRewriterRequestFilter.java:50)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:90)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:80)
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:103)
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:272)
org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter.service(MultipartServletRequestFilter.java:44)
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:928)
org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:147)
MyPage.tml file is very simple and has nothing suspicious but I can post the code if needed.
Why tapestry is trying to load a js file which is not included in any page?
Update:
Infact, irrespective of what I write in #Import annotation, the files are always imported according to the previous code. This is happening with all the pages.

This could be caused by some component in the template which fails to load the asset, or maybe a parent template that is extended by MyPage.
According to the stacktrace, the page net.semandex.salsa.tapestry.pages.ActivitiesTab is the cause of the problem. MyPage probably loads it somewhere.

Resolved now. The problem was with my production environment and not in Tapestry. Java class files were not updated by Eclipse when I changed them. Because of this, javascript files were imported based on the previous code in java file of the page.
Eclipse reported following problem.
"The project was not built due to "Could not delete '/someName/bin/". Fix the problem, then try refreshing this project and building it since it may be inconsistent"
I referred this question and solved my problem.
Simple refresh, clean/publish did not solve my problem. I had to close the Eclipse and restart the PC. This fixed my environment and now Eclipse is updating the java classes properly.

Related

How to load a 'ParserModel' and where to place the "en-parser-chunking.bin" file in my Web application?

I'm getting an error while running my java web application. I have one servlet class and one class for Apache openNLP text analyzing. When I run my code (submit my form data to servlet) I get below error code in my browser
Also it shows below exception details in eclipse console.
Below is my project structure and I have placed the "en-parser-chunking.bin" file in highlighted area.
Is there any better way to place my "en-parser-chunking.bin" file?
First part of the answer:
1) Place the en-parser-chunking.bin into the WebContent/WEB-INF/classes or WebContent/WEB-INF/resources folder of your Eclipse project. These are directories in which the instance of WebappClassLoaderBase is allowed to load resources from at runtime of a web application.
2) With this code snippet (which is shortened for brevity):
String parserModelPath = "/WEB-INF/resources/en-parser-chunker.bin";
ParserModel model = new ParserModel(servletContext.getResourceAsStream(parserModelPath));
if(model!=null) {
// From here, <model> is initialized and you can start playing with it...
// Creating a parser
Parser parser = ParserFactory.create(model);
// Parse some things here
// ...
}
you should get a working Parser at runtime. For reference, see JavaDoc for ServletContext#getResourceAsStream and this StackOverflow post.
Second part of the answer:
1) Place the opennlp-tools-<opennlp-version>.jar file into WebContent/WEB-INF/lib or reference it in the Web-App's class path of your project setup. Thus, the library and its classes, such as opennlp.tools.parser.ParserModel, can be loaded and used at runtime of your project.
2) Re-bundle your war archive and redeploy it to your Tomcat's webapps directory.
Hope it helps, see also my similar answer.

Property exception component:'jsgfGrammar'

So I have been trying to start writing my own code for Sphinx4. I created my own grammar, config, and java file, all necessary for it to run, and used the code from the HelloWorld demo. However, when I ran the code, I received this error:
Problem configuring HelloWorld: Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:/edu/cmu/sphinx/demo/hellowrld/
edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:/edu/cmu/sphinx/demo/hellowrld/
Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:/edu/cmu/sphinx/demo/hellowrld/
edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:/edu/cmu/sphinx/demo/hellowrld/
at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.getResource(ConfigurationManagerUtils.java:483)
followed by more edu.cmu.sphinx.util.props that are missing apparently.
When I go to the project folder where the demos are, there aren't any files there, so I am not sure if there are files I am just missing or aren't included. Everything is in the same workspace folder as well.
Would anyone have any idea as to why my program isn't running? I need this baseline to work properly so I can write my own code.
Also any references to tutorial videos, links or documents to help with Sphinx4 would be greatly appreciated. I have seen a video from Puneet and Sharing is Caring on YouTube. The Sphinx site isn't that helpful in terms of starting because they mainly discuss the writing the code in manually, which was confusing.

Eclipse can't find source when debugging java code

I am new to Java and started with Eclipse Kepler Service Release 1. I started a small project that contains two classes, each in its own file:
MIDI_Wrap_Test - a main (program) class
MIDI_Wrap - another class (MIDI_Wrap) which is intended as a MIDI wrapper. -
Both classes are in the same directory with file names being the same as the class name (with .java added of course). Something goes wrong and I want to debug it. However, when control transfers from the main program to the MIDI_Wrap file/class I get the error message 'source not found'.
I found out that this is a quite common error. The question and answer that seem to mirror my problem perfectly is found here. I added the project to the debug source path, noticing that the correct directories were already added but to no avail.
I must be doing something wrong but am not able to find out what. Can someone help me out of this?
I solved by shutting down eclipse and reopened it. This solved me, and code can be debug with source code view.

org.postgresql.*; class not found error

I am using Java with eclipse.
I downloaded postgresql-9.1-901.jdbc4.jar and added it. (Properties-> Java Build Path-> Libraries -> Add External JARs...
My Database connection is working just fine I can create tables, execute queries ect.
Now I want to use the CopyManager. And therefore added to my code:
import org.postgresql.copy.CopyManager;
...
CopyManager cManager = new CopyManager(XXX);
unfortunately I get an error Message saying: "The source attachment does not contain the source for the file CopyManager.class"
Exception in thread "main" java.lang.NullPointerException
at org.postgresql.copy.CopyManager.<init>(CopyManager.java:46)
at Table.insert_data_in_tb(Table.java:73)
at DB.main(DB.java:69)
I'd be very thankfull for any help...
This is a message you get while running your code and clicking methods in debug mode. To correct the immediate problem (being able to view the source code) do this:
Download PostgreSQL 9.1 source
code
Copy the file to some appropriate folder and untar it
tar xvf postgresql-jdbc-9.1-901.src.tar.gz
Add the source folder to your debug configuration in Eclipse
(Run->Debug Configurations->select Java Application->Click Source
tab->Add->File System Directory->add ), where directory is
where you expanded the tarball too.
However, you really don't need to view the source code in order to determine whats going wrong in your program. The documentation for CopyManager is available in online Javadocs. The constructor for the object requires a valid connection, which I am guessing is null in your program.

Incompatible magic value 1008813135

I am writing a Java applet and embedding it in a web page.
It used to run Mac and Windows in different browsers without problem.
I was using NetBeans on the Mac to build the .jar file the applet used.
For some reason or another I decided to load the project on the Windows' NetBeans - I started getting the following error on the Windows machine when accessing the web page from any browser:
java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file
Fearing that it must have been my decision to open the project on Windows that caused this error - I tried to build from the Mac's NetBeans - but the error persisted.
I started a while new project on the Mac and imported the existing source code: still same problem.
I was doing some reading about this error and it seems that the magic number expected is 0xCAFEBABE in hex which is 3405691582 in decimal, not 1008813135. So it looks like the Mac version of Java doesn't produce this file header any more? Hoe can that be? I didn't do any updates or anything.
Yes, 0xCAFEBABE is the usual first 4 bytes of a Java file.
1008813135 is <!DO in Latin encoding, which is, in all probability, the start of <!DOCTYPE....
It is therefore likely the start of a 404 error, or some other error page.
I have not experienced this problem, but Googling this error yields several possible solutions:
forum.sun.com - Java Applet Development - Incompatible magic value 1008813135 in class file MyApplet
Thanks God the problem is solved.
Its the Java cache, so the solution go to Java Control Panel, "General" tab, and under "Temporary Internet Files" click "Settings", then click "Delete Files". Try using the applet again.
"Incompatible magic value 1008813135" Error?
The problem is now solved: I found out that the website host I was using didn't support .jar files at all. I mass-uploaded the files with my ftp program and didn't notice that it ignored the .jar files completely.
Errors on java initialization
Alright, so it was an apache configuration issue, removed this line from my httpd.conf file:
# DefaultType application/x-httpd-php
Fixed the issue.
If you are using Spring security or some sort of custom Servlet Filters, make sure, that the archive or codebase location is in "permitAll" access. This was to problem in my case
I was facing the same problem.The reason in my case was all dependency library that Applet uses was not signed and also applet not able to locate them.
So i Have added all the dependent library along with main applet in jsp file like below :
app.archive = '/esense/resources/lib/Applet.jar, /esense/resources/lib/jasypt-1.7.jar, /esense/resources/lib/mysql-connector-java-5.1.30.jar, /esense/resources/lib/runtime-api-1.0.jar';
I have also signed all the jar.
Hope this may work in your case.
The incompatible magic number is the first four bytes of a html file that has some error message in it, probably a message that the file isn't found.
I encountered this phenomenon when I didn't take case sensitivity into account in the codebase element of the applet tag. Things worked well on Windows, but the internet server I was using was running UNIX where filename case sensitivity is important. Making the case of all file and directory names in the code and codebase elements solved the problem.
I just clicked on maven->update project->include snapshot release in my spring boot and it worked.

Categories