I'm new to drools and what I'm trying to do is to get a value from the rules
I used the code from the project sample of drools which is:
Reading the DRL file:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "path.drl", getClass() ), ResourceType.DRL );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if( errors.size() > 0 )
{
for( KnowledgeBuilderError error : errors )
{
System.err.println( error );
}
throw new IllegalArgumentException( "Could not parse knowledge." );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
return kbase;
Inserting object and firing the rules
Bean bean = new Bean();
StatefulKnowledgeSession ksession = aKnowledgeBase.newStatefulKnowledgeSession();
// planning to insert a double
ksession.insert( bean );
ksession.fireAllRules();
What I want to do is to get a value from the rules, What I tried so far is using query which is I'm not sure if it is the proper way of doing it:
global String $test;
rule "Excellent"
when
// I'm planning to replace the bean with just a double is that possible?
$m: bean ( listeningScore > 85 )
$p: bean ( listeningScore < 101 )
then
$test = "Excellent";
System.out.println( $test );
end
query "Knowledge"
$result : $test
end
Also this produce an error which I really don't know how to fix. Here is the stacktrace:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[24,0]: [ERR 102] Line 24:0 mismatched input 'end' in query
[0,0]: Parser returned a null Package
java.lang.IllegalArgumentException: Could not parse knowledge.
at com.neu.als.thesis.units.InferenceEngine.readKnowledgeBase(InferenceEngine.java:61)
at com.neu.als.thesis.units.EvaluationUnit.evaluateConceptKnowledgeLevel(EvaluationUnit.java:187)
at com.neu.als.thesis.web.controllers.FLTController.evaluateFLT(FLTController.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:946)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:848)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:822)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Firstly, that exception means that the DRL code won't compile. I suspect this is because your query is referencing a bound variable from another rule, but it could be something else. Check out the docs on syntax for queries.
However, I tend to use one of two mechanisms for getting rule responses into the Java code.
In a stateless session have rules modify the inserted fact(s). After rules execution, just look at the fact that you inserted.
In a stateful session you can additionally use session.getObjects() or session.getObjects(ObjectFilter) to get references to the facts that are in the working memory after rules execution.
Here's an example of the first pattern, modifying the inserted fact:
rule "Reject a request"
when
$req: PaymentValidationRequest()
then
$req.setValid(false);
update($req);
end
PaymentValidationRequest request = new PaymentValidationRequest(payment);
request.setPayment(payment);
List<Object> facts = new ArrayList<Object>();
facts.add(request);
ksession.execute(facts);
...
boolean isValid = request.isValid()
List<ValidationAnnotation> annotations = request.getAnnotations();
Here's an example of the second pattern, when your rules have inserted or modified facts:
ObjectFilter filter = new ObjectFilter() {
#Override
public boolean accept(Object object) {
return object.getClass().getSimpleName().equals("MyFact");
}
};
for (FactHandle handle : session.getFactHandles(filter)) {
Object fact = session.getObject(handle);
// Do something with the fact you just found in working memory.
// ...
}
Related
I have found many similar questions on internet and tried many solutions but still can't get around this error even after 10 hours. So please give ANY suggestion before marking it as a duplicate. I am also not familiar with hsqldb so please let me know if i am missing something very obvious.
I have a jar build with cTAKES pipeline code with spring-boot. The jar executes fine in windows but when i do this in ubuntu i get the error: user lacks privilege or object not found .
I have tried following so far
adding table name in qoutes and capitalizing table name ("cui_terms") in descriptor file (works fine in windows , doesnt work in ubuntu)
Giving absolute path to script file in descriptor (same)
adding following properties in application.properties file
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.format_sql=true
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create
sql.ignore_case=true
Any suggestion would be extremely helpful
Thanks in advance
This is the script file
SET DATABASE UNIQUE NAME HSQLDB5B3BA0CBCC
SET DATABASE GC 0
SET DATABASE DEFAULT RESULT MEMORY ROWS 0
SET DATABASE EVENT LOG LEVEL 0
SET DATABASE TRANSACTION CONTROL LOCKS
SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED
SET DATABASE TRANSACTION ROLLBACK ON CONFLICT TRUE
SET DATABASE TEXT TABLE DEFAULTS ''
SET DATABASE SQL NAMES FALSE
SET DATABASE SQL REFERENCES FALSE
SET DATABASE SQL SIZE TRUE
SET DATABASE SQL TYPES FALSE
SET DATABASE SQL TDC DELETE TRUE
SET DATABASE SQL TDC UPDATE TRUE
SET DATABASE SQL TRANSLATE TTI TYPES TRUE
SET DATABASE SQL TRANSLATE TTI TYPES TRUE
SET DATABASE SQL CONCAT NULLS TRUE
SET DATABASE SQL UNIQUE NULLS TRUE
SET DATABASE SQL CONVERT TRUNCATE TRUE
SET DATABASE SQL AVG SCALE 0
SET DATABASE SQL DOUBLE NAN TRUE
SET DATABASE SQL SYNTAX ORA TRUE
SET FILES WRITE DELAY 10
SET FILES BACKUP INCREMENT TRUE
SET FILES CACHE SIZE 10000
SET FILES CACHE ROWS 50000
SET FILES SCALE 32
SET FILES LOB SCALE 32
SET FILES DEFRAG 0
SET FILES NIO TRUE
SET FILES NIO SIZE 256
SET FILES LOG TRUE
SET FILES LOG SIZE 50
CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e'
ALTER USER SA SET LOCAL TRUE
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
SET SCHEMA PUBLIC
CREATE MEMORY TABLE PUBLIC.CUI_TERMS(CUI BIGINT,RINDEX INTEGER,TCOUNT INTEGER,TEXT VARCHAR(255),RWORD VARCHAR(48))
CREATE INDEX IDX_CUI_TERMS ON PUBLIC.CUI_TERMS(RWORD)
CREATE MEMORY TABLE PUBLIC.TUI(CUI BIGINT,TUI INTEGER)
CREATE INDEX IDX_TUI ON PUBLIC.TUI(CUI)
CREATE MEMORY TABLE PUBLIC.PREFTERM(CUI BIGINT,PREFTERM VARCHAR(511))
CREATE INDEX IDX_PREFTERM ON PUBLIC.PREFTERM(CUI)
CREATE MEMORY TABLE PUBLIC.RXNORM(CUI BIGINT,RXNORM BIGINT)
CREATE INDEX IDX_RXNORM ON PUBLIC.RXNORM(CUI)
CREATE MEMORY TABLE PUBLIC.SNOMEDCT_US(CUI BIGINT,SNOMEDCT_US BIGINT)
CREATE INDEX IDX_SNOMEDCT_US ON PUBLIC.SNOMEDCT_US(CUI)
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1
SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC
GRANT DBA TO SA
SET SCHEMA SYSTEM_LOBS
INSERT INTO BLOCKS VALUES(0,2147483647,0)
SET SCHEMA PUBLIC
INSERT INTO CUI_TERMS VALUES(97,0,1,'mptp','mptp')
INSERT INTO CUI_TERMS VALUES(97,0,1,'methylphenyltetrahydropyridine','methylphenyltetrahydropyridine')
INSERT INTO CUI_TERMS VALUES(102,0,1,'naphthalidine','naphthalidine')
This is the annotator descriptor file where configurations are define
<?xml version="1.0" encoding="UTF-8"?>
<lookupSpecification>
<dictionaries>
<dictionary>
<name>sno_rx_16abTerms</name>
<implementationName>org.apache.ctakes.dictionary.lookup2.dictionary.UmlsJdbcRareWordDictionary</implementationName>
<properties>
<!-- urls for hsqldb memory connections must be file types in hsql 1.8.
These file urls must be either absolute path or relative to current working directory.
They cannot be based upon the classpath.
Though JdbcConnectionFactory will attempt to "find" a db based upon the parent dir of the url
for the sake of ide ease-of-use, the user should be aware of these hsql limitations.
-->
<property key="jdbcDriver" value="org.hsqldb.jdbcDriver"/>
<property key="jdbcUrl" value="jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab/sno_rx_16ab"/>
<property key="jdbcUser" value="sa"/>
<property key="jdbcPass" value=""/>
<property key="rareWordTable" value="cui_terms"/>
<property key="umlsUrl" value="https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser"/>
<property key="umlsVendor" value="NLM-6515182895"/>
<property key="umlsUser" value="CHANGE_ME"/>
<property key="umlsPass" value="CHANGE_ME"/>
</properties>
</dictionary>
</dictionaries>
<conceptFactories>
<conceptFactory>
<name>sno_rx_16abConcepts</name>
<implementationName>org.apache.ctakes.dictionary.lookup2.concept.UmlsJdbcConceptFactory</implementationName>
<properties>
<property key="jdbcDriver" value="org.hsqldb.jdbcDriver"/>
<property key="jdbcUrl" value="jdbc:hsqldb:file:resources/org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab/sno_rx_16ab"/>
<property key="jdbcUser" value="sa"/>
<property key="jdbcPass" value=""/>
<property key="umlsUrl" value="https://uts-ws.nlm.nih.gov/restful/isValidUMLSUser"/>
<property key="umlsVendor" value="NLM-6515182895"/>
<property key="umlsUser" value="CHANGE_ME"/>
<property key="umlsPass" value="CHANGE_ME"/>
<property key="tuiTable" value="tui"/>
<property key="prefTermTable" value="prefTerm"/>
<!-- Optional tables for optional term info.
Uncommenting these lines alone may not persist term information;
persistence depends upon the TermConsumer. -->
<property key="rxnormTable" value="long"/>
<property key="snomedct_usTable" value="long"/>
</properties>
</conceptFactory>
</conceptFactories>
<!-- Defines what terms and concepts will be used -->
<dictionaryConceptPairs>
<dictionaryConceptPair>
<name>sno_rx_16abPair</name>
<dictionaryName>sno_rx_16abTerms</dictionaryName>
<conceptFactoryName>sno_rx_16abConcepts</conceptFactoryName>
</dictionaryConceptPair>
</dictionaryConceptPairs>
<rareWordConsumer>
<name>Term Consumer</name>
<implementationName>org.apache.ctakes.dictionary.lookup2.consumer.DefaultTermConsumer</implementationName>
</rareWordConsumer>
</lookupSpecification>
And this is the java class where connection is made
package org.apache.ctakes.dictionary.lookup2.dictionary;
import org.apache.ctakes.dictionary.lookup2.term.RareWordTerm;
import org.apache.ctakes.dictionary.lookup2.util.JdbcConnectionFactory;
import org.apache.log4j.Logger;
import org.apache.uima.UimaContext;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import static org.apache.ctakes.dictionary.lookup2.util.JdbcConnectionFactory.*;
final public class JdbcRareWordDictionary extends AbstractRareWordDictionary {
/**
* Column (field) indices in the database. Notice that these are constant and not configurable.
* If a configurable implementation is desired then create an extension.
*/
static private enum FIELD_INDEX {
CUI( 1 ), RINDEX( 2 ), TCOUNT( 3 ), TEXT( 4 ), RWORD( 5 );
final private int __index;
private FIELD_INDEX( final int index ) {
__index = index;
}
}
static final private Logger LOGGER = Logger.getLogger( "JdbcRareWordDictionary" );
static public final String RARE_WORD_TABLE = "rareWordTable";
private PreparedStatement _selectTermCall;
public JdbcRareWordDictionary( final String name, final UimaContext uimaContext, final Properties properties )
throws SQLException {
this( name,
properties.getProperty( JDBC_DRIVER ), properties.getProperty( JDBC_URL ),
properties.getProperty( JDBC_USER ), properties.getProperty( JDBC_PASS ),
properties.getProperty( RARE_WORD_TABLE ) );
}
public JdbcRareWordDictionary( final String name,
final String jdbcDriver,
final String jdbcUrl,
final String jdbcUser,
final String jdbcPass,
final String tableName )
throws SQLException {
super( name );
boolean connected = false;
try {
// DO NOT use try with resources here. Try with resources uses a closable and closes it when exiting the try
final Connection connection = JdbcConnectionFactory.getInstance()
.getConnection( jdbcDriver, jdbcUrl, jdbcUser, jdbcPass );
connected = connection != null;
_selectTermCall = createSelectCall( connection, tableName );
} catch ( SQLException sqlE ) {
if ( !connected ) {
LOGGER.error( "Could not Connect to Dictionary " + name );
} else {
LOGGER.error( "Could not create Term Data Selection Call", sqlE );
}
throw sqlE;
}
LOGGER.info( "Connected to cui and term table " + tableName.toUpperCase() );
}
#Override
public Collection<RareWordTerm> getRareWordHits( final String rareWordText ) {
final List<RareWordTerm> rareWordTerms = new ArrayList<>();
try {
fillSelectCall( rareWordText );
final ResultSet resultSet = _selectTermCall.executeQuery();
while ( resultSet.next() ) {
final RareWordTerm rareWordTerm = new RareWordTerm( resultSet.getString( FIELD_INDEX.TEXT.__index ),
resultSet.getLong( FIELD_INDEX.CUI.__index ),
resultSet.getString( FIELD_INDEX.RWORD.__index ),
resultSet.getInt( FIELD_INDEX.RINDEX.__index ),
resultSet.getInt( FIELD_INDEX.TCOUNT.__index ) );
rareWordTerms.add( rareWordTerm );
}
resultSet.close();
} catch ( SQLException e ) {
LOGGER.error( e.getMessage() );
}
return rareWordTerms;
}
static private PreparedStatement createSelectCall( final Connection connection, final String tableName )
throws SQLException {
final String lookupSql = "SELECT * FROM " + tableName + " WHERE RWORD = ?";
return connection.prepareStatement( lookupSql );
}
/**
* #param rareWordText text of the rare word to use for term lookup
* #return an sql call to use for term lookup
* #throws SQLException if the {#code PreparedStatement} could not be created or changed
*/
private PreparedStatement fillSelectCall( final String rareWordText ) throws SQLException {
_selectTermCall.clearParameters();
_selectTermCall.setString( 1, rareWordText );
return _selectTermCall;
}
}
Following is the exception occurred
11 Apr 2019 12:14:47 INFO AbstractJCasTermAnnotator - Exclusion tagset loaded: CC CD DT EX IN LS MD PDT POS PP PP$ PRP PRP$ RP TO VB VBD VBG VBN VBP VBZ WDT WP WPS WRB
11 Apr 2019 12:14:47 INFO AbstractJCasTermAnnotator - Using minimum term text span: 3
11 Apr 2019 12:14:47 INFO AbstractJCasTermAnnotator - Using Dictionary Descriptor: org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab.xml
11 Apr 2019 12:14:48 INFO DictionaryDescriptorParser - Parsing dictionary specifications:
11 Apr 2019 12:14:49 INFO JdbcConnectionFactory - Connecting to jdbc:hsqldb:file:org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab/sno_rx_16ab:
2019-04-11 12:14:49.223 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : Checkpoint start
2019-04-11 12:14:49.224 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : checkpointClose start
2019-04-11 12:14:49.300 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : checkpointClose synched
2019-04-11 12:14:49.317 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : checkpointClose script done
2019-04-11 12:14:49.323 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : checkpointClose end
2019-04-11 12:14:49.327 INFO 5458 --- [nio-8080-exec-1] hsqldb.db.HSQLDB6A0B3FC2C1.ENGINE : Checkpoint end - txts: 1
11 Apr 2019 12:14:49 INFO JdbcConnectionFactory - Database connected
11 Apr 2019 12:14:49 ERROR JdbcRareWordDictionary - Could not create Term Data Selection Call
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: CUI_TERMS in statement [SELECT * FROM CUI_TERMS WHERE RWORD = ?]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at org.apache.ctakes.dictionary.lookup2.dictionary.JdbcRareWordDictionary.createSelectCall(JdbcRareWordDictionary.java:139)
at org.apache.ctakes.dictionary.lookup2.dictionary.JdbcRareWordDictionary.<init>(JdbcRareWordDictionary.java:93)
at org.apache.ctakes.dictionary.lookup2.dictionary.JdbcRareWordDictionary.<init>(JdbcRareWordDictionary.java:75)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.apache.ctakes.dictionary.lookup2.dictionary.DictionaryDescriptorParser.parseDictionary(DictionaryDescriptorParser.java:196)
at org.apache.ctakes.dictionary.lookup2.dictionary.DictionaryDescriptorParser.parseDictionaries(DictionaryDescriptorParser.java:156)
at org.apache.ctakes.dictionary.lookup2.dictionary.DictionaryDescriptorParser.parseDescriptor(DictionaryDescriptorParser.java:128)
at org.apache.ctakes.dictionary.lookup2.ae.AbstractJCasTermAnnotator.initialize(AbstractJCasTermAnnotator.java:129)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:261)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:175)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:140)
at com.canehealth.spring.ctakes.service.CtakesService.runCollectionProccesingEngine(CtakesService.java:284)
at com.canehealth.spring.ctakes.service.CtakesService.Jcas2json(CtakesService.java:146)
at com.canehealth.spring.ctakes.controller.RestApiController.post_text(RestApiController.java:61)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at com.canehealth.spring.ctakes.configuration.CORSFilter.doFilter(CORSFilter.java:30)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: CUI_TERMS
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source)
at org.hsqldb.ParserDQL.XreadFromClause(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 128 more
The issue here is: Where are the database files? By default, HSQLDB creates an empty database when none exists at the given URL. In order to ensure your database URL points to the correct location, append ;ifexists=true at the end of both jdbcUrl properties. See http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_connection_props
Second, the paths in the jdbcUrl's that you specify are file:, which means a directory structure, but the paths look like pointing to a jar (res:) resource. If the database is in a jar, use the correct type of URL.
If the database files are not in a jar, but are stored in a read-only location in the given directory structure, you may still be able to connect with res:.
Hi I have made an if query and this question goes to the server. However, the server will only accept 2 numbers and a decimal number (99.9) but I have to count up to 100, the server always gives me an error.
Do you know maybe how I can catch this error so that my software anyway Counts to 100. It must not be output to the server. The program should run only on. He shall not make it stop at 99 again and continue counting down So when he comes at 99 and then 100.
public static void main(String[] args)
{
boolean positive = true;
int counter = 0;
while (true)
{
if (counter >= 99)
{
positive = false;
}
if (counter <=-99)
{
positive = true;
}
if (positive == true)
{
counter ++;
}
else
{
counter --;
}
That's my "Software" And the Exception is:
Exception = Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html><head><title>Apache Tomcat/7.0.47 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.NoClassDefFoundError: org/springframework/dao/QueryTimeoutException
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:86)
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:102)
org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:849)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyHolderInternal(AbstractJdbcInsert.java:436)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.executeInsertAndReturnKeyInternal(AbstractJdbcInsert.java:417)
org.springframework.jdbc.core.simple.AbstractJdbcInsert.doExecuteAndReturnKey(AbstractJdbcInsert.java:371)
org.springframework.jdbc.core.simple.SimpleJdbcInsert.executeAndReturnKey(SimpleJdbcInsert.java:122)
de.fraunhofer.iao.sharedefleet.energiemanagement.backend.ChargePointLogDAO.insertChargePointRequest(ChargePointLogDAO.java:65)
de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.handleHeartbeatRequest(PlugAndChargeFacade.java:55)
de.fraunhofer.iao.sharedefleet.energiemanagement.facade.PlugAndChargeFacade.requestChargingState(PlugAndChargeFacade.java:142)
de.fraunhofer.iao.sharedefleet.energiemanagement.services.EVSEHeartbeatEndpoint.requestChargingState(EVSEHeartbeatEndpoint.java:34)
sun.reflect.GeneratedMethodAccessor143.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:240)
org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:53)
org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:233)
org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:173)
org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:59)
org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:239)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
</pre></p><p><b>root cause</b> <pre>java.lang.ClassNotFoundException: org.springframework.dao.QueryTimeoutException.
So I hope you can help me.
Thats my main
public class Main {
public static void main(String[] args)
{
boolean positive = true;
int counter = 0;
while (true)
{
if (counter >= 99)
{
positive = false;
}
if (counter <=-99)
{
positive = true;
}
if (positive == true)
{
counter ++;
}
else
{
counter --;
}
CloudCommunicator ccc = new CloudCommunicator("sh1");
EnergyManagerJob emj = ccc.SendRequest (true , true, 1 , 100 , "Nori2");
System.out.println("\nmax Current: " + emj.allowedMaximumCurrent);
System.out.println("charging status: " +emj.chargingPending);
System.out.println("power: " +emj.powerOn);
try
{
Thread.sleep(10000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
} // end of while
}// end of main
For the error you've posted, you'll need to find and add the spring-tx library to your classpath. You can add it to /WEB-INF/lib.
However, I don't see how the exception you've posted and the code you've posted relate to each other.
The server may be missing a dependency: spring-tx.
You can download the jar or add it to your project dependencies here: http://mvnrepository.com/artifact/org.springframework/spring-tx
Sotirios Delimanolis is right, please also avoid putting while(true) because it is an infinite loop, you can put for example while(positive), this will increment the counter until it gets to 99.
I have a JSP page with two tabs and I am trying to run some Java code in the second tab but I keep getting a null pointer exception. I swear my Java Code is correct but the second tab wont show up either.
<%
String fn = request.getParameter("fn9");
String ln = request.getParameter("ln9");
String primaryEmail = request.getParameter("primaryemail9");
CreatingTheProviderFile ctpf = new CreatingTheProviderFile();
char[] c = fn.toCharArray();
if(fn != null){
System.out.println("it is blank");
}else{
System.out.println("it is something else");
}
if(fn != ''){
ctpf.FillNameArray(fn, ln, primaryEmail);
}
%>
JSP for some reason doesnt like the char statement nor does it like the if statement. This is my stacktrace
Dec 18, 2013 11:37:33 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/TwoWayPortal] threw exception [An exception occurred processing JSP page /patient_discharge.jsp at line 800
797:
798: // CreatingTheProviderFile ctpf = new CreatingTheProviderFile();
799:
800: char[] c = fn.toCharArray();
801:
802: System.out.println(c[0]);
803: // System.out.println(String.valueOf(fn.charAt(0)));
Stacktrace:] with root cause
java.lang.NullPointerException
at org.apache.jsp.patient_005fdischarge_jsp._jspService(patient_005fdischarge_jsp.java:999)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:205)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
I appreciate any help,
Thank You
The line that throws the NullPointerException is the line with fn.toCharArray(); This implies that fn is null.
Try
if(fn != null){
//do stuff here
}
Yes. fn is null.
// test for null, init to null if fn is null.
char[] c = (fn != null) ? fn.toCharArray() : null;
if (fn != null) {
System.out.println("it is not null");
if (fn.length() > 0) { // fn != '' is illegal, could have used !fn.equals("") -
// note double quotes (not single).
ctpf.FillNameArray(fn, ln, primaryEmail);
}
} else {
System.out.println("it is something else");
}
Before doing fn.toCharArray() check whether fn is null or not. You are checking it later. But if fn is null, you will get exception on fn.toCharArray() only and rest of the code wont execute.
When you change tabs, you may be losing data in request scope (just a guess). As an experiment, you can consider putting data in session scope instead. If it works, you may conider weather or not its of value to leave it as session scope.
Following is my code which runs pigrunner and pigstats:
String[] args = {"abc.pig"};
PigStats stats = PigRunner.run(args,null);
System.out.println("Stats : " + stats.getReturnCode());
OutputStats os = stats.result("B");
Iterator<Tuple> it = os.iterator();
while(it.hasNext()){
Tuple t = it.next();
System.out.println(t.getAll());
}
Contents of abc.pig
A = load 'Courses' using PigStorage(' ');
B = foreach A generate $0 as id;
dump B;
I get the correct output but it is followed by this exception Stacktrace with root cause
org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://localhost:54310/tmp/temp-221133443/tmp1478461116
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:235)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigFileInputFormat.listStatus(PigFileInputFormat.java:37)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:252)
at org.apache.pig.impl.io.ReadToEndLoader.init(ReadToEndLoader.java:154)
at org.apache.pig.impl.io.ReadToEndLoader.<init>(ReadToEndLoader.java:116)
at org.apache.pig.tools.pigstats.OutputStats.iterator(OutputStats.java:148)
at org.apache.jsp.result_jsp._jspService(result_jsp.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Now the same code works without an error if I replace the DUMP with a STORE.
Can some please explain me what is going on ?
Thanks
Ravi
In case of dump Pig stores the output at a temporary location, e.g: hdfs://localhost/tmp/temp797130848/tmp1101984728
(have a look pig.map.output.dirs in your job's config.xml)
PigRunner.run() calls GruntParser.processDump(String alias) at some point of the process which iterates through the result tuples and prints them out to the console:
Iterator<Tuple> result = mPigServer.openIterator(alias);
while (result.hasNext())
{
Tuple t = result.next();
System.out.println(TupleFormat.format(t));
}
After this, but before returning, it also calls FileLocalizer.deleteTempFiles() which deletes this temporary directory.
Now you want to return the result of alias B.
OutputStats's iterator tries to open the temporary file again to loop over the tuples as PigRunner.run() did it before.
But the problem is that this file doesn't exist anymore, therefore your get the exception.
So I'd suggest you to remove the code after System.out.println("Stats : " + stats.getReturnCode()); since you already have the dump printed out.
I am building a web application for feature extraction and comparing the feature of images, using JSP, Java, and PostgreSQL.
My feature extraction is extracting some features from images, so that then I can compare them (some features are about color, some on the histogram of the image and so. I have special methods that extract them using specific libraries (jars that I add into lib) as you can see in the following example!
Those features are then successfully being added into my PostgreSQL database.
public void GetImageProperties(String targetPath, ImageProperties imagesProperties) throws Exception
{
// load image
FileInputStream imageStream;
imageStream = new FileInputStream(targetPath);
BufferedImage bimg = ImageIO.read(imageStream);
// get properties
imagesProperties.cl = new ColorLayoutImpl(bimg);
imagesProperties.eh = new EdgeHistogramImplementation(bimg);
imagesProperties.sc = new ScalableColorImpl(bimg);
}
Then I add them into a postgresql database(only the features, not the images)
String query = "CREATE TABLE Images (" +
" imageid SERIAL PRIMARY KEY," +
" fname VARCHAR(128)," +
" colorlayout VARCHAR(512), " +
" edgehist VARCHAR(512), " +
" scalablecolor VARCHAR(512) " +
")";
I get this error every time I had loaded an image and want to compare it with all the other images in a directory.
HTTP Status 500 -
type Exception report
message:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception:
org.apache.jasper.JasperException: An exception occurred processing JSP page /query.jsp at line 124
121: if (bSearch) {
122: // get form params
123: query.setTopK(new Integer(request.getParameter("frm_topk")));
124: query.setColorHistogramWeight(new Integer(request.getParameter("frm_weight_c1")));
125: query.setColorDistributionWeight(new Integer(request.getParameter("frm_weight_c2")));
126: query.setTextureWeight(new Integer(request.getParameter("frm_weight_c3")));
127: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause:
java.lang.NumberFormatException: For input string: "1.0"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:492) java.lang.Integer.<init>
(Integer.java:677) org.apache.jsp.query_jsp._jspService(query_jsp.java:256)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
Your problem is here
query.setTopK(new Integer(request.getParameter("frm_topk")));
should be
String parFrm_topk = request.getParameter("frm_topk");
Integer frm_topk = null;
if (parFrm_topk != null && parFrm_topk.length() > 0 && !parFrm_topk.equals("null"))
try {
frm_topk = Integer.valueOf(parFrm_topk);
} catch (NumberFormatException nfe){
throw nfe;
}
if (frm_topk ! = null) {
query.setTopK(frm_topk);
this code is trying to check the parameter that could be empty, why it is empty depends on how flow the app and how parameters are passed through url.